Skip to content

Commit

Permalink
latest from CODA-OSS and NITRO
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Nov 8, 2023
1 parent f174846 commit 3e75b38
Show file tree
Hide file tree
Showing 43 changed files with 99 additions and 118 deletions.
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
case cli::SUB_OPTIONS:
{
if (optionsStr.empty())
parseError(str::Format("invalid sub option: [%s]", argVar.c_str()));
parseError(str::Format("invalid sub option: [%s]", argVar));

auto v_ = std::make_unique<cli::Value>();
auto v = currentResults->hasValue(optionsStr) ? currentResults->getValue(optionsStr) : v_.get();
Expand Down Expand Up @@ -706,7 +706,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
}
if (!isValid)
{
parseError(str::Format("invalid option for [%s]", argVar.c_str()));
parseError(str::Format("invalid option for [%s]", argVar));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void BufferViewStream<T>::write(const void* buffer, size_t numBytes)
{
std::ostringstream msg;
msg << "Write of size " << numBytes << " runs out of bounds.";
throw except::Exception(Ctxt(msg.str()));
throw except::Exception(Ctxt(msg));
}

::memcpy(mBufferView.data + mPosition, buffer, numBytes);
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/io/include/io/FileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inline void move(const std::string& path,
oss << "Move Failed: Could not move source [" <<
path << "] to destination [" <<
newPath << "]";
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
}

Expand Down
5 changes: 2 additions & 3 deletions externals/coda-oss/modules/c++/io/source/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void io::copy(const std::string& path,
oss << "Copy Failed: Could not copy source [" <<
path << "] to destination [" <<
newFile << "]";
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
}
}
Expand All @@ -133,8 +133,7 @@ std::string io::FileUtils::createFile(std::string dirname,
sys::OS os;

if (!os.exists(dirname))
throw except::IOException(Ctxt(str::Format("Directory does not exist: %s",
dirname.c_str())));
throw except::IOException(Ctxt(str::Format("Directory does not exist: %s", dirname)));

str::trim(filename);

Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/io/source/InputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ sys::SSize_T InputStream::read(void* buffer,
{
std::ostringstream ostr;
ostr << "Tried to read " << len << " bytes but read failed";
throw except::IOException(Ctxt(ostr.str()));
throw except::IOException(Ctxt(ostr));
}
else if (numBytes != static_cast<sys::SSize_T>(len))
{
std::ostringstream ostr;
ostr << "Tried to read " << len << " bytes but only read "
<< numBytes << " bytes";
throw except::IOException(Ctxt(ostr.str()));
throw except::IOException(Ctxt(ostr));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void io::MMapInputStream::open(const std::string& fname, char* flags)
// std::cout << mLength << std::endl;
mFile = fopen(fname.c_str(), "r");
if (!mFile)
throw sys::SystemException(str::Format("Failure while opening file: %s", fname.c_str()));
throw sys::SystemException(str::Format("Failure while opening file: %s", fname));

_map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ StreamSplitter::StreamSplitter(io::InputStream& inputStream,
std::ostringstream os;
os << "bufferSize must be >= twice the delimiter size + 1 byte. "
<< "Normally it should be much larger for good performance.";
throw except::InvalidArgumentException(Ctxt(os.str()));
throw except::InvalidArgumentException(Ctxt(os));
}
}

Expand Down
6 changes: 3 additions & 3 deletions externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class A : public Serializable
string vec_2 = fillString(is);

assert(classType == "Class A");
dbg.writeln(str::Format("vec[0] = %s", vec_0.c_str()));
dbg.writeln(str::Format("vec[1] = %s", vec_1.c_str()));
dbg.writeln(str::Format("vec[2] = %s", vec_2.c_str()));
dbg.writeln(str::Format("vec[0] = %s", vec_0));
dbg.writeln(str::Format("vec[1] = %s", vec_1));
dbg.writeln(str::Format("vec[2] = %s", vec_2));

vec[0] = str::toType<float>(vec_0);
vec[1] = str::toType<float>(vec_1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct LogLevel final
else if (s == "SEVERE")
value = LOG_CRITICAL;
else
throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %s", s.c_str())));
throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %s", s)));
}

//! int constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ template<typename Vector_T> OneD<double> fit(const Vector_T& x,
<< sizeX << " points for an order-" << order
<< "fit)! You should really have at least (order+1) = "
<< (order+1) << " points for this to do what you expect.";
throw except::Exception(Ctxt(excSS.str()));
throw except::Exception(Ctxt(excSS));
}

// Compute mean value
Expand Down Expand Up @@ -206,7 +206,7 @@ inline math::poly::TwoD<double> fit(const math::linear::Matrix2D<double>& x,
<< x.size() << " points for a " << acols << "-coefficient fit)!"
<< " You should really have at least (orderX+1)*(orderY+1) = "
<< acols << " points for this to do what you expect.";
throw except::Exception(Ctxt(excSS.str()));
throw except::Exception(Ctxt(excSS));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ OneD<_T>::operator [] (size_t i)
}
else
{
std::stringstream str;
str << "index: " << i << " not within range [0..."
<< mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str.str()));
std::ostringstream str;
str << "index: " << i << " not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str));
}
}

