From a6083afc6cc8a8686a1ced16dad8bb8159835488 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Tue, 10 Oct 2023 09:56:48 -0400 Subject: [PATCH] Squashed 'externals/nitro/' changes from ff335eeaf..cca11bf4c cca11bf4c Merge commit 'b40d3f96fff13bf708f319c684348ebd9884aff1' into cpp17 b40d3f96f Squashed 'externals/coda-oss/' changes from b6ead418cf..434b85fe53 2d6d5aa31 Merge branch 'main' into cpp17 1b631e578 latest from CODA-OSS (#587) d32176660 Merge branch 'main' into cpp17 574bfe2b6 FmtX() -> str::Format() (#586) a8e6556aa Squashed 'externals/coda-oss/' changes from 07bcb3a39b..b6ead418cf 53596f720 Merge commit 'a8e6556aa7bc5c105d3b4383589da7ef48982deb' into cpp17 29ccecf64 latest from CODA-OSS b315d9b6c Merge branch 'main' into cpp17 edfa0f7ce latest from CODA-OSS (#585) b708bd8ea `final` for NITFException a2af78776 don't need FmtX() with no formatting 368cead55 Squashed 'externals/coda-oss/' changes from 70a006d8a4..07bcb3a39b 9b10c5340 Merge commit '368cead55f182d12953a6964b2598021f9629cf3' into cpp17 6e40d15b4 latest from CODA-OSS 31fc61888 develop/sync_externals git-subtree-dir: externals/nitro git-subtree-split: cca11bf4c8a99e779c2a7158e2fc214d3b097337 --- .gitattributes | 11 ++ externals/coda-oss/.gitattributes | 11 ++ externals/coda-oss/build/scripts/makeEnums.py | 6 +- .../modules/c++/cli/include/cli/Results.h | 70 +++++---- .../modules/c++/cli/include/cli/Value.h | 27 +--- .../modules/c++/cli/source/Argument.cpp | 2 +- .../modules/c++/cli/source/ArgumentParser.cpp | 77 ++++++---- .../modules/c++/cli/unittests/test_cli.cpp | 7 +- .../modules/c++/dbi/tests/SQLTest1.cpp | 2 +- .../modules/c++/dbi/tests/SQLTest2.cpp | 2 +- .../modules/c++/except/include/except/Error.h | 50 +------ .../c++/except/include/except/Exception.h | 51 +------ .../c++/except/include/except/Throwable.h | 96 +++--------- .../modules/c++/except/source/Throwable.cpp | 16 +- .../c++/io/source/FileInputStreamIOS.cpp | 2 +- .../modules/c++/io/source/FileUtils.cpp | 2 +- .../modules/c++/io/source/MMapInputStream.cpp | 2 +- .../modules/c++/io/source/StandardStreams.cpp | 4 +- .../coda-oss/modules/c++/io/tests/ioTest1.cpp | 2 +- .../coda-oss/modules/c++/io/tests/ioTest3.cpp | 2 +- .../coda-oss/modules/c++/io/tests/ioTest4.cpp | 2 +- .../modules/c++/io/tests/serializeTest1.cpp | 12 +- .../c++/logging/include/logging/Enums.h | 6 +- .../c++/math.poly/include/math/poly/Fixed1D.h | 4 +- .../modules/c++/mt/tests/MTSingletonTest.cpp | 2 +- .../c++/net.ssl/source/SSLConnection.cpp | 10 +- .../source/SSLConnectionClientFactory.cpp | 4 +- .../c++/net.ssl/tests/SSLTestClient.cpp | 2 +- .../c++/net.ssl/tests/SSLTestClientNoURL.cpp | 2 +- .../modules/c++/net/source/DaemonUnix.cpp | 4 +- .../modules/c++/net/source/Socket.cpp | 2 +- .../c++/net/tests/NetConnectionClientTest.cpp | 2 +- .../c++/net/tests/NetConnectionServerTest.cpp | 2 +- .../c++/net/tests/SerializableTestClient.cpp | 2 +- .../modules/c++/net/tests/URLTest.cpp | 2 +- .../include/plugin/BasicPluginManager.h | 6 +- .../sio.lite/include/sio/lite/SioFileWriter.h | 2 +- .../modules/c++/str/include/str/Format.h | 141 +++++++++--------- .../modules/c++/str/tests/VersionTest.cpp | 2 +- .../c++/sys/include/sys/ThreadInterface.h | 2 +- .../modules/c++/sys/source/DLLWin32.cpp | 4 +- .../modules/c++/sys/source/FileUnix.cpp | 2 +- .../modules/c++/sys/source/FileWin32.cpp | 4 +- .../modules/c++/sys/source/OSUnix.cpp | 4 +- .../modules/c++/sys/source/OSWin32.cpp | 2 +- .../coda-oss/modules/c++/sys/tests/OSTest.cpp | 2 +- .../modules/c++/tiff/include/tiff/IFD.h | 2 +- .../c++/tiff/include/tiff/TiffFileWriter.h | 2 +- .../coda-oss/modules/c++/tiff/source/IFD.cpp | 2 +- .../modules/c++/tiff/source/ImageReader.cpp | 2 +- .../c++/tiff/source/TiffFileReader.cpp | 4 +- .../modules/c++/tiff/tests/DumpHeader.cpp | 4 +- .../c++/xml.lite/source/Attributes.cpp | 6 +- .../c++/xml.lite/tests/AttributeValueTest.cpp | 2 +- .../c++/xml.lite/tests/MinidomParserTest1.cpp | 2 +- .../c++/xml.lite/tests/MinidomParserTest2.cpp | 4 +- .../c++/xml.lite/tests/XMLReaderTest.cpp | 2 +- .../modules/c++/zip/source/ZipEntry.cpp | 4 +- .../c++/nitf/include/nitf/NITFException.hpp | 8 +- modules/c++/nitf/include/nitf/Object.hpp | 2 +- modules/c++/nitf/source/FileHeader.cpp | 12 +- modules/c++/nitf/source/ImageSubheader.cpp | 2 +- modules/c++/nitf/source/TRE.cpp | 2 +- modules/c++/nitf/tests/test_create++.cpp | 2 +- modules/c++/nitf/tests/test_extract.cpp | 6 +- modules/c++/nitf/tests/test_fhdr_clone++.cpp | 2 +- modules/c++/nitf/tests/test_functional.cpp | 2 +- .../nitf/tests/test_j2k_nitf_read_region.cpp | 10 +- modules/c++/nitf/tests/test_read_acftb.cpp | 2 +- .../c++/nitf/unittests/test_j2k_loading++.cpp | 10 +- 70 files changed, 325 insertions(+), 442 deletions(-) diff --git a/.gitattributes b/.gitattributes index 6e07f483bd..803f17ffe9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -18,10 +18,12 @@ CMakeLists.txt text eol=lf # Text file formats *.txt text eol=lf +*.text text eol=lf *.md text eol=lf *.tex text eol=lf *.?ml text eol=lf *.kmz binary +*.log text eol=lf # Programming languages *.htm? text eol=lf @@ -54,12 +56,21 @@ CMakeLists.txt text eol=lf ###################### # Known binary files +# executables, libraries; yes, sometimes they're part of a repository +*.exe binary +*.out binary +lib*.so* binary +*.dll binary +lib*.a* binary +*.lib binary + # from various unit_test/ directories *.dat binary *.*hdr binary *.flat binary *.sig binary *.bin binary +*.dump binary # images *.bmp binary diff --git a/externals/coda-oss/.gitattributes b/externals/coda-oss/.gitattributes index 6e07f483bd..803f17ffe9 100644 --- a/externals/coda-oss/.gitattributes +++ b/externals/coda-oss/.gitattributes @@ -18,10 +18,12 @@ CMakeLists.txt text eol=lf # Text file formats *.txt text eol=lf +*.text text eol=lf *.md text eol=lf *.tex text eol=lf *.?ml text eol=lf *.kmz binary +*.log text eol=lf # Programming languages *.htm? text eol=lf @@ -54,12 +56,21 @@ CMakeLists.txt text eol=lf ###################### # Known binary files +# executables, libraries; yes, sometimes they're part of a repository +*.exe binary +*.out binary +lib*.so* binary +*.dll binary +lib*.a* binary +*.lib binary + # from various unit_test/ directories *.dat binary *.*hdr binary *.flat binary *.sig binary *.bin binary +*.dump binary # images *.bmp binary diff --git a/externals/coda-oss/build/scripts/makeEnums.py b/externals/coda-oss/build/scripts/makeEnums.py index 911a7fefee..6e909511c3 100755 --- a/externals/coda-oss/build/scripts/makeEnums.py +++ b/externals/coda-oss/build/scripts/makeEnums.py @@ -110,7 +110,7 @@ def cmpValues(x, y): s.write(' %sif (s == "%s")\n value = %s%s;\n' % (i > 0 and 'else ' or '', n, values.cleanPrefix, item.names[0].replace(' ', '_'))) i += 1 - s.write(' else\n throw except::InvalidFormatException(Ctxt(FmtX("Invalid enum value: %s", s.c_str())));\n') + s.write(' else\n throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %s", s.c_str())));\n') s.write(' }\n\n') s.write(' //! int constructor\n') @@ -123,7 +123,7 @@ def cmpValues(x, y): try: idx += 1 except:{} - s.write(' default:\n throw except::InvalidFormatException(Ctxt(FmtX("Invalid enum value: %d", i)));\n') + s.write(' default:\n throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %d", i)));\n') s.write(' }\n }\n\n') s.write(' //! destructor\n') @@ -142,7 +142,7 @@ def cmpValues(x, y): try: idx += 1 except:{} - s.write(' default:\n throw except::InvalidFormatException(Ctxt(FmtX("Invalid enum value: %d", value)));\n') + s.write(' default:\n throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %d", value)));\n') s.write(' }\n }\n\n') s.write(' //! assignment operator\n') diff --git a/externals/coda-oss/modules/c++/cli/include/cli/Results.h b/externals/coda-oss/modules/c++/cli/include/cli/Results.h index 1a74cc7aab..bd293cf695 100644 --- a/externals/coda-oss/modules/c++/cli/include/cli/Results.h +++ b/externals/coda-oss/modules/c++/cli/include/cli/Results.h @@ -25,6 +25,9 @@ #define CODA_OSS_cli_Results_h_INCLUDED_ #include +#include +#include +#include #include "sys/Conf.h" @@ -33,10 +36,9 @@ namespace cli { -class Results +class Results final { -protected: - typedef std::map ValueStorage_T; + typedef std::map> ValueStorage_T; typedef ValueStorage_T::iterator ValueIter_T; typedef ValueStorage_T::const_iterator ConstValueIter_T; typedef std::map ResultsStorage_T; @@ -44,13 +46,15 @@ class Results typedef ResultsStorage_T::const_iterator ConstResultsIter_T; public: - Results() - { - } + Results() = default; ~Results() { destroy(); } + Results(const Results&) = delete; + Results& operator=(const Results&) = delete; + Results(Results&&) = default; + Results& operator=(Results&&) = default; bool hasValue(const std::string& key) const { @@ -62,20 +66,30 @@ class Results return mResults.find(key) != mResults.end(); } - cli::Value* operator[](const std::string& key) const + const cli::Value* operator[](const std::string& key) const { return getValue(key); } - cli::Value* getValue(const std::string& key) const + const cli::Value* getValue(const std::string& key) const { - ConstValueIter_T p = mValues.find(key); + auto const p = mValues.find(key); if (p == mValues.end()) { const std::string errorMessage = "No argument named " + key; throw except::NoSuchKeyException(Ctxt(errorMessage)); } - return p->second; + return p->second.get(); + } + cli::Value* getValue(const std::string& key) + { + auto const p = mValues.find(key); + if (p == mValues.end()) + { + const std::string errorMessage = "No argument named " + key; + throw except::NoSuchKeyException(Ctxt(errorMessage)); + } + return p->second.get(); } template @@ -100,15 +114,22 @@ class Results return p->second; } - void put(const std::string& key, cli::Value *value) + void put(const std::string& key, std::unique_ptr value) + { + if (hasValue(key) && (getValue(key) == value.get())) + { + return; + } + mValues[key] = std::move(value); + } + void put(const std::string& key, cli::Value* value) { - if (hasValue(key)) + cli::Value* pExistingValue = hasValue(key) ? getValue(key) : nullptr; + if ((pExistingValue == nullptr) || (pExistingValue != value)) { - cli::Value* existing = getValue(key); - if (existing != value) - delete getValue(key); + // Either 1) we didn't already have a value or 2) the existing value is different + put(key, std::unique_ptr(value)); } - mValues[key] = value; } void put(const std::string& key, cli::Results *args) @@ -122,26 +143,21 @@ class Results mResults[key] = args; } - typedef ValueStorage_T::iterator iterator; - typedef ValueStorage_T::const_iterator const_iterator; + auto begin() { return mValues.begin(); } + auto begin() const { return mValues.begin(); } + auto end() { return mValues.end(); } + auto end() const { return mValues.end(); } - iterator begin() { return mValues.begin(); } - const_iterator begin() const { return mValues.begin(); } - iterator end() { return mValues.end(); } - const_iterator end() const { return mValues.end(); } - -protected: +private: ValueStorage_T mValues; ResultsStorage_T mResults; void destroy() { - for (ValueIter_T it = mValues.begin(), end = mValues.end(); it != end; ++it) - delete it->second; + mValues.clear(); for (ResultsIter_T it = mResults.begin(), end = mResults.end(); it != end; ++it) delete it->second; - mValues.clear(); mResults.clear(); } }; diff --git a/externals/coda-oss/modules/c++/cli/include/cli/Value.h b/externals/coda-oss/modules/c++/cli/include/cli/Value.h index 571565cab5..49f1125ebd 100644 --- a/externals/coda-oss/modules/c++/cli/include/cli/Value.h +++ b/externals/coda-oss/modules/c++/cli/include/cli/Value.h @@ -26,6 +26,7 @@ #include #include +#include #include #include "sys/Conf.h" @@ -38,12 +39,9 @@ namespace cli * The Value class provides access to one or more actual values. * It provides index-based access to parameters. */ -class CODA_OSS_API Value +struct CODA_OSS_API Value final { -public: - Value() - { - } + Value() = default; template explicit Value(std::vector value) @@ -57,12 +55,6 @@ class CODA_OSS_API Value set(value); } - template - Value(T* value, size_t size, bool own = false) - { - set(value, size, own); - } - ~Value() { cleanup(); @@ -75,17 +67,6 @@ class CODA_OSS_API Value mValues.push_back(str::toString(value)); } - template - void set(T* value, size_t size, bool own = false) - { - cleanup(); - mValues.reserve(size); - for (size_t i = 0; i < size; ++i) - add(value[i]); - if (own) - delete[] value; - } - template void setContainer(const std::vector& c) { @@ -106,7 +87,7 @@ class CODA_OSS_API Value { if (index >= mValues.size()) throw except::IndexOutOfRangeException( - Ctxt(FmtX("Invalid index: %d", index))); + Ctxt(str::Format("Invalid index: %d", index))); return str::toType(mValues[index]); } diff --git a/externals/coda-oss/modules/c++/cli/source/Argument.cpp b/externals/coda-oss/modules/c++/cli/source/Argument.cpp index 01b2563233..8b924f30a7 100644 --- a/externals/coda-oss/modules/c++/cli/source/Argument.cpp +++ b/externals/coda-oss/modules/c++/cli/source/Argument.cpp @@ -54,7 +54,7 @@ cli::Argument::~Argument() cli::Argument* cli::Argument::addFlag(const std::string& flag) { char p = mParser->mPrefixChar; - std::string p2 = FmtX("%c%c", p, p); + std::string p2 = str::Format("%c%c", p, p); if (flag.size() > 2 && str::startsWith(flag, p2) && flag[2] != p) mLongFlags.push_back(validateFlag(flag.substr(2))); else if (flag.size() > 1 && flag[0] == p && flag[1] != p) diff --git a/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp b/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp index e7763e4aae..367ff9edce 100644 --- a/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp +++ b/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp @@ -28,10 +28,11 @@ #include #include +#include namespace { -static const size_t MAX_ARG_LINE_LENGTH = 21; +constexpr size_t MAX_ARG_LINE_LENGTH = 21; bool containsOnly(const std::string& str, const std::map& flags) @@ -284,6 +285,20 @@ cli::Results* cli::ArgumentParser::parse(const std::vector& args) return parse("cli::ArgumentParser::parse" /*program*/, args).release(); // provide a "meaningful" default program name } } + +static auto put(cli::Results& currentResults, const std::string& argVar, + cli::Value* v, std::unique_ptr&& v_) +{ + if (v == v_.get()) // no existing value, using the newly created std::unique_ptr + { + currentResults.put(argVar, std::move(v_)); + } + else + { + currentResults.put(argVar, v); // already had a value, just update + } +} + std::unique_ptr cli::ArgumentParser::parse(const std::string& program, const std::vector& args) { if (!program.empty()) @@ -318,7 +333,7 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog std::map& flagMap = (subOption ? shortOptionsFlags : shortFlags); if (flagMap.find(op) != flagMap.end()) - parseError(FmtX("Conflicting option: %c%s", mPrefixChar, op)); + parseError(str::Format("Conflicting option: %c%s", mPrefixChar, op)); flagMap[op] = arg; } for (std::vector::const_iterator it = @@ -328,7 +343,7 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog std::map& flagMap = (subOption ? longOptionsFlags : longFlags); if (flagMap.find(op) != flagMap.end()) - parseError(FmtX("Conflicting option: %c%c%s", mPrefixChar, mPrefixChar, op)); + parseError(str::Format("Conflicting option: %c%c%s", mPrefixChar, mPrefixChar, op)); flagMap[op] = arg; } } @@ -457,7 +472,7 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog } else { - throw except::Exception(Ctxt(FmtX("Invalid option: [%s]", argStr))); + throw except::Exception(Ctxt(str::Format("Invalid option: [%s]", argStr))); } } } @@ -498,7 +513,7 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog } else { - throw except::Exception(Ctxt(FmtX("Invalid option: [%s]", argStr))); + throw except::Exception(Ctxt(str::Format("Invalid option: [%s]", argStr))); } } @@ -513,9 +528,8 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog { case cli::STORE: { - cli::Value* v = currentResults->hasValue(argVar) - ? currentResults->getValue(argVar) - : new cli::Value; + auto v_ = std::make_unique(); + auto v = currentResults->hasValue(argVar) ? currentResults->getValue(argVar) : v_.get(); int maxArgs = arg->getMaxArgs(); // risky, I know... bool added = false; @@ -545,16 +559,16 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog } if (!added) - parseError(FmtX("option requires value or has exceeded its max: [%s]", argVar)); + parseError(str::Format("option requires value or has exceeded its max: [%s]", argVar)); - currentResults->put(argVar, v); + put(*currentResults, argVar, v, std::move(v_)); break; } case cli::STORE_TRUE: - currentResults->put(argVar, new cli::Value(true)); + currentResults->put(argVar, std::make_unique(true)); break; case cli::STORE_FALSE: - currentResults->put(argVar, new cli::Value(false)); + currentResults->put(argVar, std::make_unique(false)); break; case cli::STORE_CONST: { @@ -565,10 +579,10 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog case cli::SUB_OPTIONS: { if (optionsStr.empty()) - parseError(FmtX("invalid sub option: [%s]", argVar.c_str())); - cli::Value* v = currentResults->hasValue(optionsStr) - ? currentResults->getValue(optionsStr) - : new cli::Value; + parseError(str::Format("invalid sub option: [%s]", argVar.c_str())); + + auto v_ = std::make_unique(); + auto v = currentResults->hasValue(optionsStr) ? currentResults->getValue(optionsStr) : v_.get(); if (i < s - 1) { std::string nextArg = explodedArgs[i + 1]; @@ -589,7 +603,7 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog // this indicates the sub op is a bool v->add(true); } - currentResults->put(optionsStr, v); + put(*currentResults, optionsStr, v, std::move(v_)); break; } case cli::VERSION: @@ -601,24 +615,22 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog { // it's a positional argument cli::Value* lastPosVal = nullptr; - for (std::vector::iterator it = - positionalArgs.begin(); it != positionalArgs.end(); ++it) + for (auto&& posArg : positionalArgs) { - cli::Argument *posArg = *it; std::string argVar = posArg->getVariable(); int maxArgs = posArg->getMaxArgs(); if (currentResults->hasValue(argVar)) { - cli::Value *posVal = lastPosVal - = currentResults->getValue(argVar); - if (static_cast(posVal->size()) >= maxArgs) + lastPosVal = currentResults->getValue(argVar); + if (gsl::narrow(lastPosVal->size()) >= maxArgs) continue; break; } else if (maxArgs != 0) { - lastPosVal = new cli::Value; - currentResults->put(argVar, lastPosVal); + auto lastPosVal_ = std::make_unique(); + lastPosVal = lastPosVal_.get(); + currentResults->put(argVar, std::move(lastPosVal_)); break; } } @@ -651,12 +663,11 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog if (defaultVal != nullptr) results->put(argVar, defaultVal->clone()); else if (arg->getAction() == cli::STORE_FALSE) - results->put(argVar, new cli::Value(true)); + results->put(argVar, std::make_unique(true)); else if (arg->getAction() == cli::STORE_TRUE) - results->put(argVar, new cli::Value(false)); + results->put(argVar, std::make_unique(false)); else if (arg->isRequired()) - parseError(FmtX("missing required argument: [%s]", - argVar.c_str())); + parseError(str::Format("missing required argument: [%s]", argVar)); } @@ -670,9 +681,9 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog if (arg->isRequired() || numGiven > 0) { if (minArgs > 0 && numGiven < static_cast(minArgs)) - parseError(FmtX("not enough arguments, %d required: [%s]", minArgs, argId)); + parseError(str::Format("not enough arguments, %d required: [%s]", minArgs, argId)); if (maxArgs >= 0 && numGiven > static_cast(maxArgs)) - parseError(FmtX("too many arguments, %d supported: [%s]", maxArgs, argId)); + parseError(str::Format("too many arguments, %d supported: [%s]", maxArgs, argId)); } @@ -682,7 +693,7 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog if (numGiven > 0 && !choices.empty()) { bool isValid = false; - cli::Value *vals = results->getValue(argVar); + auto vals = results->getValue(argVar); for (size_t ii = 0; ii < numGiven; ++ii) { @@ -695,7 +706,7 @@ std::unique_ptr cli::ArgumentParser::parse(const std::string& prog } if (!isValid) { - parseError(FmtX("invalid option for [%s]", argVar.c_str())); + parseError(str::Format("invalid option for [%s]", argVar.c_str())); } } } diff --git a/externals/coda-oss/modules/c++/cli/unittests/test_cli.cpp b/externals/coda-oss/modules/c++/cli/unittests/test_cli.cpp index ade63b34ac..d8d1578ff9 100644 --- a/externals/coda-oss/modules/c++/cli/unittests/test_cli.cpp +++ b/externals/coda-oss/modules/c++/cli/unittests/test_cli.cpp @@ -160,7 +160,7 @@ TEST_CASE(testIterate) std::unique_ptr results(parser.parse(str::split("-v -c config.xml"))); std::vector keys; - for(cli::Results::const_iterator it = results->begin(); it != results->end(); ++it) + for(auto it = results->begin(); it != results->end(); ++it) keys.push_back(it->first); TEST_ASSERT_EQ(std::ssize(keys), 2); // std::map returns keys in alphabetical order... @@ -186,14 +186,9 @@ TEST_CASE(testRequiredThrows) parser.addArgument("-c --config", "Specify a config file", cli::STORE) ->setRequired(true); - // The exceptions leak memory which causes an ASAN diagnostic on Linux. - #if CODA_OSS_POSIX_SOURCE && __SANITIZE_ADDRESS__ - TEST_SUCCESS; - #else const std::string program(testName); TEST_EXCEPTION(parser.parse(program, str::split(""))); TEST_EXCEPTION(parser.parse(program, str::split("-c"))); - #endif } TEST_CASE(testUnknownArgumentsOptions) diff --git a/externals/coda-oss/modules/c++/dbi/tests/SQLTest1.cpp b/externals/coda-oss/modules/c++/dbi/tests/SQLTest1.cpp index dbca6e5e83..ad1b0eb8d7 100644 --- a/externals/coda-oss/modules/c++/dbi/tests/SQLTest1.cpp +++ b/externals/coda-oss/modules/c++/dbi/tests/SQLTest1.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { try { - if (argc < 4) throw except::Exception(Ctxt(FmtX("Usage %s [host] [port]", argv[0]))); + if (argc < 4) throw except::Exception(Ctxt(str::Format("Usage %s [host] [port]", argv[0]))); std::string database(argv[1]); std::string user(argv[2]); diff --git a/externals/coda-oss/modules/c++/dbi/tests/SQLTest2.cpp b/externals/coda-oss/modules/c++/dbi/tests/SQLTest2.cpp index 843a4d2780..c1bc60f2d7 100644 --- a/externals/coda-oss/modules/c++/dbi/tests/SQLTest2.cpp +++ b/externals/coda-oss/modules/c++/dbi/tests/SQLTest2.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { try { - if (argc != 6) throw except::Exception(Ctxt(FmtX("Usage %s ", argv[0]))); + if (argc != 6) throw except::Exception(Ctxt(str::Format("Usage %s ", argv[0]))); std::string database(argv[1]); std::string host(argv[4]); diff --git a/externals/coda-oss/modules/c++/except/include/except/Error.h b/externals/coda-oss/modules/c++/except/include/except/Error.h index 56fcdb78ca..02e50fa8bd 100644 --- a/externals/coda-oss/modules/c++/except/include/except/Error.h +++ b/externals/coda-oss/modules/c++/except/include/except/Error.h @@ -44,16 +44,12 @@ _Name##Error_(const except::Context& c) : _Base(c){} \ _Name##Error_(const std::string& msg) : _Base(msg){} \ _Name##Error_(const except::Throwable& t, const except::Context& c) : _Base(t, c){} \ - _Name##Error_(const except::ThrowableEx& t, const except::Context& c) : _Base(t, c){} \ std::string getType() const noexcept override { return #_Name; } \ } #define DECLARE_EXTENDED_ERROR(_Name, _Base) DECLARE_EXTENDED_ERROR_(_Name, Error, _Base) -#define DECLARE_EXTENDED_ERROREX(_Name, _Base) DECLARE_EXTENDED_ERROR_(_Name, ErrorEx, _Base) // Need to keep this around for existing code -#define DECLARE_ERROR(_Name) \ - DECLARE_EXTENDED_ERROR(_Name, except::Error); \ - DECLARE_EXTENDED_ERROREX(_Name, except::ErrorEx) +#define DECLARE_ERROR(_Name) DECLARE_EXTENDED_ERROR(_Name, except::Error) namespace except { @@ -98,9 +94,6 @@ struct Error : public Throwable Throwable(t, c) { } - Error(const ThrowableEx& t, const Context& c) : Throwable(t, c) - { - } std::string getType() const override { @@ -110,46 +103,9 @@ struct Error : public Throwable // Use this in new code: name is FooErrror (not FooErrorEx), base is except::ErrorEx (not except::Error). #define CODA_OSS_DECLARE_EXTENDED_ERROR(name_, base_) DECLARE_EXTENDED_ERROR_(name_, Error, base_) -#define CODA_OSS_DECLARE_ERROR(name_) CODA_OSS_DECLARE_EXTENDED_ERROR(name_, except::ErrorEx) - -struct ErrorEx : public ThrowableEx -{ - ErrorEx() = default; - virtual ~ErrorEx() = default; - - /*! - * Constructor. Takes a Context - * \param c The Context - */ - ErrorEx(const Context& c) : ThrowableEx(c) - { - } +#define CODA_OSS_DECLARE_ERROR(name_) CODA_OSS_DECLARE_EXTENDED_ERROR(name_, except::Error) - /*! - * Constructor. Takes a message - * \param message The message - */ - ErrorEx(const std::string& message) : ThrowableEx(message) - { - } - - /*! - * Constructor. Takes an Throwable and a Context - * \param t The Throwable - * \param c The Context - */ - ErrorEx(const ThrowableEx& t, const Context& c) : ThrowableEx(t, c) - { - } - ErrorEx(const Throwable& t, const Context& c) : ThrowableEx(t, c) - { - } - - std::string getType() const noexcept override - { - return "ErrorEx"; - } -}; +using ErrorEx = Error; using Error11 = ErrorEx; // keep old name around for other projects /*! diff --git a/externals/coda-oss/modules/c++/except/include/except/Exception.h b/externals/coda-oss/modules/c++/except/include/except/Exception.h index 33a8563632..95ddad022d 100644 --- a/externals/coda-oss/modules/c++/except/include/except/Exception.h +++ b/externals/coda-oss/modules/c++/except/include/except/Exception.h @@ -60,17 +60,14 @@ _Name##Exception_(const except::Context& c) : _Base(c){} \ _Name##Exception_(const std::string& msg) : _Base(msg){} \ _Name##Exception_(const except::Throwable& t, const except::Context& c) : _Base(t, c){} \ - _Name##Exception_(const except::ThrowableEx& t, const except::Context& c) : _Base(t, c){} \ CODA_OSS_except_Exception_suppress_26447_BEGIN_ \ std::string getType() const noexcept override { return #_Name #Exception_; } \ CODA_OSS_except_Exception_suppress_26447_END_ } #define DECLARE_EXTENDED_EXCEPTION(_Name, _Base) DECLARE_EXTENDED_EXCEPTION_(_Name, Exception, _Base) -#define DECLARE_EXTENDED_EXCEPTIONEX(_Name, _Base) DECLARE_EXTENDED_EXCEPTION_(_Name, ExceptionEx, _Base) // Need to keep this around for existing code -#define DECLARE_EXCEPTION(_Name) \ - DECLARE_EXTENDED_EXCEPTION(_Name, except::Exception); \ - DECLARE_EXTENDED_EXCEPTIONEX(_Name, except::ExceptionEx) +#define DECLARE_EXCEPTION(_Name) DECLARE_EXTENDED_EXCEPTION(_Name, except::Exception); \ + using _Name ## ExceptionEx = _Name ##Exception namespace except { @@ -104,9 +101,6 @@ struct Exception : public Throwable Throwable(t, c) { } - Exception(const ThrowableEx& t, const Context& c) : Throwable(t, c) - { - } /*! * Constructor. Takes a message @@ -126,46 +120,9 @@ struct Exception : public Throwable // Use this in new code: name is FooException (not FooExceptionEx), base is except::ExceptionEx (not except::Exception). #define CODA_OSS_DECLARE_EXTENDED_EXCEPTION(name_, base_) DECLARE_EXTENDED_EXCEPTION_(name_, Exception, base_) -#define CODA_OSS_DECLARE_EXCEPTION(name_) CODA_OSS_DECLARE_EXTENDED_EXCEPTION(name_, except::ExceptionEx) - -struct ExceptionEx : public ThrowableEx -{ - ExceptionEx() = default; - virtual ~ExceptionEx() = default; - - /*! - * Constructor. Takes a Context - * \param c The Context - */ - ExceptionEx(const Context& c) : ThrowableEx(c) - { - } +#define CODA_OSS_DECLARE_EXCEPTION(name_) CODA_OSS_DECLARE_EXTENDED_EXCEPTION(name_, except::Exception) - /*! - * Constructor. Takes an Throwable and a Context - * \param t The Throwable - * \param c The Context - */ - ExceptionEx(const ThrowableEx& t, const Context& c) : ThrowableEx(t, c) - { - } - ExceptionEx(const Throwable& t, const Context& c) : ThrowableEx(t, c) - { - } - - /*! - * Constructor. Takes a message - * \param message The message - */ - ExceptionEx(const std::string& message) : ThrowableEx(message) - { - } - - std::string getType() const noexcept override - { - return "ExceptionEx"; - } -}; +using ExceptionEx = Exception; using Exception11 = ExceptionEx; // keep old name around for other projects /*! diff --git a/externals/coda-oss/modules/c++/except/include/except/Throwable.h b/externals/coda-oss/modules/c++/except/include/except/Throwable.h index 5067ab02a0..ffb2ea7b0f 100644 --- a/externals/coda-oss/modules/c++/except/include/except/Throwable.h +++ b/externals/coda-oss/modules/c++/except/include/except/Throwable.h @@ -20,9 +20,9 @@ * */ +#pragma once #ifndef CODA_OSS_except_Throwable_h_INCLUDED_ #define CODA_OSS_except_Throwable_h_INCLUDED_ -#pragma once #include #include @@ -47,14 +47,11 @@ * A lot of existing code has "catch (std::exception)" BEFORE "catch (except::Throwable)" * making it difficult to change without the risk of breaking something. :-( */ -#ifdef CODA_OSS_THROWABLE_ISA_STD_EXCEPTION // -DCODA_OSS_THROWABLE_ISA_STD_EXCEPTION -#ifdef CODA_OSS_except_Throwable_ISA_std_exception -#error "CODA_OSS_except_Throwable_ISA_std_exception is already #define'd." +#ifdef CODA_OSS_THROWABLE_ISA_STD_EXCEPTION +#error "No longer supported, please update your code." #endif -#define CODA_OSS_except_Throwable_ISA_std_exception 1 -#endif -#ifndef CODA_OSS_except_Throwable_ISA_std_exception // or, -DCODA_OSS_except_Throwable_ISA_std_exception=1 -#define CODA_OSS_except_Throwable_ISA_std_exception 0 +#ifdef CODA_OSS_except_Throwable_ISA_std_exception +#error "No longer supported, please update your code." #endif /*! @@ -74,18 +71,21 @@ namespace except * This class provides the base interface for exceptions and errors. */ -class ThrowableEx; -class CODA_OSS_API Throwable -#if CODA_OSS_except_Throwable_ISA_std_exception - : public std::exception +#ifndef SWIGPYTHON +CODA_OSS_disable_warning_push +#if _MSC_VER +#pragma warning(disable: 4275) // non dll-interface class '...' used as base for dll-interface class '...' #endif -{ - void doGetBacktrace(); - template - Throwable(const Context*, const TThrowable* pT, const std::string* pMessage, bool callGetBacktrace, std::nullptr_t); +class CODA_OSS_API Throwable : public std::exception { +CODA_OSS_disable_warning_pop +#else +class Throwable { +#endif // SWIGPYTHON + + void doGetBacktrace(); + Throwable(const Context*, const Throwable* pT, const std::string* pMessage, bool callGetBacktrace, std::nullptr_t); protected: Throwable(const Context*, const Throwable* pT = nullptr, const std::string* pMessage = nullptr, bool callGetBacktrace = false); - Throwable(const Context*, const ThrowableEx* pT, const std::string* pMessage = nullptr, bool callGetBacktrace = false); public: Throwable() = default; @@ -94,7 +94,6 @@ class CODA_OSS_API Throwable Throwable(Throwable&&) = default; Throwable& operator=(Throwable&&) = default; - Throwable(const ThrowableEx&); /*! * Constructor. Takes a message @@ -114,7 +113,6 @@ class CODA_OSS_API Throwable * \param c The Context */ Throwable(const Throwable&, Context); - Throwable(const ThrowableEx&, Context); /*! * Destructor @@ -184,7 +182,7 @@ class CODA_OSS_API Throwable virtual std::string toString(bool includeBacktrace) const { - // Adding the backtrace to existing toString() output could substantally alter existing strings. + // Adding the backtrace to existing toString() output could substantially alter existing strings. std::string backtrace; if (includeBacktrace) { @@ -193,11 +191,10 @@ class CODA_OSS_API Throwable } return toString() + backtrace; } - + #ifndef SWIGPYTHON + const char* what() const noexcept override final // derived classes override toString() + #else const char* what() const noexcept - #if CODA_OSS_except_Throwable_ISA_std_exception - // can't use "final" unless what() is virtual - final // derived classes override toString() #endif { // adding this to toString() output could (significantly) alter existing display @@ -222,57 +219,8 @@ class CODA_OSS_API Throwable * * This class provides the base interface for exceptions and errors. */ +using ThrowableEx = Throwable; -/* - * It can be quite convenient to derive from std::exception as often one less - * "catch" will be needed and we'll have standard what(). But doing so could - * break existing code as "catch (const std::exception&)" will catch - * except::Throwable when it didn't before. - */ -// Use multiple-inheritance :-( to reduce duplicated boilerplate code. -class ThrowableEx : public Throwable // "ThrowableEx" = "Throwable exception" -#if !CODA_OSS_except_Throwable_ISA_std_exception - , public std::exception -#endif -{ -public: - ThrowableEx() = default; - virtual ~ThrowableEx() = default; - ThrowableEx(const ThrowableEx&) = default; - ThrowableEx& operator=(const ThrowableEx&) = default; - ThrowableEx(ThrowableEx&&) = default; - ThrowableEx& operator=(ThrowableEx&&) = default; - - ThrowableEx(const Throwable& t) : Throwable(t){} - - /*! - * Constructor. Takes a message - * \param message The message - */ - ThrowableEx(const std::string& message) : Throwable(message) {} - - /*! - * Constructor. Takes a Context. - * \param c The Context - */ - ThrowableEx(const Context& ctx) : Throwable(ctx) {} - - /*! - * Constructor. Takes a Throwable and a Context - * \param t The throwable - * \param c The Context - */ - ThrowableEx(const ThrowableEx& t, const Context& ctx) : Throwable(t, ctx) {} - ThrowableEx(const Throwable& t, const Context& ctx) : Throwable(t, ctx) {} - - #if !CODA_OSS_except_Throwable_ISA_std_exception - const char* what() const noexcept override final // derived classes override toString() - { - const Throwable* pThrowable = this; - return pThrowable->what(); - } - #endif -}; using Throwable11 = ThrowableEx; // keep old name around for other projects } diff --git a/externals/coda-oss/modules/c++/except/source/Throwable.cpp b/externals/coda-oss/modules/c++/except/source/Throwable.cpp index a30d484dfb..85c2c3f55b 100644 --- a/externals/coda-oss/modules/c++/except/source/Throwable.cpp +++ b/externals/coda-oss/modules/c++/except/source/Throwable.cpp @@ -34,8 +34,7 @@ void except::Throwable::doGetBacktrace() (void)except::getBacktrace(supported, mBacktrace); } -template -except::Throwable::Throwable(const Context* pContext, const TThrowable* pThrowable, const std::string* pMessage, bool callGetBacktrace, std::nullptr_t) +except::Throwable::Throwable(const Context* pContext, const Throwable* pThrowable, const std::string* pMessage, bool callGetBacktrace, std::nullptr_t) { if (pThrowable != nullptr) { @@ -62,7 +61,7 @@ except::Throwable::Throwable(const Context* pContext, const TThrowable* pThrowab // This will record a back-trace from where the Throwable object was instantiated. // That's not necessarily where the "throw" will occur, but it's often the case; Throwable - // instances ususally aren't passed around. That is, hardly anybody does: + // instances usually aren't passed around. That is, hardly anybody does: // Exception e; // Throwable instance // might_throw(e); // rather, the idiom is usually @@ -76,10 +75,6 @@ except::Throwable::Throwable(const Context* pContext, const Throwable* pThrowabl : Throwable(pContext, pThrowable, pMessage, callGetBacktrace, nullptr) { } -except::Throwable::Throwable(const Context* pContext, const ThrowableEx* pThrowable, const std::string* pMessage, bool callGetBacktrace) -: Throwable(pContext, pThrowable, pMessage, callGetBacktrace, nullptr) -{ -} except::Throwable::Throwable(const std::string& message) : Throwable(nullptr, static_cast(nullptr), &message) { @@ -92,9 +87,4 @@ except::Throwable::Throwable(except::Context c) : Throwable(&c) except::Throwable::Throwable(const except::Throwable& t, except::Context c) : Throwable(&c, &t) { } -except::Throwable::Throwable(const except::ThrowableEx& t, except::Context c) : Throwable(&c, &t) -{ -} -except::Throwable::Throwable(const except::ThrowableEx& t) : Throwable(nullptr, &t) -{ -} + diff --git a/externals/coda-oss/modules/c++/io/source/FileInputStreamIOS.cpp b/externals/coda-oss/modules/c++/io/source/FileInputStreamIOS.cpp index e1585d16ba..5ff403893d 100644 --- a/externals/coda-oss/modules/c++/io/source/FileInputStreamIOS.cpp +++ b/externals/coda-oss/modules/c++/io/source/FileInputStreamIOS.cpp @@ -91,7 +91,7 @@ void io::FileInputStreamIOS::open(const char *file, mFStream.open(file, mode); if (!isOpen()) throw except::IOException(Ctxt( - FmtX( + str::Format( "File %s could not be opened for reading", file) ) diff --git a/externals/coda-oss/modules/c++/io/source/FileUtils.cpp b/externals/coda-oss/modules/c++/io/source/FileUtils.cpp index 9de78af1f1..5c61540576 100644 --- a/externals/coda-oss/modules/c++/io/source/FileUtils.cpp +++ b/externals/coda-oss/modules/c++/io/source/FileUtils.cpp @@ -133,7 +133,7 @@ std::string io::FileUtils::createFile(std::string dirname, sys::OS os; if (!os.exists(dirname)) - throw except::IOException(Ctxt(FmtX("Directory does not exist: %s", + throw except::IOException(Ctxt(str::Format("Directory does not exist: %s", dirname.c_str()))); str::trim(filename); diff --git a/externals/coda-oss/modules/c++/io/source/MMapInputStream.cpp b/externals/coda-oss/modules/c++/io/source/MMapInputStream.cpp index d942ac2231..e1391083a5 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(FmtX("Failure while opening file: %s", fname.c_str())); + throw sys::SystemException(str::Format("Failure while opening file: %s", fname.c_str())); _map(); diff --git a/externals/coda-oss/modules/c++/io/source/StandardStreams.cpp b/externals/coda-oss/modules/c++/io/source/StandardStreams.cpp index 2323613990..3e374d09d5 100644 --- a/externals/coda-oss/modules/c++/io/source/StandardStreams.cpp +++ b/externals/coda-oss/modules/c++/io/source/StandardStreams.cpp @@ -33,7 +33,7 @@ void io::StandardOutStream::write(const void* buffer, sys::Size_T len) if (!std::cout.good()) throw except::IOException( Ctxt( - FmtX("std::cout stream is bad after requested write: (%d)", + str::Format("std::cout stream is bad after requested write: (%d)", len)) ); } @@ -53,7 +53,7 @@ void io::StandardErrStream::write(const void* buffer, sys::Size_T len) if (!std::cerr.good()) throw except::IOException( Ctxt( - FmtX("std::cerr stream is bad after requested write: (%d)", + str::Format("std::cerr stream is bad after requested write: (%d)", len) ) ); } diff --git a/externals/coda-oss/modules/c++/io/tests/ioTest1.cpp b/externals/coda-oss/modules/c++/io/tests/ioTest1.cpp index 56cd99924e..f803f47e89 100644 --- a/externals/coda-oss/modules/c++/io/tests/ioTest1.cpp +++ b/externals/coda-oss/modules/c++/io/tests/ioTest1.cpp @@ -33,7 +33,7 @@ int main(int argc, char **argv) { if (argc != 3) { - throw Exception(Ctxt(FmtX("Usage: %s ", + throw Exception(Ctxt(str::Format("Usage: %s ", argv[0]))); } diff --git a/externals/coda-oss/modules/c++/io/tests/ioTest3.cpp b/externals/coda-oss/modules/c++/io/tests/ioTest3.cpp index 39a85190b7..f00693da4f 100644 --- a/externals/coda-oss/modules/c++/io/tests/ioTest3.cpp +++ b/externals/coda-oss/modules/c++/io/tests/ioTest3.cpp @@ -48,7 +48,7 @@ int main(int argc, char **argv) try { if (argc != 3) - throw Exception(Ctxt(FmtX("Usage: %s ", argv[0]))); + throw Exception(Ctxt(str::Format("Usage: %s ", argv[0]))); Copy::run(argv[1], argv[2]); } diff --git a/externals/coda-oss/modules/c++/io/tests/ioTest4.cpp b/externals/coda-oss/modules/c++/io/tests/ioTest4.cpp index a45f89b7fe..7121f9b0eb 100644 --- a/externals/coda-oss/modules/c++/io/tests/ioTest4.cpp +++ b/externals/coda-oss/modules/c++/io/tests/ioTest4.cpp @@ -53,7 +53,7 @@ int main(int argc, char **argv) if (argc != 3) throw except::Error( Ctxt( - FmtX( + str::Format( "Usage: %s ", argv[0]))); diff --git a/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp b/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp index 2037899aee..01fb74dd89 100644 --- a/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp +++ b/externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp @@ -47,9 +47,9 @@ class A : public Serializable virtual void serialize(OutputStream& os) override { os.writeln("Class A"); - os.writeln(FmtX("%f", vec[0])); - os.writeln(FmtX("%f", vec[1])); - os.writeln(FmtX("%f", vec[2])); + os.writeln(str::Format("%f", vec[0])); + os.writeln(str::Format("%f", vec[1])); + os.writeln(str::Format("%f", vec[2])); } virtual void deserialize(InputStream& is) override @@ -60,9 +60,9 @@ class A : public Serializable string vec_2 = fillString(is); assert(classType == "Class A"); - dbg.writeln(FmtX("vec[0] = %s", vec_0.c_str())); - dbg.writeln(FmtX("vec[1] = %s", vec_1.c_str())); - dbg.writeln(FmtX("vec[2] = %s", vec_2.c_str())); + 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())); 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 f7d30fb1ea..8569a8c49f 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(FmtX("Invalid enum value: %s", s.c_str()))); + throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %s", s.c_str()))); } //! int constructor @@ -120,7 +120,7 @@ struct LogLevel final value = LOG_CRITICAL; break; default: - throw except::InvalidFormatException(Ctxt(FmtX("Invalid enum value: %d", i))); + throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %d", i))); } } @@ -145,7 +145,7 @@ struct LogLevel final case 5: return std::string("CRITICAL"); default: - throw except::InvalidFormatException(Ctxt(FmtX("Invalid enum value: %d", value))); + throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %d", value))); } } diff --git a/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fixed1D.h b/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fixed1D.h index 5f14c6fcd4..03024de73f 100644 --- a/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fixed1D.h +++ b/externals/coda-oss/modules/c++/math.poly/include/math/poly/Fixed1D.h @@ -203,14 +203,14 @@ template class Fixed1D _T& operator [] (size_t i) { if (i > _Order) - throw except::IndexOutOfRangeException(Ctxt(FmtX("index [%d] is not in range [0..%d]", i, _Order))); + throw except::IndexOutOfRangeException(Ctxt(str::Format("index [%d] is not in range [0..%d]", i, _Order))); return mCoef[i]; } _T operator [] (size_t i) const { if (i > _Order) - throw except::IndexOutOfRangeException(Ctxt(FmtX("index [%d] is not in range [0..%d]", i, _Order))); + throw except::IndexOutOfRangeException(Ctxt(str::Format("index [%d] is not in range [0..%d]", i, _Order))); return mCoef[i]; diff --git a/externals/coda-oss/modules/c++/mt/tests/MTSingletonTest.cpp b/externals/coda-oss/modules/c++/mt/tests/MTSingletonTest.cpp index beb1719e35..e71dce3454 100644 --- a/externals/coda-oss/modules/c++/mt/tests/MTSingletonTest.cpp +++ b/externals/coda-oss/modules/c++/mt/tests/MTSingletonTest.cpp @@ -103,7 +103,7 @@ class Thespian : public Runnable } void run() override { - //__debugln__(FmtX("[%s]:", mName.c_str())); + //__debugln__(str::Format("[%s]:", mName.c_str())); doLines(); } virtual void doLines() = 0; diff --git a/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp b/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp index 903fa077dc..433d737489 100644 --- a/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp +++ b/externals/coda-oss/modules/c++/net.ssl/source/SSLConnection.cpp @@ -37,7 +37,7 @@ net::ssl::SSLConnection::SSLConnection(std::unique_ptr&& socket, mSSL = SSL_new(ctx); if (mSSL == nullptr) { - throw net::ssl::SSLException(Ctxt(FmtX("SSL_new failed"))); + throw net::ssl::SSLException(Ctxt(str::Format("SSL_new failed"))); } setupSocket(host); @@ -87,7 +87,7 @@ void net::ssl::SSLConnection::setupSocket(const std::string& hostName) #endif throw net::ssl::SSLException - (Ctxt(FmtX("SSL_connect failed: %d", SSL_get_error(mSSL, val)))); + (Ctxt(str::Format("SSL_connect failed: %d", SSL_get_error(mSSL, val)))); } if(mServerAuthentication) @@ -143,7 +143,7 @@ sys::SSize_T net::ssl::SSLConnection::read(sys::byte* b, sys::Size_T len) std::cout << "=============================================" << std::endl << std::endl; #endif - throw net::ssl::SSLException(Ctxt(FmtX("When receiving %d bytes", + throw net::ssl::SSLException(Ctxt(str::Format("When receiving %d bytes", len)) ); } else if (numBytes == 0) @@ -155,7 +155,7 @@ sys::SSize_T net::ssl::SSLConnection::read(sys::byte* b, sys::Size_T len) return -1; } #if defined(__DEBUG_SOCKET) - std::cout << FmtX("Read %d bytes from socket:", numBytes) << std::endl; + std::cout << str::Format("Read %d bytes from socket:", numBytes) << std::endl; std::cout << "---------------------------------------------" << std::endl; std::cout << std::string(b, numBytes) << std::endl; std::cout << "---------------------------------------------" << std::endl; @@ -172,7 +172,7 @@ void net::ssl::SSLConnection::write(const sys::byte* b, sys::Size_T len) const auto numBytes = SSL_write(mSSL, (const char*)b, len); if (static_cast(numBytes) != len) { - throw net::ssl::SSLException(Ctxt(FmtX("Tried sending %d bytes, %d sent", + throw net::ssl::SSLException(Ctxt(str::Format("Tried sending %d bytes, %d sent", len, numBytes)) ); } diff --git a/externals/coda-oss/modules/c++/net.ssl/source/SSLConnectionClientFactory.cpp b/externals/coda-oss/modules/c++/net.ssl/source/SSLConnectionClientFactory.cpp index 5a9d441480..63a721a818 100644 --- a/externals/coda-oss/modules/c++/net.ssl/source/SSLConnectionClientFactory.cpp +++ b/externals/coda-oss/modules/c++/net.ssl/source/SSLConnectionClientFactory.cpp @@ -60,12 +60,12 @@ void net::ssl::SSLConnectionClientFactory::initializeContext() if(method == nullptr) { - throw net::ssl::SSLException(Ctxt(FmtX("SSLv23_client_method failed"))); + throw net::ssl::SSLException(Ctxt(str::Format("SSLv23_client_method failed"))); } mCtx = SSL_CTX_new(method); if(mCtx == nullptr) { - throw net::ssl::SSLException(Ctxt(FmtX("SSL_CTX_new failed"))); + throw net::ssl::SSLException(Ctxt(str::Format("SSL_CTX_new failed"))); } if(mClientAuthentication) diff --git a/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClient.cpp b/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClient.cpp index 074b4abb23..ff8db2b6fd 100644 --- a/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClient.cpp +++ b/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClient.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) try { if (argc != 2) - throw Exception(FmtX("Usage: %s ", argv[0])); + throw Exception(str::Format("Usage: %s ", argv[0])); URL url(argv[1]); //int sslOn = atoi(argv[2]); diff --git a/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClientNoURL.cpp b/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClientNoURL.cpp index 60baa34faa..89c4d64764 100644 --- a/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClientNoURL.cpp +++ b/externals/coda-oss/modules/c++/net.ssl/tests/SSLTestClientNoURL.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv) try { if (argc != 3) - throw Exception(FmtX("Usage: %s ", argv[0])); + throw Exception(str::Format("Usage: %s ", argv[0])); std::string host(argv[1]); int port(atoi(argv[2])); diff --git a/externals/coda-oss/modules/c++/net/source/DaemonUnix.cpp b/externals/coda-oss/modules/c++/net/source/DaemonUnix.cpp index 8683816f95..797f515788 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(FmtX("Failed to open file %s for STDOUT.", filename.c_str()))); + Ctxt(str::Format("Failed to open file %s for STDOUT.", filename.c_str()))); } if (openFileFor(STDERR_FILENO, filename, O_WRONLY|O_CREAT|O_TRUNC) < 0) { throw except::Exception( - Ctxt(FmtX("Failed to open file %s for STDERR.", filename.c_str()))); + Ctxt(str::Format("Failed to open file %s for STDERR.", filename.c_str()))); } } diff --git a/externals/coda-oss/modules/c++/net/source/Socket.cpp b/externals/coda-oss/modules/c++/net/source/Socket.cpp index 9c0c791b90..4fa436453c 100644 --- a/externals/coda-oss/modules/c++/net/source/Socket.cpp +++ b/externals/coda-oss/modules/c++/net/source/Socket.cpp @@ -115,7 +115,7 @@ size_t net::Socket::recv(void* b, size_t len, int flags) return static_cast(-1); } #if defined(__DEBUG_SOCKET) - std::cout << FmtX("Read %d bytes from socket:", numBytes) << std::endl; + std::cout << str::Format("Read %d bytes from socket:", numBytes) << std::endl; std::cout << "---------------------------------------------" << std::endl; std::cout << std::string(b, numBytes) << std::endl; std::cout << "---------------------------------------------" << std::endl; diff --git a/externals/coda-oss/modules/c++/net/tests/NetConnectionClientTest.cpp b/externals/coda-oss/modules/c++/net/tests/NetConnectionClientTest.cpp index 992ac5eca0..abe0b35790 100644 --- a/externals/coda-oss/modules/c++/net/tests/NetConnectionClientTest.cpp +++ b/externals/coda-oss/modules/c++/net/tests/NetConnectionClientTest.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) try { if (argc != 3) - throw Exception(FmtX("Usage: %s ", argv[0])); + throw Exception(str::Format("Usage: %s ", argv[0])); std::string host(argv[1]); int port(atoi(argv[2])); diff --git a/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp b/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp index ed72a907ba..0cb8cdb0cf 100644 --- a/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp +++ b/externals/coda-oss/modules/c++/net/tests/NetConnectionServerTest.cpp @@ -74,7 +74,7 @@ int main(int argc, char **argv) try { if (argc < 2) - throw Exception(FmtX("Usage: %s (-mt|-st|-tp)", argv[0])); + throw Exception(str::Format("Usage: %s (-mt|-st|-tp)", argv[0])); net::AllocStrategy* strategy = nullptr; diff --git a/externals/coda-oss/modules/c++/net/tests/SerializableTestClient.cpp b/externals/coda-oss/modules/c++/net/tests/SerializableTestClient.cpp index 229758ca3f..0c472bf09f 100644 --- a/externals/coda-oss/modules/c++/net/tests/SerializableTestClient.cpp +++ b/externals/coda-oss/modules/c++/net/tests/SerializableTestClient.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) try { if (argc != 2) - throw Exception(FmtX("Usage: %s ", argv[0])); + throw Exception(str::Format("Usage: %s ", argv[0])); URL url(argv[1]); diff --git a/externals/coda-oss/modules/c++/net/tests/URLTest.cpp b/externals/coda-oss/modules/c++/net/tests/URLTest.cpp index aacde069ca..e6c5f79320 100644 --- a/externals/coda-oss/modules/c++/net/tests/URLTest.cpp +++ b/externals/coda-oss/modules/c++/net/tests/URLTest.cpp @@ -36,7 +36,7 @@ int main(int argc, char **argv) try { if (argc != 2) - throw Exception(FmtX("Usage: %s ", argv[0])); + throw Exception(str::Format("Usage: %s ", argv[0])); URL url(argv[1]); diff --git a/externals/coda-oss/modules/c++/plugin/include/plugin/BasicPluginManager.h b/externals/coda-oss/modules/c++/plugin/include/plugin/BasicPluginManager.h index c421beea9e..6e65ea9eb4 100644 --- a/externals/coda-oss/modules/c++/plugin/include/plugin/BasicPluginManager.h +++ b/externals/coda-oss/modules/c++/plugin/include/plugin/BasicPluginManager.h @@ -278,8 +278,8 @@ template class BasicPluginManager for (unsigned int i = 0; ops[i] != nullptr; i++) oss << ops[i] << ":"; - auto unsupported = FmtX("For plugin supporting ops %s version ", oss.str()); - unsupported += FmtX("[%d.%d] not supported (%d.%d)", majorVersion, minorVersion, mMajorVersion, mMinorVersion); + auto unsupported = str::Format("For plugin supporting ops %s version ", oss.str()); + unsupported += str::Format("[%d.%d] not supported (%d.%d)", majorVersion, minorVersion, mMajorVersion, mMinorVersion); eh->onPluginVersionUnsupported(unsupported); return; } @@ -290,7 +290,7 @@ template class BasicPluginManager if (! pluginHandler ) { eh->onPluginLoadFailed( - FmtX("Failed to spawn handler for op %s", ops[i])); + str::Format("Failed to spawn handler for op %s", ops[i])); // Keep going } mHandlers[ops[i]].first = pluginHandler; diff --git a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileWriter.h b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileWriter.h index 8d75266d52..72a895b00c 100644 --- a/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileWriter.h +++ b/externals/coda-oss/modules/c++/sio.lite/include/sio/lite/SioFileWriter.h @@ -173,7 +173,7 @@ template void writeSIO(const T* image, size_t rows, size_t cols, et = FileHeader::UNSIGNED; break; default: - throw except::Exception(Ctxt(FmtX("Unexpected es: %d", es))); + throw except::Exception(Ctxt(str::Format("Unexpected es: %d", es))); } } diff --git a/externals/coda-oss/modules/c++/str/include/str/Format.h b/externals/coda-oss/modules/c++/str/include/str/Format.h index 44808100f1..6261e204df 100644 --- a/externals/coda-oss/modules/c++/str/include/str/Format.h +++ b/externals/coda-oss/modules/c++/str/include/str/Format.h @@ -65,152 +65,155 @@ inline auto Format(const char* format, const T1& t1, const T2& t2, const T3& t3, return Format_(format, t1, t2, t3, t4); } } -} + /*! * \param format The format * \param ... Any printf like thing */ -inline auto FmtX(const char* format) +inline auto Format(const char* format) { - return str::details::Format(format); + return details::Format(format); } -inline auto FmtX(const char* format, const char* pStr) +inline auto Format(const char* format, const char* pStr) { - return str::details::Format(format, pStr); + return details::Format(format, pStr); } -inline auto FmtX(const char* format, const std::string& s) +inline auto Format(const char* format, const std::string& s) { - return FmtX(format, s.c_str()); + return Format(format, s.c_str()); } -inline auto FmtX(const char* format, int i) +inline auto Format(const char* format, int i) { - return str::details::Format(format, i); + return details::Format(format, i); } -inline auto FmtX(const char* format, uint32_t i) +inline auto Format(const char* format, uint32_t i) { - return str::details::Format(format, i); + return details::Format(format, i); } -inline auto FmtX(const char* format, ptrdiff_t l) +inline auto Format(const char* format, ptrdiff_t l) { - return str::details::Format(format, l); + return details::Format(format, l); } -inline auto FmtX(const char* format, size_t ul) +inline auto Format(const char* format, size_t ul) { - return str::details::Format(format, ul); + return details::Format(format, ul); } -inline auto FmtX(const char* format, float f) +inline auto Format(const char* format, float f) { - return str::details::Format(format, f); + return details::Format(format, f); } -inline auto FmtX(const char* format, double d) +inline auto Format(const char* format, double d) { - return str::details::Format(format, d); + return details::Format(format, d); } -inline auto FmtX(const char* format, const void* p) +inline auto Format(const char* format, const void* p) { - return str::details::Format(format, p); + return details::Format(format, p); } -inline auto FmtX(const char* format, char ch, const char* pStr) +inline auto Format(const char* format, char ch, const char* pStr) { - return str::details::Format(format, ch, pStr); + return details::Format(format, ch, pStr); } -inline auto FmtX(const char* format, char ch, const std::string& s) +inline auto Format(const char* format, char ch, const std::string& s) { - return FmtX(format, ch, s.c_str()); + return Format(format, ch, s.c_str()); } -inline auto FmtX(const char* format, const std::string& s1, const std::string& s2) +inline auto Format(const char* format, const std::string& s1, const std::string& s2) { - return str::details::Format(format, s1.c_str(), s2.c_str()); + return details::Format(format, s1.c_str(), s2.c_str()); } -inline auto FmtX(const char* format, const std::string& s, size_t ul) +inline auto Format(const char* format, const std::string& s, size_t ul) { - return str::details::Format(format, s.c_str(), ul); + return details::Format(format, s.c_str(), ul); } -inline auto FmtX(const char* format, char ch1, char ch2) +inline auto Format(const char* format, char ch1, char ch2) { - return str::details::Format(format, ch1, ch2); + return details::Format(format, ch1, ch2); } -inline auto FmtX(const char* format, int i1, int i2) +inline auto Format(const char* format, int i1, int i2) { - return str::details::Format(format, i1, i2); + return details::Format(format, i1, i2); } -inline auto FmtX(const char* format, long l1, long l2) +inline auto Format(const char* format, long l1, long l2) { - return str::details::Format(format, l1, l2); + return details::Format(format, l1, l2); } -inline auto FmtX(const char* format, uint32_t ui1, uint32_t ui2) +inline auto Format(const char* format, uint32_t ui1, uint32_t ui2) { - return str::details::Format(format, ui1, ui2); + return details::Format(format, ui1, ui2); } -inline auto FmtX(const char* format, size_t ul1, size_t ul2) +inline auto Format(const char* format, size_t ul1, size_t ul2) { - return str::details::Format(format, ul1, ul2); + return details::Format(format, ul1, ul2); } -inline auto FmtX(const char* format, size_t ul1, int i2) +inline auto Format(const char* format, size_t ul1, int i2) { - return str::details::Format(format, ul1, i2); + return details::Format(format, ul1, i2); } -inline auto FmtX(const char* format, double d1, double d2) +inline auto Format(const char* format, double d1, double d2) { - return str::details::Format(format, d1, d2); + return details::Format(format, d1, d2); } -inline auto FmtX(const char* format, int i, const char* pStr) +inline auto Format(const char* format, int i, const char* pStr) { - return str::details::Format(format, i, pStr); + return details::Format(format, i, pStr); } -inline auto FmtX(const char* fmt, int i, const std::string& s) +inline auto Format(const char* fmt, int i, const std::string& s) { - return FmtX(fmt, i, s.c_str()); + return Format(fmt, i, s.c_str()); } -inline auto FmtX(const char* format, char ch1, char ch2, const std::string& s) +inline auto Format(const char* format, char ch1, char ch2, const std::string& s) { - return str::details::Format(format, ch1, ch2, s.c_str()); + return details::Format(format, ch1, ch2, s.c_str()); } -inline auto FmtX(const char* format, int i1, int i2, unsigned long ul) +inline auto Format(const char* format, int i1, int i2, unsigned long ul) { - return str::details::Format(format, i1, i2, ul); + return details::Format(format, i1, i2, ul); } -inline auto FmtX(const char* format, int i1, int i2, int i3) +inline auto Format(const char* format, int i1, int i2, int i3) { - return str::details::Format(format, i1, i2, i3); + return details::Format(format, i1, i2, i3); } -inline auto FmtX(const char* format, float f1, float f2, float f3) +inline auto Format(const char* format, float f1, float f2, float f3) { - return str::details::Format(format, f1, f2, f3); + return details::Format(format, f1, f2, f3); } -inline std::string FmtX(const char* format, const std::string& s1, int i2, int i3) +inline std::string Format(const char* format, const std::string& s1, int i2, int i3) { - return str::details::Format(format, s1.c_str(), i2, i3); + return details::Format(format, s1.c_str(), i2, i3); } -inline auto FmtX(const char* format, const std::string& s1, const std::string& s2, uint32_t ui) +inline auto Format(const char* format, const std::string& s1, const std::string& s2, uint32_t ui) { - return str::details::Format(format, s1.c_str(), s2.c_str(), ui); + return details::Format(format, s1.c_str(), s2.c_str(), ui); } -inline auto FmtX(const char* format, const std::string& s1, const std::string& s2, const std::string& s3) +inline auto Format(const char* format, const std::string& s1, const std::string& s2, const std::string& s3) { - return str::details::Format(format, s1.c_str(), s2.c_str(), s3.c_str()); + return details::Format(format, s1.c_str(), s2.c_str(), s3.c_str()); } -inline auto FmtX(const char* format, int i1, int i2, int i3, int i4) +inline auto Format(const char* format, int i1, int i2, int i3, int i4) { - return str::details::Format(format, i1, i2, i3, i4); + return details::Format(format, i1, i2, i3, i4); } -inline auto FmtX(const char* format, uint32_t ui1, uint32_t ui2, uint32_t ui3, uint32_t ui4) +inline auto Format(const char* format, uint32_t ui1, uint32_t ui2, uint32_t ui3, uint32_t ui4) { - return str::details::Format(format, ui1, ui2, ui3, ui4); + return details::Format(format, ui1, ui2, ui3, ui4); } -inline auto FmtX(const char* format, const char* pStr1, const std::string& s2, const char* pStr3, const std::string& s4) +inline auto Format(const char* format, const char* pStr1, const std::string& s2, const char* pStr3, const std::string& s4) { - return str::details::Format(format, pStr1, s2.c_str(), pStr3, s4.c_str()); + return details::Format(format, pStr1, s2.c_str(), pStr3, s4.c_str()); } -inline auto FmtX(const char* format, const std::string& s1, int i2, const std::string& s3, int i4) +inline auto Format(const char* format, const std::string& s1, int i2, const std::string& s3, int i4) { - return str::details::Format(format, s1.c_str(), i2, s3.c_str(), i4); + return details::Format(format, s1.c_str(), i2, s3.c_str(), i4); } +} + +#define FmtX(format, ...) str::Format(format, __VA_ARGS__) #endif // CODA_OSS_str_Format_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/str/tests/VersionTest.cpp b/externals/coda-oss/modules/c++/str/tests/VersionTest.cpp index aa1d9625dc..627696cdf5 100644 --- a/externals/coda-oss/modules/c++/str/tests/VersionTest.cpp +++ b/externals/coda-oss/modules/c++/str/tests/VersionTest.cpp @@ -25,7 +25,7 @@ int main() { - std::cout << FmtX("Your version of str is %d.%d.%d\n", + std::cout << str::Format("Your version of str is %d.%d.%d\n", STR_MAJOR_VERSION, STR_MINOR_VERSION, STR_MICRO_VERSION); std::cout << "Specialization for string test...\n"; std::string ok("This test passes"); diff --git a/externals/coda-oss/modules/c++/sys/include/sys/ThreadInterface.h b/externals/coda-oss/modules/c++/sys/include/sys/ThreadInterface.h index e536fe48e7..cefbf8dcc4 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/ThreadInterface.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/ThreadInterface.h @@ -132,7 +132,7 @@ struct CODA_OSS_API ThreadInterface : public Runnable // of nasty issues that could pop up (execution in freed memory, etc). if (isRunning()) { - std::cerr << Ctxt(FmtX("Thread object [%s] destructed before " \ + std::cerr << Ctxt(str::Format("Thread object [%s] destructed before " \ "thread terminated, aborting program.", getName().c_str())) << std::endl; abort(); diff --git a/externals/coda-oss/modules/c++/sys/source/DLLWin32.cpp b/externals/coda-oss/modules/c++/sys/source/DLLWin32.cpp index 466f7d2952..6fc96611fc 100644 --- a/externals/coda-oss/modules/c++/sys/source/DLLWin32.cpp +++ b/externals/coda-oss/modules/c++/sys/source/DLLWin32.cpp @@ -45,7 +45,7 @@ void sys::DLL::load(const std::string& libName) // Now we check the return value if (!mLib) - throw sys::DLLException(FmtX("Failed to load() DLL: %s", + throw sys::DLLException(str::Format("Failed to load() DLL: %s", mLibName.c_str() ) ); } @@ -75,7 +75,7 @@ retrieve(const std::string& functionName) // Now we check the ptr value if (ptr == nullptr) - throw sys::DLLException(FmtX("Failed to load function: %s", + throw sys::DLLException(str::Format("Failed to load function: %s", functionName.c_str())); return ptr; } diff --git a/externals/coda-oss/modules/c++/sys/source/FileUnix.cpp b/externals/coda-oss/modules/c++/sys/source/FileUnix.cpp index e603835a32..07d6c5ff94 100644 --- a/externals/coda-oss/modules/c++/sys/source/FileUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/FileUnix.cpp @@ -43,7 +43,7 @@ void sys::File::create(const std::string& str, int accessFlags, if (mHandle < 0) { throw sys::SystemException(Ctxt( - FmtX("Error opening file [%d]: [%s]", mHandle, str.c_str()))); + str::Format("Error opening file [%d]: [%s]", mHandle, str.c_str()))); } } diff --git a/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp b/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp index 5e2f2b23d0..cf30c9f6cc 100644 --- a/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp +++ b/externals/coda-oss/modules/c++/sys/source/FileWin32.cpp @@ -59,7 +59,7 @@ void sys::File::create(const std::string& str, if (mHandle == INVALID_HANDLE_VALUE) { throw sys::SystemException( - Ctxt(FmtX("Error opening file: [%s]", str.c_str()))); + Ctxt(str::Format("Error opening file: [%s]", str.c_str()))); } } @@ -169,7 +169,7 @@ sys::Off_T sys::File::lastModifiedTime() return (sys::Off_T)stInMillis; } throw sys::SystemException(Ctxt( - FmtX("Error getting last modified time for path %s", + str::Format("Error getting last modified time for path %s", mPath.c_str()))); } diff --git a/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp b/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp index 5d5685ba92..d1806010d8 100644 --- a/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp +++ b/externals/coda-oss/modules/c++/sys/source/OSUnix.cpp @@ -144,8 +144,8 @@ std::string sys::OSUnix::getPlatformName() const throw sys::SystemException("Uname failed"); std::string retval = name.sysname; - retval += FmtX(" (%s): %s", name.machine, name.release); - retval += FmtX(" [build: %s]", name.version); + retval += str::Format(" (%s): %s", name.machine, name.release); + retval += str::Format(" [build: %s]", name.version); return retval; } diff --git a/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp b/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp index 62ac0cda35..bde4cb5d28 100644 --- a/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp +++ b/externals/coda-oss/modules/c++/sys/source/OSWin32.cpp @@ -59,7 +59,7 @@ std::string sys::OSWin32::getPlatformName() const platform = "Unknown Windows OS"; } auto retval = platform + ": "; - retval += FmtX("%d.%d [build: %d], ", info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber); + retval += str::Format("%d.%d [build: %d], ", info.dwMajorVersion, info.dwMinorVersion, info.dwBuildNumber); retval += info.szCSDVersion; return retval; } diff --git a/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp b/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp index 330493eb76..79be99659a 100644 --- a/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp +++ b/externals/coda-oss/modules/c++/sys/tests/OSTest.cpp @@ -92,7 +92,7 @@ int main(int argc, char **argv) std::string tempFileName = os.getTempName(); std::ofstream ofs(tempFileName.c_str()); if (!ofs.is_open()) - throw except::Exception(FmtX("Could not open file named: %s", + throw except::Exception(str::Format("Could not open file named: %s", tempFileName.c_str())); ofs << "Im writing some crap to this file!" << std::endl; ofs.close(); 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 706309e8f4..4975bdaaa8 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/IFD.h @@ -155,7 +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(FmtX( + throw except::Exception(Ctxt(str::Format( "Unable to add IFD Entry: unknown tag [%s]", name.c_str()))); const auto id = mapEntry->getTagID(); diff --git a/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h b/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h index fb495a6766..f6474c6e2e 100644 --- a/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h +++ b/externals/coda-oss/modules/c++/tiff/include/tiff/TiffFileWriter.h @@ -191,7 +191,7 @@ template void writeTIFF(const T* image, size_t rows, size_t cols, et = ::tiff::Const::SampleFormatType::UNSIGNED_INT; break; default: - throw except::Exception(Ctxt(FmtX("Unexpected es: %d", es))); + throw except::Exception(Ctxt(str::Format("Unexpected es: %d", es))); } } unsigned short alpha(0); diff --git a/externals/coda-oss/modules/c++/tiff/source/IFD.cpp b/externals/coda-oss/modules/c++/tiff/source/IFD.cpp index fb145461db..bb9d80e7dc 100644 --- a/externals/coda-oss/modules/c++/tiff/source/IFD.cpp +++ b/externals/coda-oss/modules/c++/tiff/source/IFD.cpp @@ -90,7 +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(FmtX( + throw except::Exception(Ctxt(str::Format( "Unable to add IFD Entry: unknown tag [%s]", name.c_str()))); unsigned short id = mapEntry->getTagID(); diff --git a/externals/coda-oss/modules/c++/tiff/source/ImageReader.cpp b/externals/coda-oss/modules/c++/tiff/source/ImageReader.cpp index 5fd42c6adc..9e5c1cbf7e 100644 --- a/externals/coda-oss/modules/c++/tiff/source/ImageReader.cpp +++ b/externals/coda-oss/modules/c++/tiff/source/ImageReader.cpp @@ -65,7 +65,7 @@ void tiff::ImageReader::getData(unsigned char *buffer, { unsigned short c = *(tiff::GenericType *)(*compression)[0]; if (c != tiff::Const::CompressionType::NO_COMPRESSION) - throw except::Exception(Ctxt(FmtX("Unsupported compression type: %d", c))); + throw except::Exception(Ctxt(str::Format("Unsupported compression type: %d", c))); } if (mIFD["StripOffsets"]) diff --git a/externals/coda-oss/modules/c++/tiff/source/TiffFileReader.cpp b/externals/coda-oss/modules/c++/tiff/source/TiffFileReader.cpp index e0d78f8417..812a1bb9ce 100644 --- a/externals/coda-oss/modules/c++/tiff/source/TiffFileReader.cpp +++ b/externals/coda-oss/modules/c++/tiff/source/TiffFileReader.cpp @@ -79,7 +79,7 @@ void tiff::FileReader::close() tiff::ImageReader *tiff::FileReader::operator[](const sys::Uint32_T index) const { if (index >= mImages.size()) - throw except::Exception(Ctxt(FmtX("Index out of range: %d", index))); + throw except::Exception(Ctxt(str::Format("Index out of range: %d", index))); return mImages[index]; } @@ -106,7 +106,7 @@ void tiff::FileReader::getData(unsigned char *buffer, const sys::Uint32_T numElementsToRead, const sys::Uint32_T imageIndex) { if (imageIndex >= mImages.size()) - throw except::Exception(Ctxt(FmtX("Index out of range", imageIndex))); + throw except::Exception(Ctxt(str::Format("Index out of range", imageIndex))); mImages[imageIndex]->getData(buffer, numElementsToRead); } diff --git a/externals/coda-oss/modules/c++/tiff/tests/DumpHeader.cpp b/externals/coda-oss/modules/c++/tiff/tests/DumpHeader.cpp index 1c310f4419..2e0be41cbe 100644 --- a/externals/coda-oss/modules/c++/tiff/tests/DumpHeader.cpp +++ b/externals/coda-oss/modules/c++/tiff/tests/DumpHeader.cpp @@ -31,7 +31,7 @@ int main(int argc, char **argv) try { if (argc < 2) - throw except::Exception(FmtX("usage: %s ", argv[0])); + throw except::Exception(str::Format("usage: %s ", argv[0])); sys::OS os; std::string path = sys::Path::absolutePath(argv[1]); @@ -47,7 +47,7 @@ int main(int argc, char **argv) if (tiff::Utils::hasGeoTiffIFD(reader[i]->getIFD())) { outStream.writeln("==========================="); - outStream.writeln(FmtX("GeoTIFF detected: Image %d\n", (i + 1))); + outStream.writeln(str::Format("GeoTIFF detected: Image %d\n", (i + 1))); tiff::IFD *geoIFD = tiff::Utils::createGeoTiffIFD(reader[i]->getIFD()); geoIFD->print(outStream); 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 2628ca7c84..4032f86fc0 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/Attributes.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/Attributes.cpp @@ -81,7 +81,7 @@ std::string xml::lite::Attributes::getValue(int i) const } catch (const std::out_of_range& ex) { - throw except::NoSuchKeyException(Ctxt(FmtX("attributes[%d] not found, %s", i, ex.what()))); + throw except::NoSuchKeyException(Ctxt(str::Format("attributes[%d] not found, %s", i, ex.what()))); } } bool xml::lite::Attributes::getValue(int i, std::string& result) const @@ -125,7 +125,7 @@ std::string xml::lite::Attributes::getValue(const std::string& qname) const std::string retval; if (!getValue(qname, retval)) { - throw except::NoSuchKeyException(Ctxt(FmtX("QName '%s' could not be found", + throw except::NoSuchKeyException(Ctxt(str::Format("QName '%s' could not be found", qname.c_str()))); } @@ -152,7 +152,7 @@ std::string xml::lite::Attributes::getValue(const QName& qname) const { const auto uri = qname.getUri().value; const auto localName = qname.getName(); - throw except::NoSuchKeyException(Ctxt(FmtX("(uri: %s, localName: %s", uri, localName))); + throw except::NoSuchKeyException(Ctxt(str::Format("(uri: %s, localName: %s", uri, localName))); } return retval; } diff --git a/externals/coda-oss/modules/c++/xml.lite/tests/AttributeValueTest.cpp b/externals/coda-oss/modules/c++/xml.lite/tests/AttributeValueTest.cpp index c66f466caa..01e66e1e0a 100644 --- a/externals/coda-oss/modules/c++/xml.lite/tests/AttributeValueTest.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/tests/AttributeValueTest.cpp @@ -41,7 +41,7 @@ int main(int argc, char **argv) // Check to make sure we have right length if (argc != 2) - throw Exception(Ctxt(FmtX("Usage: %s \n", argv[0]))); + throw Exception(Ctxt(str::Format("Usage: %s \n", argv[0]))); // Create an input stream FileInputStream xmlFile(argv[1]); diff --git a/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest1.cpp b/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest1.cpp index ac5ffa42ea..aaa37b9abe 100644 --- a/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest1.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest1.cpp @@ -39,7 +39,7 @@ int main(int argc, char **argv) // Check to make sure we have right length if (argc != 2) - throw Exception(Ctxt(FmtX("Usage: %s \n", argv[0]))); + throw Exception(Ctxt(str::Format("Usage: %s \n", argv[0]))); // Create an input stream FileInputStream xmlFile(argv[1]); diff --git a/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest2.cpp b/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest2.cpp index ee28d77d8c..78c01da3bc 100644 --- a/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest2.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/tests/MinidomParserTest2.cpp @@ -52,7 +52,7 @@ int main(int argc, char **argv) { if (argc != 5) { - throw Exception(Ctxt(FmtX( + throw Exception(Ctxt(str::Format( "Usage: %s [OPTION] \n\n\t-a\tadd service\n\t-s\tsubtract service\n\t-o\toutput file\n", argv[0]))); } @@ -123,7 +123,7 @@ int main(int argc, char **argv) if (rootElement) rootElement->print(out); break; default: - throw Exception(Ctxt(FmtX( + throw Exception(Ctxt(str::Format( "Usage: %s [OPTION] \n\n\t-a\tadd service\n\t-s\tsubtract service\n\t-o\toutput file\n", argv[0]))); } diff --git a/externals/coda-oss/modules/c++/xml.lite/tests/XMLReaderTest.cpp b/externals/coda-oss/modules/c++/xml.lite/tests/XMLReaderTest.cpp index 8e4cf9a080..83989cb4a1 100644 --- a/externals/coda-oss/modules/c++/xml.lite/tests/XMLReaderTest.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/tests/XMLReaderTest.cpp @@ -134,7 +134,7 @@ int main(int argc, char **argv) { // Check to make sure we have right length if (argc != 2) - throw Exception(Ctxt(FmtX("Usage: %s \n", argv[0]))); + throw Exception(Ctxt(str::Format("Usage: %s \n", argv[0]))); // Create an input stream FileInputStream diff --git a/externals/coda-oss/modules/c++/zip/source/ZipEntry.cpp b/externals/coda-oss/modules/c++/zip/source/ZipEntry.cpp index 4c93526729..14bc85be17 100644 --- a/externals/coda-oss/modules/c++/zip/source/ZipEntry.cpp +++ b/externals/coda-oss/modules/c++/zip/source/ZipEntry.cpp @@ -50,7 +50,7 @@ void ZipEntry::inflate(sys::ubyte* out, sys::Size_T outLen, sys::ubyte* in, int zerr = inflateInit2(&zstream, -MAX_WBITS); if (zerr != Z_OK) { - throw except::IOException(Ctxt(FmtX("inflateInit2 failed [%d]", zerr))); + throw except::IOException(Ctxt(str::Format("inflateInit2 failed [%d]", zerr))); } // decompress @@ -58,7 +58,7 @@ void ZipEntry::inflate(sys::ubyte* out, sys::Size_T outLen, sys::ubyte* in, if (zerr != Z_STREAM_END) { - throw except::IOException(Ctxt(FmtX( + throw except::IOException(Ctxt(str::Format( "inflate failed [%d]: wanted: %d, got: %lu", zerr, Z_STREAM_END, zstream.total_out))); } diff --git a/modules/c++/nitf/include/nitf/NITFException.hpp b/modules/c++/nitf/include/nitf/NITFException.hpp index 46b9bac5bf..6c91837d71 100644 --- a/modules/c++/nitf/include/nitf/NITFException.hpp +++ b/modules/c++/nitf/include/nitf/NITFException.hpp @@ -20,9 +20,9 @@ * */ +#pragma once #ifndef __NITF_EXCEPTION_HPP__ #define __NITF_EXCEPTION_HPP__ -#pragma once #include @@ -79,7 +79,11 @@ namespace nitf * \class NITFException * \brief The C++ wrapper for the nitf_Error */ -class NITFException /*final*/ : public except::Exception // no "final", SWIG doesn't like it +#ifndef SWIGPYTHON // no "final", SWIG doesn't like it +class NITFException final : public except::Exception +#else +class NITFException : public except::Exception +#endif { static except::Context make_Context_(const Error& error, const std::string& message) { diff --git a/modules/c++/nitf/include/nitf/Object.hpp b/modules/c++/nitf/include/nitf/Object.hpp index 035995bfc5..815943483e 100644 --- a/modules/c++/nitf/include/nitf/Object.hpp +++ b/modules/c++/nitf/include/nitf/Object.hpp @@ -151,7 +151,7 @@ class NITRO_NITFCPP_API Object */ std::string getObjectID() const { - return FmtX("%p", getNative()); + return str::Format("%p", getNative()); } bool isManaged() const noexcept { return isValid() && mHandle->isManaged(); } diff --git a/modules/c++/nitf/source/FileHeader.cpp b/modules/c++/nitf/source/FileHeader.cpp index d5facc2f87..73dc5d3572 100644 --- a/modules/c++/nitf/source/FileHeader.cpp +++ b/modules/c++/nitf/source/FileHeader.cpp @@ -200,7 +200,7 @@ nitf::ComponentInfo FileHeader::getImageInfo(int i) const { int num = getNumImages(); if (i < 0 || i >= num) - throw except::IndexOutOfRangeException(Ctxt(FmtX( + throw except::IndexOutOfRangeException(Ctxt(str::Format( "Index out of range: (%d <= %d <= %d)", 0, i, num))); return make_ComponentInfo(getNativeOrThrow()->imageInfo, i); } @@ -209,7 +209,7 @@ nitf::ComponentInfo FileHeader::getGraphicInfo(int i) const { int num = getNumGraphics(); if (i < 0 || i >= num) - throw except::IndexOutOfRangeException(Ctxt(FmtX( + throw except::IndexOutOfRangeException(Ctxt(str::Format( "Index out of range: (%d <= %d <= %d)", 0, i, num))); return make_ComponentInfo(getNativeOrThrow()->graphicInfo, i); } @@ -218,7 +218,7 @@ nitf::ComponentInfo FileHeader::getLabelInfo(int i) const { int num = getNumLabels(); if (i < 0 || i >= num) - throw except::IndexOutOfRangeException(Ctxt(FmtX( + throw except::IndexOutOfRangeException(Ctxt(str::Format( "Index out of range: (%d <= %d <= %d)", 0, i, num))); return make_ComponentInfo(getNativeOrThrow()->labelInfo, i); } @@ -227,7 +227,7 @@ nitf::ComponentInfo FileHeader::getTextInfo(int i) const { int num = getNumTexts(); if (i < 0 || i >= num) - throw except::IndexOutOfRangeException(Ctxt(FmtX( + throw except::IndexOutOfRangeException(Ctxt(str::Format( "Index out of range: (%d <= %d <= %d)", 0, i, num))); return make_ComponentInfo(getNativeOrThrow()->textInfo, i); } @@ -236,7 +236,7 @@ nitf::ComponentInfo FileHeader::getDataExtensionInfo(int i) const { int num = getNumDataExtensions(); if (i < 0 || i >= num) - throw except::IndexOutOfRangeException(Ctxt(FmtX( + throw except::IndexOutOfRangeException(Ctxt(str::Format( "Index out of range: (%d <= %d <= %d)", 0, i, num))); return make_ComponentInfo(getNativeOrThrow()->dataExtensionInfo, i); } @@ -245,7 +245,7 @@ nitf::ComponentInfo FileHeader::getReservedExtensionInfo(int i) const { int num = getNumReservedExtensions(); if (i < 0 || i >= num) - throw except::IndexOutOfRangeException(Ctxt(FmtX( + throw except::IndexOutOfRangeException(Ctxt(str::Format( "Index out of range: (%d <= %d <= %d)", 0, i, num))); return make_ComponentInfo(getNativeOrThrow()->reservedExtensionInfo, i); } diff --git a/modules/c++/nitf/source/ImageSubheader.cpp b/modules/c++/nitf/source/ImageSubheader.cpp index d45feee514..4e4f48f991 100644 --- a/modules/c++/nitf/source/ImageSubheader.cpp +++ b/modules/c++/nitf/source/ImageSubheader.cpp @@ -80,7 +80,7 @@ void ImageSubheader::setPixelInformation(std::string pvtype, if (!bandInfo) { - throw nitf::NITFException(Ctxt(FmtX("Out of Memory"))); + throw nitf::NITFException(Ctxt("Out of Memory")); } for (size_t i = 0; i < bandCount; i++) diff --git a/modules/c++/nitf/source/TRE.cpp b/modules/c++/nitf/source/TRE.cpp index 9b10e5f095..97f697bb96 100644 --- a/modules/c++/nitf/source/TRE.cpp +++ b/modules/c++/nitf/source/TRE.cpp @@ -96,7 +96,7 @@ nitf::Field TRE::getField(const std::string& key) const nitf_Field* field = ::nitf_TRE_getField(getNativeOrThrow(), key.c_str()); if (!field) throw except::NoSuchKeyException( - Ctxt(FmtX("Field does not exist in TRE: %s", key.c_str()))); + Ctxt(str::Format("Field does not exist in TRE: %s", key))); return nitf::Field(field); } diff --git a/modules/c++/nitf/tests/test_create++.cpp b/modules/c++/nitf/tests/test_create++.cpp index 64be835b37..a64f0868fb 100644 --- a/modules/c++/nitf/tests/test_create++.cpp +++ b/modules/c++/nitf/tests/test_create++.cpp @@ -28,7 +28,7 @@ int main(int argc, char** argv) { if (argc != 2) { - throw nitf::NITFException(Ctxt(FmtX("Usage %s \n", + throw nitf::NITFException(Ctxt(str::Format("Usage %s \n", argv[0]))); } diff --git a/modules/c++/nitf/tests/test_extract.cpp b/modules/c++/nitf/tests/test_extract.cpp index ab72d78bdb..748e2981a0 100644 --- a/modules/c++/nitf/tests/test_extract.cpp +++ b/modules/c++/nitf/tests/test_extract.cpp @@ -44,9 +44,9 @@ static std::vector extract_image(const nitf::ImageSubheader& subhe size_t band = 0; for (const auto& data : bandData) // for band, data in enumerate(bandData): { - auto outName = FmtX("%s_%d__", baseName, index); - outName += FmtX("%d_x_%d_", window.getNumRows(), window.getNumCols()); - outName += FmtX("%d_band_%d.out", static_cast(nbpp), static_cast(band)); + auto outName = str::Format("%s_%d__", baseName, index); + outName += str::Format("%d_x_%d_", window.getNumRows(), window.getNumCols()); + outName += str::Format("%d_band_%d.out", static_cast(nbpp), static_cast(band)); outName = sys::Path::joinPaths(outDir, outName); auto f = fopen(outName.c_str(), "wb"); // f = open(outName, "wb"); nitf::write(f, data); // fwrite(data.data(), sizeof(data[0]), data.size() / sizeof(data[0]), f); diff --git a/modules/c++/nitf/tests/test_fhdr_clone++.cpp b/modules/c++/nitf/tests/test_fhdr_clone++.cpp index 6149cc742c..3e0a3e8e38 100644 --- a/modules/c++/nitf/tests/test_fhdr_clone++.cpp +++ b/modules/c++/nitf/tests/test_fhdr_clone++.cpp @@ -118,7 +118,7 @@ int main(int argc, char** argv) { if (argc != 2) { - throw nitf::NITFException(Ctxt(FmtX("Usage: %s \n", argv[0]))); + throw nitf::NITFException(Ctxt(str::Format("Usage: %s \n", argv[0]))); } nitf::Reader reader; diff --git a/modules/c++/nitf/tests/test_functional.cpp b/modules/c++/nitf/tests/test_functional.cpp index 6f9e9e8450..19413e5437 100644 --- a/modules/c++/nitf/tests/test_functional.cpp +++ b/modules/c++/nitf/tests/test_functional.cpp @@ -34,7 +34,7 @@ int main(int argc, char **argv) { nitf::Reader reader; if ( argc != 2 ) - throw nitf::NITFException(Ctxt(FmtX("Usage: %s \n", argv[0]))); + throw nitf::NITFException(Ctxt(str::Format("Usage: %s \n", argv[0]))); nitf::IOHandle io(argv[1]); nitf::Record record = reader.read(io); diff --git a/modules/c++/nitf/tests/test_j2k_nitf_read_region.cpp b/modules/c++/nitf/tests/test_j2k_nitf_read_region.cpp index d1ab434621..e219c8293b 100644 --- a/modules/c++/nitf/tests/test_j2k_nitf_read_region.cpp +++ b/modules/c++/nitf/tests/test_j2k_nitf_read_region.cpp @@ -47,8 +47,8 @@ void writeFile(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, std::span buf, const std::string& prefix) { - auto filename = FmtX("%s-raw-", prefix); - filename += FmtX("%d_%d__%d_%d.out", x0, y0, x1, y1); + auto filename = str::Format("%s-raw-", prefix); + filename += str::Format("%d_%d__%d_%d.out", x0, y0, x1, y1); nitf::IOHandle outHandle(filename, NRT_ACCESS_WRITEONLY, NRT_CREATE); outHandle.write(buf.data(), buf.size()); printf("Wrote file: %s\n", filename.c_str()); @@ -58,8 +58,8 @@ void writeJ2K(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, std::span buf, const j2k::Container& inContainer, const std::string& prefix) { - auto outName = FmtX("%s-raw-", prefix); - outName += FmtX("%d_%d__%d_%d.j2k", x0, y0, x1, y1); + auto outName = str::Format("%s-raw-", prefix); + outName += str::Format("%d_%d__%d_%d.j2k", x0, y0, x1, y1); const auto num_x_tiles = inContainer.getTilesX(); const auto num_y_tiles = inContainer.getTilesY(); @@ -217,7 +217,7 @@ int main(int argc, char **argv) const auto result_ = j2kReader.readRegion(0, 0, width, height, buf); const std::span result(result_.data(), result_.size()); - const auto namePrefix = FmtX("image-%d", (i + 1)); + const auto namePrefix = str::Format("image-%d", (i + 1)); // TODO: Update write to only output tiles in read region writeFile(0, 0, width, height, result, namePrefix); writeJ2K(0, 0, width, height, result, container, namePrefix); diff --git a/modules/c++/nitf/tests/test_read_acftb.cpp b/modules/c++/nitf/tests/test_read_acftb.cpp index a91ece7697..fcd4309712 100644 --- a/modules/c++/nitf/tests/test_read_acftb.cpp +++ b/modules/c++/nitf/tests/test_read_acftb.cpp @@ -83,7 +83,7 @@ int main(int argc, char** argv) nitf::Reader reader; if (argc != 2) { - throw nitf::NITFException(Ctxt(FmtX("Usage: %s \n", + throw nitf::NITFException(Ctxt(str::Format("Usage: %s \n", argv[0]))); } nitf::IOHandle io(argv[1]); diff --git a/modules/c++/nitf/unittests/test_j2k_loading++.cpp b/modules/c++/nitf/unittests/test_j2k_loading++.cpp index fccc42361c..6e878d5184 100644 --- a/modules/c++/nitf/unittests/test_j2k_loading++.cpp +++ b/modules/c++/nitf/unittests/test_j2k_loading++.cpp @@ -168,8 +168,8 @@ TEST_CASE(test_j2k_nitf) void writeFile(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, std::span buf, const std::string& prefix) { - auto filename = FmtX("%s-raw-", prefix); - filename += FmtX("%d_%d__%d_%d.out", x0, y0, x1, y1); + auto filename = str::Format("%s-raw-", prefix); + filename += str::Format("%d_%d__%d_%d.out", x0, y0, x1, y1); nitf::IOHandle outHandle(filename, NRT_ACCESS_WRITEONLY, NRT_CREATE); outHandle.write(buf.data(), buf.size()); //printf("Wrote file: %s\n", filename.c_str()); @@ -178,8 +178,8 @@ void writeJ2K(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, std::span buf, const j2k::Container& inContainer, const std::string& prefix) { - auto outName = FmtX("%s-raw-", prefix); - outName += FmtX("%d_%d__%d_%d.j2k", x0, y0, x1, y1); + auto outName = str::Format("%s-raw-", prefix); + outName += str::Format("%d_%d__%d_%d.j2k", x0, y0, x1, y1); const auto num_x_tiles = inContainer.getTilesX(); const auto num_y_tiles = inContainer.getTilesY(); @@ -273,7 +273,7 @@ void test_j2k_nitf_read_region_(const std::string& testName, const auto result_ = j2kReader.readRegion(0, 0, width, height, buf); const auto result = sys::make_const_span(result_); - const auto namePrefix = FmtX("image-%d", (i + 1)); + const auto namePrefix = str::Format("image-%d", (i + 1)); // TODO: Update write to only output tiles in read region writeFile(0, 0, width, height, result, namePrefix); writeJ2K(0, 0, width, height, result, container, namePrefix);