diff --git a/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp b/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp index 367ff9edce..e6c8fb4442 100644 --- a/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp +++ b/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp @@ -579,7 +579,7 @@ std::unique_ptr 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(); auto v = currentResults->hasValue(optionsStr) ? currentResults->getValue(optionsStr) : v_.get(); @@ -706,7 +706,7 @@ std::unique_ptr 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)); } } } diff --git a/externals/coda-oss/modules/c++/io/include/io/BufferViewStream.h b/externals/coda-oss/modules/c++/io/include/io/BufferViewStream.h index beb00d23a2..5f71ae46ca 100644 --- a/externals/coda-oss/modules/c++/io/include/io/BufferViewStream.h +++ b/externals/coda-oss/modules/c++/io/include/io/BufferViewStream.h @@ -191,7 +191,7 @@ void BufferViewStream::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); diff --git a/externals/coda-oss/modules/c++/io/include/io/FileUtils.h b/externals/coda-oss/modules/c++/io/include/io/FileUtils.h index d8305fc0c5..927aeb4f5b 100644 --- a/externals/coda-oss/modules/c++/io/include/io/FileUtils.h +++ b/externals/coda-oss/modules/c++/io/include/io/FileUtils.h @@ -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)); } } diff --git a/externals/coda-oss/modules/c++/io/source/FileUtils.cpp b/externals/coda-oss/modules/c++/io/source/FileUtils.cpp index 5c61540576..e0aaf24ea7 100644 --- a/externals/coda-oss/modules/c++/io/source/FileUtils.cpp +++ b/externals/coda-oss/modules/c++/io/source/FileUtils.cpp @@ -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)); } } } @@ -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); diff --git a/externals/coda-oss/modules/c++/io/source/InputStream.cpp b/externals/coda-oss/modules/c++/io/source/InputStream.cpp index e39ac48a6b..b85dcf37d4 100644 --- a/externals/coda-oss/modules/c++/io/source/InputStream.cpp +++ b/externals/coda-oss/modules/c++/io/source/InputStream.cpp @@ -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(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)); } } diff --git a/externals/coda-oss/modules/c++/io/source/MMapInputStream.cpp b/externals/coda-oss/modules/c++/io/source/MMapInputStream.cpp index e1391083a5..35959ef01f 100644 --- a/externals/coda-oss/modules/c++/io/source/MMapInputStream.cpp +++ b/externals/coda-oss/modules/c++/io/source/MMapInputStream.cpp @@ -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(); diff --git a/externals/coda-oss/modules/c++/io/source/StreamSplitter.cpp b/externals/coda-oss/modules/c++/io/source/StreamSplitter.cpp index 57d6a2f603..dbef8edc2e 100644 --- a/externals/coda-oss/modules/c++/io/source/StreamSplitter.cpp +++ b/externals/coda-oss/modules/c++/io/source/StreamSplitter.cpp @@ -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)); } } diff --git a/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp b/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp index 01fb74dd89..5229fb2652 100644 --- a/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp +++ b/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp @@ -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(vec_0); vec[1] = str::toType(vec_1); diff --git a/externals/coda-oss/modules/c++/logging/include/logging/Enums.h b/externals/coda-oss/modules/c++/logging/include/logging/Enums.h index 8569a8c49f..9175a8126d 100644 --- a/externals/coda-oss/modules/c++/logging/include/logging/Enums.h +++ b/externals/coda-oss/modules/c++/logging/include/logging/Enums.h @@ -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 diff --git a/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fit.h b/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fit.h index 0a3978fdbc..3e54777bf7 100644 --- a/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fit.h +++ b/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fit.h @@ -82,7 +82,7 @@ template OneD 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 @@ -206,7 +206,7 @@ inline math::poly::TwoD fit(const math::linear::Matrix2D& 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)); } diff --git a/externals/coda-oss/modules/c++/math.poly/include/math/poly/OneD.hpp b/externals/coda-oss/modules/c++/math.poly/include/math/poly/OneD.hpp index 67fb59b7b8..9aa0253540 100644 --- a/externals/coda-oss/modules/c++/math.poly/include/math/poly/OneD.hpp +++ b/externals/coda-oss/modules/c++/math.poly/include/math/poly/OneD.hpp @@ -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)); } } @@ -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)); } } diff --git a/externals/coda-oss/modules/c++/math.poly/include/math/poly/TwoD.hpp b/externals/coda-oss/modules/c++/math.poly/include/math/poly/TwoD.hpp index 2a26275404..87d7f72178 100644 --- a/externals/coda-oss/modules/c++/math.poly/include/math/poly/TwoD.hpp +++ b/externals/coda-oss/modules/c++/math.poly/include/math/poly/TwoD.hpp @@ -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; } @@ -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)); } } diff --git a/externals/coda-oss/modules/c++/mem/include/mem/BufferView.h b/externals/coda-oss/modules/c++/mem/include/mem/BufferView.h index 02816c5260..55997392b2 100644 --- a/externals/coda-oss/modules/c++/mem/include/mem/BufferView.h +++ b/externals/coda-oss/modules/c++/mem/include/mem/BufferView.h @@ -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 newSection(data, sectionSize); diff --git a/externals/coda-oss/modules/c++/mem/include/mem/ScratchMemory.hpp b/externals/coda-oss/modules/c++/mem/include/mem/ScratchMemory.hpp index 45c6fcd261..7b22af8354 100644 --- a/externals/coda-oss/modules/c++/mem/include/mem/ScratchMemory.hpp +++ b/externals/coda-oss/modules/c++/mem/include/mem/ScratchMemory.hpp @@ -52,7 +52,7 @@ inline void ScratchMemory::put(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, diff --git a/externals/coda-oss/modules/c++/mem/source/ScratchMemory.cpp b/externals/coda-oss/modules/c++/mem/source/ScratchMemory.cpp index a3f162daa0..4677b1da99 100644 --- a/externals/coda-oss/modules/c++/mem/source/ScratchMemory.cpp +++ b/externals/coda-oss/modules/c++/mem/source/ScratchMemory.cpp @@ -212,9 +212,8 @@ 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::const_iterator iterSeg = mSegments.find(key); @@ -222,7 +221,7 @@ const ScratchMemory::Segment& ScratchMemory::lookupSegment( { 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; @@ -230,9 +229,8 @@ const ScratchMemory::Segment& ScratchMemory::lookupSegment( { 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; } diff --git a/externals/coda-oss/modules/c++/mt/include/mt/BalancedRunnable1D.h b/externals/coda-oss/modules/c++/mt/include/mt/BalancedRunnable1D.h index c7af782fb7..3ee200e04d 100644 --- a/externals/coda-oss/modules/c++/mt/include/mt/BalancedRunnable1D.h +++ b/externals/coda-oss/modules/c++/mt/include/mt/BalancedRunnable1D.h @@ -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) diff --git a/externals/coda-oss/modules/c++/mt/include/mt/Runnable1D.h b/externals/coda-oss/modules/c++/mt/include/mt/Runnable1D.h index dbcde3aada..fb277b1e8c 100644 --- a/externals/coda-oss/modules/c++/mt/include/mt/Runnable1D.h +++ b/externals/coda-oss/modules/c++/mt/include/mt/Runnable1D.h @@ -75,7 +75,7 @@ void run1D(size_t numElements, size_t numThreads, const std::vector& 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) diff --git a/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h b/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h index dd8e4553de..95f36e6a75 100644 --- a/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h +++ b/externals/coda-oss/modules/c++/mt/include/mt/WorkSharingBalancedRunnable1D.h @@ -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 threadPoolEndElements; diff --git a/externals/coda-oss/modules/c++/mt/source/CPUAffinityInitializerLinux.cpp b/externals/coda-oss/modules/c++/mt/source/CPUAffinityInitializerLinux.cpp index 7da70537a7..2f728fad97 100644 --- a/externals/coda-oss/modules/c++/mt/source/CPUAffinityInitializerLinux.cpp +++ b/externals/coda-oss/modules/c++/mt/source/CPUAffinityInitializerLinux.cpp @@ -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 mask(new sys::ScopedCPUMaskUnix()); diff --git a/externals/coda-oss/modules/c++/net/include/net/Socket.h b/externals/coda-oss/modules/c++/net/include/net/Socket.h index 7d75eae466..024af735c5 100644 --- a/externals/coda-oss/modules/c++/net/include/net/Socket.h +++ b/externals/coda-oss/modules/c++/net/include/net/Socket.h @@ -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)); } } diff --git a/externals/coda-oss/modules/c++/net/source/DaemonUnix.cpp b/externals/coda-oss/modules/c++/net/source/DaemonUnix.cpp index 797f515788..af0a1e0bf6 100644 --- a/externals/coda-oss/modules/c++/net/source/DaemonUnix.cpp +++ b/externals/coda-oss/modules/c++/net/source/DaemonUnix.cpp @@ -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))); } } diff --git a/externals/coda-oss/modules/c++/net/source/Socket.cpp b/externals/coda-oss/modules/c++/net/source/Socket.cpp index 4fa436453c..b7b8627c5d 100644 --- a/externals/coda-oss/modules/c++/net/source/Socket.cpp +++ b/externals/coda-oss/modules/c++/net/source/Socket.cpp @@ -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) { @@ -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)); } } @@ -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)); } } diff --git a/externals/coda-oss/modules/c++/polygon/source/PolygonMask.cpp b/externals/coda-oss/modules/c++/polygon/source/PolygonMask.cpp index d9a729feff..6ad904aa2f 100644 --- a/externals/coda-oss/modules/c++/polygon/source/PolygonMask.cpp +++ b/externals/coda-oss/modules/c++/polygon/source/PolygonMask.cpp @@ -134,9 +134,8 @@ PolygonMask::PolygonMask(const std::vector >& 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)); } } diff --git a/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp b/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp index 94fd0b9ec9..01b0393b3f 100644 --- a/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp +++ b/externals/coda-oss/modules/c++/re/source/RegexPCRE.cpp @@ -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; @@ -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; diff --git a/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp b/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp index cf30c9f6cc..d1ed79a67d 100644 --- a/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp +++ b/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp @@ -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))); } } @@ -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() diff --git a/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp b/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp index d1806010d8..9a3cb61b9a 100644 --- a/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp @@ -122,7 +122,7 @@ std::set get_unique_thread_siblings() std::ostringstream msg; msg << "Unable to open thread siblings file " << tsPath.getPath(); - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } std::string tsContents; @@ -176,7 +176,7 @@ void sys::OSUnix::removeFile(const std::string& pathname) const oss << "Failure removing file [" << pathname << "] with error [" << err.toString() << "]"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } } @@ -189,7 +189,7 @@ void sys::OSUnix::removeDirectory(const std::string& pathname) const oss << "Failure removing directory [" << pathname << "] with error [" << err.toString() << "]"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } } @@ -463,7 +463,7 @@ void sys::OSUnix::removeSymlink(const std::string& symlinkPathname) const oss << "Failure removing symlink [" << symlinkPathname << "] with error [" << err.toString() << "]"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } } diff --git a/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp b/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp index bde4cb5d28..57145274ff 100644 --- a/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp +++ b/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp @@ -112,7 +112,7 @@ void sys::OSWin32::removeFile(const std::string& pathname) const oss << "Failure removing file [" << pathname << "] with error [" << err.toString() << "]"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } } @@ -125,7 +125,7 @@ void sys::OSWin32::removeDirectory(const std::string& pathname) const oss << "Failure removing directory [" << pathname << "] with error [" << err.toString() << "]"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } } @@ -414,7 +414,7 @@ void sys::OSWin32::removeSymlink(const std::string& symlinkPathname) const oss << "Failure removing symlink [" << symlinkPathname << "] with error [" << err.toString() << "]"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } } diff --git a/externals/coda-oss/modules/c++/sys/source/Path.cpp b/externals/coda-oss/modules/c++/sys/source/Path.cpp index b775585af2..4c91e6d18f 100644 --- a/externals/coda-oss/modules/c++/sys/source/Path.cpp +++ b/externals/coda-oss/modules/c++/sys/source/Path.cpp @@ -279,7 +279,7 @@ std::vector Path::list(const std::string& path) std::ostringstream oss; oss << "'" << path << "' does not exist or is not a valid directory"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } std::vector listing; Directory directory; diff --git a/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp b/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp index e409b3b03f..07f67cfe42 100644 --- a/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/ScopedCPUAffinityUnix.cpp @@ -56,7 +56,7 @@ void ScopedCPUMaskUnix::initialize(int numCPUs) { std::ostringstream msg; msg << "Failed to allocate CPU mask for " << numCPUs << "CPUs"; - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } CPU_ZERO_S(mSize, mMask); @@ -122,7 +122,7 @@ ScopedCPUAffinityUnix::ScopedCPUAffinityUnix() : default: msg << " Unknown cause."; } - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } } } diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h b/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h index 4975bdaaa8..9120f581a5 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h @@ -155,8 +155,7 @@ class IFD : public io::Serializable const tiff::IFDEntry *mapEntry = tiff::KnownTagsRegistry::getInstance()[name]; //we can't add it if we don't know about it if (!mapEntry) - throw except::Exception(Ctxt(str::Format( - "Unable to add IFD Entry: unknown tag [%s]", name.c_str()))); + throw except::Exception(Ctxt(str::Format("Unable to add IFD Entry: unknown tag [%s]", name))); const auto id = mapEntry->getTagID(); const auto type = mapEntry->getType(); diff --git a/externals/coda-oss/modules/c++/tiff/source/IFD.cpp b/externals/coda-oss/modules/c++/tiff/source/IFD.cpp index bb9d80e7dc..09a5396a26 100644 --- a/externals/coda-oss/modules/c++/tiff/source/IFD.cpp +++ b/externals/coda-oss/modules/c++/tiff/source/IFD.cpp @@ -90,8 +90,7 @@ void tiff::IFD::addEntry(const std::string& name) tiff::IFDEntry *mapEntry = tiff::KnownTagsRegistry::getInstance()[name]; // we can't add it b/c we don't know about this tag if (!mapEntry) - throw except::Exception(Ctxt(str::Format( - "Unable to add IFD Entry: unknown tag [%s]", name.c_str()))); + throw except::Exception(Ctxt(str::Format("Unable to add IFD Entry: unknown tag [%s]", name))); unsigned short id = mapEntry->getTagID(); diff --git a/externals/coda-oss/modules/c++/xml.lite/source/Attributes.cpp b/externals/coda-oss/modules/c++/xml.lite/source/Attributes.cpp index 4032f86fc0..aff2572562 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/Attributes.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/Attributes.cpp @@ -125,8 +125,7 @@ std::string xml::lite::Attributes::getValue(const std::string& qname) const std::string retval; if (!getValue(qname, retval)) { - throw except::NoSuchKeyException(Ctxt(str::Format("QName '%s' could not be found", - qname.c_str()))); + throw except::NoSuchKeyException(Ctxt(str::Format("QName '%s' could not be found", qname))); } return retval; diff --git a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp index 0d5280881f..3950d12422 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp @@ -181,7 +181,7 @@ ValidatorXerces::ValidatorXerces( { std::ostringstream oss; oss << "Error: Failure to load schema " << schema; - log->warn(Ctxt(oss.str())); + log->warn(Ctxt(oss)); } } diff --git a/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp b/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp index c908b2a8c5..2b3b8206a7 100644 --- a/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp +++ b/externals/nitro/modules/c++/nitf/source/ByteProvider.cpp @@ -249,18 +249,16 @@ void ByteProvider::getFileLayout_(const nitf::Record& inRecord, { std::ostringstream ostr; ostr << "First image segment had " << mNumCols - << " columns but image segment " << ii << " has " - << numCols; - throw except::Exception(Ctxt(ostr.str())); + << " columns but image segment " << ii << " has " << numCols; + throw except::Exception(Ctxt(ostr)); } if (numBytesPerPixel != mNumBytesPerPixel) { std::ostringstream ostr; ostr << "First image segment had " << mNumBytesPerPixel - << " bytes/pxeil but image segment " << ii << " has " - << numBytesPerPixel; - throw except::Exception(Ctxt(ostr.str())); + << " bytes/pxeil but image segment " << ii << " has " << numBytesPerPixel; + throw except::Exception(Ctxt(ostr)); } } @@ -287,7 +285,7 @@ void ByteProvider::getFileLayout_(const nitf::Record& inRecord, std::ostringstream ostr; ostr << "Record has " << numDESs << " DESs but " << desData.size() << " DES data was sent in"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } std::vector desSubheaderLengths(numDESs); @@ -415,7 +413,7 @@ void ByteProvider::checkBlocking(size_t seg, ostr << "Trying to write starting at segment " << seg << "'s row " << segStartRowToWrite << " which is not a multiple of " << numRowsPerBlock; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } // Need to end on a block boundary or the end of the segment @@ -429,7 +427,7 @@ void ByteProvider::checkBlocking(size_t seg, << " which is not a multiple of " << numRowsPerBlock << " (segment has start = " << imageSegmentInfo.firstRow << ", num = " << imageSegmentInfo.numRows << ")"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } } } diff --git a/externals/nitro/modules/c++/nitf/source/CompressedByteProvider.cpp b/externals/nitro/modules/c++/nitf/source/CompressedByteProvider.cpp index bb15773b09..7cee92b71d 100644 --- a/externals/nitro/modules/c++/nitf/source/CompressedByteProvider.cpp +++ b/externals/nitro/modules/c++/nitf/source/CompressedByteProvider.cpp @@ -70,9 +70,8 @@ void CompressedByteProvider::initialize_(const Record& record, { std::ostringstream oss; oss << "NITF header metadata contains " << numImages << " images, " - << "but block sizes provided for " << bytesPerBlock.size() - << " images."; - throw except::Exception(Ctxt(oss.str())); + << "but block sizes provided for " << bytesPerBlock.size() << " images."; + throw except::Exception(Ctxt(oss)); } mImageDataLengths.resize(numImages); @@ -119,7 +118,7 @@ size_t CompressedByteProvider::countBytesForCompressedImageData( ostr << "Trying to get bytes from blocks [" << blockRange.mStartElement << ", " << blockRange.endElement() << ") but seg " << seg << " only has " << bytesPerBlock.size() << " blocks"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } size_t numBytes = 0; @@ -152,7 +151,7 @@ types::Range CompressedByteProvider::findBlocksToWrite( << (globalStartRow + numRowsToWrite) << ") from seg " << seg << " which contains global rows [" << segmentInfo.firstRow << ", " << segmentInfo.endRow() << ")"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } const size_t startRow = globalStartRow - segmentInfo.firstRow; @@ -192,7 +191,7 @@ static size_t addImageData_(const std::vector > mBytesInEach std::ostringstream error; error << "Internal logic error. blockRange.mStartElement should " << "never be 0 when fileOffset hasn't been set."; - throw except::Exception(Ctxt(error.str())); + throw except::Exception(Ctxt(error)); } fileOffset = mImageSubheaderFileOffsets[seg] + gsl::narrow(mImageSubheaders[seg].size()); diff --git a/externals/nitro/modules/c++/nitf/source/ImageBlocker.cpp b/externals/nitro/modules/c++/nitf/source/ImageBlocker.cpp index 52f8d3da0f..0c4a257053 100644 --- a/externals/nitro/modules/c++/nitf/source/ImageBlocker.cpp +++ b/externals/nitro/modules/c++/nitf/source/ImageBlocker.cpp @@ -147,7 +147,7 @@ void ImageBlocker::findSegment(size_t row, std::ostringstream ostr; ostr << "Row " << row << " is out of bounds"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } void ImageBlocker::findSegmentRange(size_t startRow, @@ -177,7 +177,7 @@ void ImageBlocker::findSegmentRange(size_t startRow, << startRowWithinFirstSeg << " within segment " << firstSegIdx << ". The local row must be a multiple of " << mNumRowsPerBlock[firstSegIdx] << "."; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } // Figure out which segment we're ending in @@ -196,7 +196,7 @@ void ImageBlocker::findSegmentRange(size_t startRow, ostr << "Last row " << lastRow << " is local row " << lastRowWithinLastSeg << " within segment " << lastSegIdx << ". This must land on a full block."; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } } } @@ -396,6 +396,6 @@ size_t ImageBlocker::getSegmentFromGlobalBlockRow(size_t blockRow) const std::ostringstream message; message << "Requested block row " << blockRow << ", but this image " << "only has " << startBlock << " rows of blocks."; - throw except::Exception(Ctxt(message.str())); + throw except::Exception(Ctxt(message)); } } diff --git a/externals/nitro/modules/c++/nitf/source/ImageSegmentComputer.cpp b/externals/nitro/modules/c++/nitf/source/ImageSegmentComputer.cpp index c862958627..7631befb71 100644 --- a/externals/nitro/modules/c++/nitf/source/ImageSegmentComputer.cpp +++ b/externals/nitro/modules/c++/nitf/source/ImageSegmentComputer.cpp @@ -105,18 +105,16 @@ ImageSegmentComputer::ImageSegmentComputer(size_t numRows, { std::ostringstream ostr; ostr << "Max rows was set to " << maxRows - << " but it cannot be greater than " << ILOC_MAX - << " per the NITF spec"; - throw except::Exception(Ctxt(ostr.str())); + << " but it cannot be greater than " << ILOC_MAX << " per the NITF spec"; + throw except::Exception(Ctxt(ostr)); } if (maxSize > NUM_BYTES_MAX) { std::ostringstream ostr; ostr << "Max image segment size was set to " << maxSize - << " but it cannot be greater than " << NUM_BYTES_MAX - << " per the NITF spec"; - throw except::Exception(Ctxt(ostr.str())); + << " but it cannot be greater than " << NUM_BYTES_MAX << " per the NITF spec"; + throw except::Exception(Ctxt(ostr)); } computeImageInfo(); @@ -152,9 +150,8 @@ void ImageSegmentComputer::computeImageInfo() { // This should not be possible std::ostringstream ostr; - ostr << "Image would require " << maxRowsUint64 - << " rows which is too many"; - throw except::Exception(Ctxt(ostr.str())); + ostr << "Image would require " << maxRowsUint64 << " rows which is too many"; + throw except::Exception(Ctxt(ostr)); } size_t maxRows(gsl::narrow(maxRowsUint64)); @@ -163,7 +160,7 @@ void ImageSegmentComputer::computeImageInfo() std::ostringstream ostr; ostr << "maxNumBytesPerSegment [" << mMaxNumBytesPerSegment << "] < bytesPerRow [" << bytesPerRow << "]"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } // Truncate back to a full block for the maxRows that will actually fit @@ -180,7 +177,7 @@ void ImageSegmentComputer::computeImageInfo() << ", bytes per row of " << bytesPerRow << ", and rows per block of " << mNumRowsPerBlock << ", cannot fit an entire block into a segment"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } } diff --git a/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp b/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp index 98648338e3..b5e9f4392e 100644 --- a/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp +++ b/externals/nitro/modules/c++/nitf/source/J2KCompressor.cpp @@ -338,10 +338,10 @@ class TileWriter final mEncoder.clearError(); os << " with openjpeg error: " << opjErrorMsg; - throw except::Exception(Ctxt(os.str())); + throw except::Exception(Ctxt(os)); } - throw except::Exception(Ctxt(os.str())); + throw except::Exception(Ctxt(os)); } } @@ -560,7 +560,7 @@ std::span j2k::Compressor::compressRowSubrange( { std::ostringstream ostr; ostr << "Global start row = " << globalStartRow << " must be a multiple of number of rows in tile = " << numRowsInTile; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } if ((numLocalRows % numRowsInTile != 0) && @@ -568,7 +568,7 @@ std::span j2k::Compressor::compressRowSubrange( { std::ostringstream ostr; ostr << "Number of local rows = " << numLocalRows << " must be a multiple of number of rows in tile = " << numRowsInTile; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } const auto startRowOfTiles = globalStartRow / numRowsInTile; @@ -600,7 +600,7 @@ std::span j2k::Compressor::compressTileSubrange( std::ostringstream ostr; ostr << "Require " << numBytesNeeded << " bytes for compression of " << numTiles << " tiles but only received " << compressedData.size() << " bytes"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } auto compressedPtr = compressedData.data(); @@ -649,7 +649,7 @@ std::span j2k::Compressor::compressTileSubrange( std::ostringstream os; os << "Cannot write " << numBytesThisTile << " bytes for tile " << tileNum << " at byte offset " << numBytesWritten << " - exceeds maximum compressed image size (" << compressedData.size() << " bytes)!"; - throw except::Exception(Ctxt(os.str())); + throw except::Exception(Ctxt(os)); } const auto src = tileStream.get(); diff --git a/externals/nitro/modules/c++/nitf/source/J2KEncoder.cpp b/externals/nitro/modules/c++/nitf/source/J2KEncoder.cpp index b005bb4377..cddbada264 100644 --- a/externals/nitro/modules/c++/nitf/source/J2KEncoder.cpp +++ b/externals/nitro/modules/c++/nitf/source/J2KEncoder.cpp @@ -89,7 +89,7 @@ j2k::Encoder::Encoder(Image& image, const CompressionParameters& compressionPara std::ostringstream os; os << "Failed to setup openjpeg encoder with openjpeg error: " << opjErrorMsg; - throw except::Exception(Ctxt(os.str())); + throw except::Exception(Ctxt(os)); } throw except::Exception(Ctxt("Failed to setup openjpeg encoder.")); diff --git a/externals/nitro/modules/c++/nitf/source/J2KImage.cpp b/externals/nitro/modules/c++/nitf/source/J2KImage.cpp index 9d536c2178..6ec248ed3c 100644 --- a/externals/nitro/modules/c++/nitf/source/J2KImage.cpp +++ b/externals/nitro/modules/c++/nitf/source/J2KImage.cpp @@ -40,7 +40,7 @@ j2k::Image::Image(const types::RowCol& rawImageDims) std::ostringstream os; os << "Failed to create an openjpeg image handle using the provided raw image dimensions"; os << " (rows: "<< rawImageDims.row << ", cols : " << rawImageDims.col << ")!"; - throw except::Exception(Ctxt(os.str())); + throw except::Exception(Ctxt(os)); } // set up the image diff --git a/externals/nitro/modules/c++/nitf/source/J2KStream.cpp b/externals/nitro/modules/c++/nitf/source/J2KStream.cpp index 7bbd465ae7..49335d5cf7 100644 --- a/externals/nitro/modules/c++/nitf/source/J2KStream.cpp +++ b/externals/nitro/modules/c++/nitf/source/J2KStream.cpp @@ -37,7 +37,7 @@ j2k::Stream::Stream(j2k::StreamType streamType, size_t chunkSize) { std::ostringstream os; os << "Failed creating an openjpeg stream with a chunk size of " << chunkSize << " bytes."; - throw except::Exception(Ctxt(os.str())); + throw except::Exception(Ctxt(os)); } } diff --git a/externals/nitro/modules/c++/nitf/source/NITFBufferList.cpp b/externals/nitro/modules/c++/nitf/source/NITFBufferList.cpp index c9db90cd1c..fd2339ae46 100644 --- a/externals/nitro/modules/c++/nitf/source/NITFBufferList.cpp +++ b/externals/nitro/modules/c++/nitf/source/NITFBufferList.cpp @@ -67,7 +67,7 @@ size_t NITFBufferList::getNumBytesInBlock( std::ostringstream ostr; ostr << "Block index " << blockIdx << " is out of bounds - only " << numBlocks << " blocks with a block size of " << blockSize; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } const size_t numBytes = (blockIdx == numBlocks - 1) ? diff --git a/externals/nitro/modules/c++/nitf/source/TRE.cpp b/externals/nitro/modules/c++/nitf/source/TRE.cpp index 97f697bb96..dd109d407d 100644 --- a/externals/nitro/modules/c++/nitf/source/TRE.cpp +++ b/externals/nitro/modules/c++/nitf/source/TRE.cpp @@ -219,7 +219,7 @@ nitf_Field& TRE::nitf_TRE_getField(const std::string& tag) const { std::ostringstream msg; msg << tag << " is not a recognized field for this TRE"; - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } return *field; }