Expand All @@ -196,9 +195,9 @@ OneD<_T>::operator [] (size_t i) const
}
else
{
std::stringstream str;
std::ostringstream str;
str << "idx(" << i << ") not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str.str()));
throw except::IndexOutOfRangeException(Ctxt(str));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,9 @@ TwoD<_T>::operator [] (size_t i) const
}
else
{
std::stringstream str;
str << "index:" << i << " not within range [0..."
<< mCoef.size() << ")";

throw except::IndexOutOfRangeException(Ctxt(str.str()));
std::ostringstream str;
str << "index:" << i << " not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str));
}
return ret;
}
Expand All @@ -206,10 +204,9 @@ TwoD<_T>::operator [] (size_t i)
}
else
{
std::stringstream str;
str << "index: " << i << " not within range [0..."
<< mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str.str()));
std::ostringstream str;
str << "index: " << i << " not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct BufferView
oss << "BufferView::section() called with sectionSize: " << sectionSize << " when";
oss << " there were only " << size << " elements in the BufferView";

throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}

BufferView<T> newSection(data, sectionSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline void ScratchMemory::put<sys::ubyte>(const std::string& key,
{
std::ostringstream oss;
oss << "Scratch memory space was already reserved for " << key;
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
mSegments.insert(
iterSeg,
Expand Down
12 changes: 5 additions & 7 deletions externals/coda-oss/modules/c++/mem/source/ScratchMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,25 @@ const ScratchMemory::Segment& ScratchMemory::lookupSegment(
if (mBuffer.data == nullptr)
{
std::ostringstream oss;
oss << "Tried to get scratch memory for \"" << key
<< "\" before running setup.";
throw except::Exception(Ctxt(oss.str()));
oss << "Tried to get scratch memory for \"" << key << "\" before running setup.";
throw except::Exception(Ctxt(oss));
}

std::map<std::string, Segment>::const_iterator iterSeg = mSegments.find(key);
if (iterSeg == mSegments.end())
{
std::ostringstream oss;
oss << "Scratch memory segment was not found for \"" << key << "\"";
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}

const Segment& segment = iterSeg->second;
if (indexBuffer >= segment.buffers.size())
{
std::ostringstream oss;
oss << "Trying to get buffer index " << indexBuffer << " for \""
<< key << "\", which has only " << segment.buffers.size()
<< " buffers";
throw except::Exception(Ctxt(oss.str()));
<< key << "\", which has only " << segment.buffers.size() << " buffers";
throw except::Exception(Ctxt(oss));
}
return segment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void runBalanced1D(size_t numElements,
std::ostringstream ostr;
ostr << "Got " << numThreads << " threads but " << ops.size()
<< " functors";
throw except::Exception(Ctxt(ostr.str()));
throw except::Exception(Ctxt(ostr));
}

if (numThreads <= 1)
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/mt/include/mt/Runnable1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void run1D(size_t numElements, size_t numThreads, const std::vector<OpT>& ops)
std::ostringstream ostr;
ostr << "Got " << numThreads << " threads but " << ops.size()
<< " functors";
throw except::Exception(Ctxt(ostr.str()));
throw except::Exception(Ctxt(ostr));
}

if (numThreads <= 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void runWorkSharingBalanced1D(size_t numElements,
std::ostringstream ostr;
ostr << "Got " << numThreads << " threads but " << ops.size()
<< " functors";
throw except::Exception(Ctxt(ostr.str()));
throw except::Exception(Ctxt(ostr));
}

std::vector<size_t> threadPoolEndElements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct AvailableCPUProvider final : public AbstractNextCPUProviderLinux
{
std::ostringstream msg;
msg << "No more CPUs available (size = " << mCPUs.size() << ")";
throw except::Exception(Ctxt(msg.str()));
throw except::Exception(Ctxt(msg));
}

std::unique_ptr<sys::ScopedCPUMaskUnix> mask(new sys::ScopedCPUMaskUnix());
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/net/include/net/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class Socket

std::ostringstream oss;
oss << "Socket setOptions failure: " << err.toString();
throw sys::SocketException(Ctxt(oss.str()));
throw sys::SocketException(Ctxt(oss));
}
}

Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/net/source/DaemonUnix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ void DaemonUnix::redirectStreamsTo(const std::string& filename)
if (openFileFor(STDOUT_FILENO, filename, O_WRONLY|O_CREAT|O_TRUNC) < 0)
{
throw except::Exception(
Ctxt(str::Format("Failed to open file %s for STDOUT.", filename.c_str())));
Ctxt(str::Format("Failed to open file %s for STDOUT.", filename)));
}
if (openFileFor(STDERR_FILENO, filename, O_WRONLY|O_CREAT|O_TRUNC) < 0)
{
throw except::Exception(
Ctxt(str::Format("Failed to open file %s for STDERR.", filename.c_str())));
Ctxt(str::Format("Failed to open file %s for STDERR.", filename)));
}
}

Expand Down
6 changes: 3 additions & 3 deletions externals/coda-oss/modules/c++/net/source/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ size_t net::Socket::recv(void* b, size_t len, int flags)
oss << "When receiving " << str::toString(len) << " bytes: " <<
err.toString();

throw sys::SocketException(Ctxt(oss.str()));
throw sys::SocketException(Ctxt(oss));
}
else if (numBytes == 0)
{
Expand Down Expand Up @@ -170,7 +170,7 @@ void net::Socket::send(const void* b, size_t len, int flags)
oss << "Tried sending " << len << " bytes, " <<
numBytes << " sent: " << err.toString();

throw sys::SocketException(Ctxt(oss.str()));
throw sys::SocketException(Ctxt(oss));
}
}

Expand All @@ -193,6 +193,6 @@ void net::Socket::sendTo(const SocketAddress& address,
oss << "Tried sending " << len << " bytes, " << numBytes << " sent: "
<< err.toString();

throw sys::SocketException(Ctxt(oss.str()));
throw sys::SocketException(Ctxt(oss));
}
}
5 changes: 2 additions & 3 deletions externals/coda-oss/modules/c++/polygon/source/PolygonMask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,8 @@ PolygonMask::PolygonMask(const std::vector<types::RowCol<double> >& points,
// happen.
std::ostringstream ostr;
ostr << "Requires a convex polygon but these points produced "
<< intersectionsVec.size() << " intersections for row "
<< row;
throw except::Exception(Ctxt(ostr.str()));
<< intersectionsVec.size() << " intersections for row " << row;
throw except::Exception(Ctxt(ostr));
}
}

Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class ScopedMatchData
ostr << "Match: Match substring out of range ("
<< index << ", " << end << ") for string of length "
<< str.length();
throw re::RegexException(Ctxt(ostr.str()));
throw re::RegexException(Ctxt(ostr));
}

const size_t subStringLength = end - index;
Expand Down Expand Up @@ -225,7 +225,7 @@ Regex& Regex::compile(const std::string& pattern)
std::ostringstream ostr;
ostr << "PCRE compilation failed at offset " << errorOffset
<< ": " << getErrorMessage(errorCode);
throw RegexException(Ctxt(ostr.str()));
throw RegexException(Ctxt(ostr));
}

return *this;
Expand Down
6 changes: 2 additions & 4 deletions externals/coda-oss/modules/c++/sys/source/FileWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ void sys::File::create(const std::string& str,
create(std::nothrow, str, accessFlags, creationFlags);
if (mHandle == INVALID_HANDLE_VALUE)
{
throw sys::SystemException(
Ctxt(str::Format("Error opening file: [%s]", str.c_str())));
throw sys::SystemException(Ctxt(str::Format("Error opening file: [%s]", str)));
}
}

Expand Down Expand Up @@ -169,8 +168,7 @@ sys::Off_T sys::File::lastModifiedTime()
return (sys::Off_T)stInMillis;
}
throw sys::SystemException(Ctxt(
str::Format("Error getting last modified time for path %s",
mPath.c_str())));
str::Format("Error getting last modified time for path %s", mPath)));
}

void sys::File::flush()
Expand Down
Loading

0 comments on commit 3e75b38

Please sign in to comment.