From 01f6954c71ab2f8327aa00531489d4738cb44e0c Mon Sep 17 00:00:00 2001 From: "J. Daniel Smith" Date: Mon, 9 Oct 2023 13:41:00 -0400 Subject: [PATCH] latest from CODA-OSS and NITRO (#703) * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from e87c32b4d..168cbae01 168cbae01 reduce differences between 'main' and 'cpp17' (#724) 5b892bf5f release 2023-08-18 (#723) 0b1327d1e restore mem::AutoPtr; too much of a hassle moving it to numpyutils :-( (#722) 7691adb56 normalize line endings (#721) b7d50efdd update to HDF5 1.14.2 (#720) fcc96ec69 Update .gitattributes (#719) bb82a94c9 xerces-c 3.2.4 (#718) ef4ad7cf3 Update to e2fsprogs 1.47.0 (#717) b4ca18a11 fix compiler warning about order of operations a5df5b823 update to HighFive 2.7.1 (#716) 4109ee5d2 `mem::AutoPtr` is only for Python bindings (#715) 00d843f87 remove hdf5.lite (#714) 443dd3825 Reduce compiler warnings, speed up builds (#713) d60861821 get optional working with partial C++17 (#712) d5bd0d804 "warning STL4036: is removed in C++20." c19ece7f9 Don't interfere with a partial C++20 implementation (#711) 065e86ddc operator==() for QName (#710) 1c16380ce remove zint* typedefs; don't want to encourage use of types::Complex (#709) 6dd247991 our optional<> is now closer to C++17 (#708) 87ac61739 strict checking on `std::complex` is too much of a hassle for now 034d52c86 overloads to byte-swap type::Complex are too much trouble (#707) 42d449c33 sys::byteSwap overloads for types::Complex (#705) 4092fd8e7 remove work-around for NITRO bug (#704) e2472acfc build in NITRO and SIX (#703) 32ccf9105 Use same build paths as Visual Studio (#701) 366ac9f43 Another round of removing compiler warnings (#702) a7f8ef260 Fix compile warnings from building CODA (#700) f70b4202f account for coda-oss.vcxproj being in other SLNs af3faebfc Remove more compiler/code-analysis warnings (#699) 82be2a6db unittests should work w/o install (#698) dbb90a06d add msbuild for coda-oss.sln (#697) 5a417140a reduce compiler warnings (#696) 288619dfa all modules now part of coda-oss.vcxproj (#695) c2fc5fc66 add more projects to coda-oss-lite.vcxproj (#694) ceb86c186 support $(PlatformToolset) as a "special" environment variable (#693) d78a8595a OS::getSIMDInstructionSet() utility (#692) 2d2df467d fix `python3 waf dumplib` 54033e70e Merge branch 'main' into feature/complex_short 3c63f9f65 std::numbers from C++20 (#691) 892dd0e00 ComplexInteger and ComplexReal to better match existing naming conventions (#690) b3872181e match coda-oss naming conventions (#688) 704d6867f beef-up our complex type (#687) 47c1c1cd6 check is_absolute() for URLs (#686) c042373e1 be sure our Path::isAbolute() matches std::filesystem::path::absolute() (#684) ad10286bc volatile is about "special" memory, not threading (#685) f4d42005f fix build error in NITRO ff11a5557 keep using std::complex for now (#682) c88b9c053 types::complex (#681) d1244a080 don't need our own make_unique in C++14 (#680) aeec0131c assert()s for mem::CopyablePtr (#679) 72b0ebd60 add types::complex_short (#678) 932130a58 patch to build other projects c00c1f203 coda-oss release 2023-06-06 (#677) ef54bbcd5 remove more compiler warnings (#676) dadfc5ce6 distinguish between byte-swapping a buffer and single value (#674) 90187f6cd more xml.lite tweaks for SIDD-3.0/ISM (#675) eb9960772 stronger type-checking for byteSwap() (#673) ff4f820ed xml.lite tweaks to support SIDD 3.0 ISM (#672) b1de8c0e5 std::byte should be a unique type (#671) c05bf9a02 allow enums to be byte-swapped too 1f9fd88d6 remove spurious 47684c45b byteSwap now uses byte buffers (#670) cbc659db2 add swapBytes() utility from SIX (#669) 891481b64 simplify byte-swapping (#668) 540ae763e more byteSwap() tweaks 0774c03c4 threaded byteSwap() (#667) d156370d3 swapping a single-byte value makes no sense c120e3255 be sure parameter is used to avoid compiler warning e85ec9331 --output-on-failure for CTest (#666) e80376197 turn off "there is no warning number" warning c5f0a5d15 A C-string may not be NULL-terminated (#665) 0c5eb29ae use platform-specific routines for byteSwap() (#664) 0b7d581fa remove transform_async() (#663) f6489b6be Merge branch 'main' into feature/xml.lite_tweaks 836c426a2 use function-pointers so that isConsoleOutput is only checked once 56e3c45b1 move depthPrint() functionality into non-member function in preparation for future changes ddcd26d97 Merge branch 'main' into feature/xml.lite_tweaks 69cc0e506 use the more rigorous create_and_check_datatype() 9efb87558 Merge branch 'main' into feature/hdf5 4d2f2f417 more HighFive unittests (#662) 14191a844 HighFive::create_datatype() goes from C++ to HighFive 98583473f utility routines to read string attributes 1fa75ce81 use the C API to read a string attribute 71e7b69f5 still can't figure out how to read a string attribute :-( e96f37a69 test reading the file attributes a25244519 getAttribute() unittest 8f12a3000 getDataType() unittest 857ff0af3 HighFive utility routines (#661) 1d687db57 writeDataSet() utility overload 106aa6894 sigh ... H5Easy::dump() fill fails on Windows/WAF :-( 2641b60b2 Merge branch 'main' into feature/hdf5 35c19e7e8 change actions to @v3 (#660) 212bbd3a3 works on local machine, but not build server ... ? 7125118b0 dump of 1D vector doesn't work :-( c704db435 sigh ... WAF build still failing :-( 01aae4616 does dump() of a 1D vector work? 76a53c813 comment-out H5 writing :-( 0f0e19aff test_highfive_dump() cb8f73795 trying to get highfive_dump() unittest working w/Windows-WAF 6584a264a does test_highfive_create() work? cde6147ce tweak HighFive wrappers (#659) 316566854 Revert "trying HighFive "write" unittests again" a9ec24ca4 trying HighFive "write" unittests again 585ad49a5 tweak names of utility routines 4c91a4d97 make it easier to read a std::vector and std::vecotr 0217ffa26 readDataSet() now works for 1D data 95e8973f2 trying to get hdf5::lite::load() working 4d294611d "const" correctness 5e6305c3f fix load_complex() 4a134dc5f start work on utility routines to read complex data from HDF5 9d76a7f41 Merge branch 'main' into feature/hdf5 8f9667a24 whitepsace ebd3fc99e Merge branch 'main' into feature/hdf5 40091b069 comment-out writing tests for now ... need to figure our WAF bulid failure 935aa3459 be sure the dataset has real data 114b9bf33 update release notes bd9c0b26c tweak HighFive utility routines acda1ef57 turn off diagnostics around expected failures 22a748840 readDataSet() utility routine for HighFive bd88a8c25 HighFive writeDataSet() utility to work with our SpanRC 6142f5b33 use HighFive routines to write a HDF5 file 5bbf1abaf Use HiveFive routines to get info about the file 84fbc8378 duplicate unittests with H5Easy f1f054c03 Merge branch 'main' into feature/hdf5 9b63ca470 fix directory names f6f826689 fix directory names 7aeb82c33 Merge branch 'main' into feature/hdf5 d028baaeb hook up HighFive header-only library (#653) 3083b0a31 Revert "HighFive 2.6.2" 246985a7f Revert ""build" HighFive HDF5 library" a8b75a586 Revert "turn off HighFive Boost support" ec68d5f83 Revert "Add HighFive unittests" f1f85b9e7 Revert "get test_high_five_base more-or-less compiling" 5ea634ee1 Revert "more work on getting HighFive unittests to build" ecc45433c more work on getting HighFive unittests to build bb194788a get test_high_five_base more-or-less compiling d42bde000 Add HighFive unittests ddc86bb32 turn off HighFive Boost support b255122d4 "build" HighFive HDF5 library 396cc3ef2 HighFive 2.6.2 5e5f9d9c0 Merge branch 'main' into feature/hdf5 ee938b4a5 changes from SIX bb764df90 Merge branch 'main' into feature/xml.lite_tweaks de2a24380 make derived classes 'final' if possible 14e19bcd2 Change xml lite function to virtual (#645) 8f42ac8e9 Merge branch 'main' into feature/xml.lite_tweaks 18ad90645 hdf5Write unittest 3462e1179 createFile() and writeFile() overloads ecee81d53 fix typos 197eecfa6 sketch-out hdf5::lite::writeFile() bd2311795 use SpanRC for writeFile(), not yet implemented ea9af7510 simple SpanRC to hold a 2D-size and pointer 027c19ee8 createFile() unittest 1f9d07ecb hook up createFile() 8c7e4473f start hooking up HDF5 writing 146e0bea3 Merge branch 'main' into feature/hdf5 88ca9fcb7 Merge branch 'main' into feature/hdf5 42b604b46 Squashed commit of the following: 10ee602c2 Merge branch 'main' into feature/hdf5 67aa42b69 restore changes from "main" 8bbfcbfbf unittests can be simplified to match fewer "view" classes 126bb802e Merge branch 'main' into feature/hdf5 3f8ba7a42 again, don't need a class just to convert from std::vector<> to std::span<> 24c2b489c Squashed commit of the following: 2703c119d Squashed commit of the following: 9d5228a2b don't need an entire class just to convert a std::vector<> into std::span<> 51bc931dc Merge branch 'main' into feature/hdf5 a84f25816 Squashed commit of the following: c4d2ed696 add missing #include guards, fix type in existing #include guard d541525a0 use a single ComplexViewConstIterator for all views 86e6a459f CODA_OSS_disable_warning causes GCC errors :-( 5d4b9c2cb only need an custom iterator for ComplexSpansView d9f0fb128 hook up iterators b9329e4db initial pass at a ComplexViewConstIterator 635238873 remove compiler warning about unused "constexpr" variables b39f6096f use the casing from H5 to make copy/pasting code slightly easier 0887b13eb Merge branch 'main' into feature/hdf5 bd07df1ca Consistent casing for Dataset, Datatype, Dataspace 7acd30ee2 tweak hdf5.lite dependencies 38ab914df Jupyter notebook for creating H5 files 95a040e0b _small.h5 is now (correctly) FLOAT32 107e7c487 make a simple values() member function to avoid template magic e1feca919 use TEST_SPECIFIC_EXCEPTION macro instead of try/catch 738333688 readDatasetT() now throws for the wrong buffer type 6b2cc2529 Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 310f8fd3d can't get template magic right for copy_axis() 86b306d59 stepping through copy ctors in the debugger is annoying f243e92d6 trying to make wrong type of buffer fail 2b10d9652 read in new sample file a28e59d8c help the compiler with type deduction 49bf5e9bc nested_complex_float_data_small.h5 e029325fc utility routines to "deconstruct" and array of std::complex dede3bd39 Merge branch 'main' into feature/hdf5 904b1ef5e tweak class names, make_() and copy() utility routines 8237b9efb make it harder to pass the wrong types to ComplexViews 4d9aeda2c ComplexArrayView and ComplexParallelView utility classes f5e367dfa test std::span> a4a2844f2 read in the nested "i" and "r" data 115615265 sample file has subgroups 8e1b7869a Merge branch 'feature/hdf5' of github.com:mdaus/coda-oss into feature/hdf5 9f4232a1d update sample H5 file 8c55db73a walk through HDF5 sub-groups 7775ed9c4 Update 123_barfoo_catdog_cx.h5 677975d7c Matlab code to create sample H5 file a0e7dfe07 Update test_hdf5info.cpp 0b67e1602 pass __FILE__ and __LINE__ from calling site for a more accurate exception message 86a677321 skeleton for more sample data 85f79b099 Merge branch 'main' into feature/hdf5 18088e942 Merge branch 'main' into feature/hdf5 3a1d17692 Merge branch 'main' into feature/hdf5 1755c69d7 Merge branch 'main' into feature/hdf5 9ad015432 No more "11" suffix on exception names c20d96251 Squashed commit of the following: c88cee999 other values to be filled-in bca4a4ecd incorporation NamedObject from HDF5 docs 61fa68f72 groupInfo() 460e7d766 datasetInfo() 14eb9b764 start filling in DatasetInfo afe5f1c3a start to fill in DatasetInfo 77a968c72 start filling in GroupInfo d81bcdfd9 openGroup() to open groups (loc) a0cd29469 comment-out "dataset" unittest for now 86e006024 begin filling in FileInfo 366dda6ab a return_type_of utility is needed to deduce the return type e21928263 explicitly pass return type to template 4937ccd11 template to reduce boilerplate when calling try_catch_H5Exceptions b3b5ebde7 use new exception utility routines ea1c03ef0 put exception handling/conversion in a utility routine 819a99d39 utility routine for exception handling 6f34eea97 put utilities in a separate file for easier reuse fcbde4f24 break utility routines into smaller pieces for easier reuse 52358ea8a WIN32 no longer automatically defined? 5a4286472 Revert "build HDF5 with C89" 680e599e9 build HDF5 with C89 a87a07121 Merge branch 'main' into feature/hdf5 8447c1a90 Revert "sym-links instead of copying files" db3b5e12b Merge branch 'main' into feature/xml.lite_tweaks fb60b5696 Merge branch 'main' into feature/hdf5 5110a5cc8 Comments about _u and _q 1a937d32c Merge branch 'main' into feature/xml.lite_tweaks fa06f04d7 get ready for hdf5.lite enhancdements b040c7c43 sym-links instead of copying files aa431bb47 use _u for xml::lite::Uri 3d0c6d58c fix case-sensitive #include filename 93dcd0e52 operator() for getElementByName() 75a93af85 more operator[] overloads to make attribute management easier 4ab8216f8 user-defined string literals to remove some noise around xml::lite::QName f82f0b0fc Merge branch 'main' into feature/xml.lite_tweaks ae30e3644 Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks ffdd9beb0 simplify attribute creation 9bf5414f5 simplify attribute creation 82d7a4e95 SWIG gets confused about namespaces 7a61d0741 fix bug on Element ctor uncovered by unittest fdd7e58c1 QName is also in the xerces namespace which confuses SWIG bindings a325b7053 operator+=() overload for addChild daf30e6c0 Merge branch 'feature/xml.lite_tweaks' of github.com:mdaus/coda-oss into feature/xml.lite_tweaks b887d2b47 provide overloads for Element& rather than creating new "reference" types 1fa6bba38 rename test_xmleasy.cpp 7c8c9e0f1 += overload 850da6f63 overload for std::string 4547fc5a7 use UIT-8 strings for characterData 4723462a3 convenient addChild() overloads e48720753 copy over ElementReference from xml.easy a4ca30a0d Merge branch 'main' into feature/xml.lite_tweaks 6ae9f0b71 Revert "check-in of new xml.easy (to move code between computers)" f7466a6d7 Revert "simple routines for single element" a5490230d Revert "make some operators simplier ways of calling functions" c9a25630a Revert "get document creation working" 8af8710b0 Revert "free functions instead of member functions" 16c3847cb Revert "ElementReference distinct from Element" 7d68e156f Revert "ElementMutableReference" 00eb2a282 Merge branch 'main' into feature/xml.lite_tweaks a42969c1f ElementMutableReference a20ae9355 ElementReference distinct from Element 14eeeea0b free functions instead of member functions 4aae014b3 get document creation working 883569269 make some operators simplier ways of calling functions 053bd1212 simple routines for single element 8bf701a2e check-in of new xml.easy (to move code between computers) 41f959051 unittests for creating XML documents from scratch 9752d50ae Merge branch 'main' into feature/xml.lite_tweaks 1531d5709 by default, don't validate strings passed to Uri() 46d13d4bf Merge branch 'master' into feature/xml.lite_tweaks 39b547d32 remove more vestiges of Expat and LibXML ec8274d52 remove LibXML and Expat as they're no longer used/supported. 20eeefeef Merge branch 'master' into feature/xml.lite_tweaks 95074b9b1 update for newer Intel compiler 7024f71e1 Merge branch 'master' into feature/xml.lite_tweaks 57b1cbc83 Merge branch 'master' into feature/xml.lite_tweaks 4b67561c3 remove validate() overload that nobody is using fa15f1e5d Squashed commit of the following: 1484a9090 test the new validate() API 470da70fb hookup StringStreamT routines 2cddf2504 begin hooking up validate() overloads 1b5d910f3 overload validate() for UTF-8 and Windows-1252 03309b8c9 Squashed commit of the following: b72c6c5bf older compiler doesn't like our make_unique af8f00307 validate UTF-8 XML on Linux 211188613 unit-test for LEGACY XML validation 3c1169d2b Squashed commit of the following: 3afff19ca std::filesystem::path for FileInputStreamOS 908d452f8 WIP: validate all of our sample XML files 00f9bb16b validate against a XML schema 243d8c356 Merge branch 'master' into feature/xml.lite_tweaks 2815d707d fix to work with SWIG bindings. :-( 460862132 trying (again) to remove vestiages of old code e3c83a858 Revert "new code should use UTF-8" 811207c92 new code should use UTF-8 0ffd835f9 Squashed commit of the following: 1e7e03ded Merge branch 'master' into feature/xml.lite_tweaks c1d806aff Merge branch 'master' into feature/xml.lite_tweaks 850d3c811 str::strip() that can be easier to use than str::trim() 580ba9c8c explicitly =delete move 2b39831a8 Squashed commit of the following: 39eebdc23 Merge branch 'master' into feature/xml.lite_tweaks 9adf86cba force calling new UTF-8 write() routines ea61b6204 Merge branch 'master' into feature/xml.lite_tweaks 8a34583fa overload to take schemaPaths as filesystem::path 8671b442f parse XML embedded in a binary file ec4a902f1 updates from xerces.lite 80dc4d963 updates from xerces.lite 549766d6c Attributes::contains() no longer catches an exception 8a645ceac need "sys/" when building in other environments 36af08269 super-simple URI validation 78ef28a3e SWIG bindings are a PITA! :-( e9cba8491 SWIG needs help with Uri 8a8d8dc07 another routines used by pre-build SWIG bindings 818e1ec5d pre-build SWIG bindings use getElementByTagName() member function 067cac5d8 old compiler gets confused on unadorned QName ba92c0ae7 more use of Uri and QName 446c7d17a use QName in new code d6f8b0c83 more direct use of QName 90fff1c73 use xml::lite::QName instead of tuple 646cbb5ed more direct use of QName and Uri ba589ea3b make QName more robust bab0ee8b5 createElement() -> addNewElement() e3a145747 grab changes from six-library 32285e95c Merge branch 'master' into feature/xml.lite_tweaks 9f79f0bf6 Merge branch 'master' into feature/xml.lite_tweaks a12bbc32c make it easier to create new Elements with a value fc9967f98 make it easy for callers to addChild() keep a reference to the Element 4627766b7 be sure test_xmlparser works in "externals" of other projects bf2276396 "private" is part of the name-mangling fad92bcc8 making sure copy-ctor is implemented f90fdcead consolidate common XML test code 9fc53f2d5 use str:: utility for casting 6da6f794b still trying to find the right macro for SWIG 0c1b86c56 still trying to fix SWIG fdc6fc9bd trying to fix SWIG build error 7835e8c27 SWIG needs copy-ctor 585695942 disable copy/assignment for Element, it's probably almost always wrong 391fed613 fix double-delete caused by copying 61790fe69 retry parsing XML with Windows-1252 if first parse() fails 63cffac59 change string_encoding to match coda-oss style of PascalCase 010479bbe read an XML file we know is wrongly encoded as Windows-1252 9a0505062 more references instead of pointers 2d44b6951 Reading Windows-1252 w/o "encoding" fails 63dc7b076 read Windows-1252 too c9434c9cb test as UIT-8 too f310ccf0c get reading from UTF-8 XML working on Windows 1fa39c2be get testReadUtf8XmlFile working on Linux 1a83cd815 sys::Path is too much trouble right now ed60aa22c unit-test to read XML from a file a9336db7c Squashed commit of the following: 0825beb0d Merge branch 'master' into feature/xml.lite_tweaks c618489be Merge branch 'master' into feature/xml.lite_tweaks e8e4b8fe1 determine string_encoding based on platform 1f43bcfc2 create a new Element by using the platform to determine "characterData" encoding 961bef66b Merge branch 'master' into feature/xml.lite_tweaks e9798a5cb fix static_assert() 6f7772874 Merge branch 'master' into feature/xml.lite_tweaks b98d4f5a9 Merge branch 'master' into feature/xml.lite_tweaks 1b5abba2a The (old) version of SWIG we're using doesn't like certain C++11 features. 53bdeabaf Merge branch 'master' into feature/xml.lite_tweaks 60cf8ae80 "" doesn't work with decltype() in older C++ 97e72477a reduce getValue() overloads by making "key" a template argument 5e6373e55 reduce code duplication f9e7cfeee provide castValue instead of getValue(T&) cbd0bd8f2 castValue throws instead of returning a bool like getValue(T&) 87c7514fc Merge branch 'master' into feature/xml.lite_tweaks 10cc61223 make getElement*() consistent for zero or >1 results f5b137e3c Merge branch 'master' into feature/xml.lite_tweaks 1765efc62 allow clients to specify toType() and toString() for getValue() and setValue() df8b746e1 allow clients to specify their own toType/toString routines 66702726a Merge branch 'master' into feature/xml.lite_tweaks 6956311f1 Merge branch 'master' into feature/xml.lite_tweaks d505f3593 Merge branch 'master' into feature/xml.lite_tweaks fbd106115 catch a BadCastException and return false from getValue() 3a78377b5 use a template to reduce duplicated code 0ad4b8606 Merge branch 'master' into feature/xml.lite_tweaks a848aa3a2 get & set the characer data as a type f3ee1ee12 utility routines to set an attribute value 595227683 templates to get an attribute value convert to a specific type 06639227b miised a change in last commit 1aa458ef8 add getValue() overloads that return true/false rather than throwing faa6d3075 added getElementByTagName() overloads as that's a very common use-case git-subtree-dir: externals/coda-oss git-subtree-split: 168cbae01bb1e5fc0a02c2d96e8b02619bf2831d * Squashed 'externals/nitro/' changes from c8ecbe9ae..547d0aa9f 547d0aa9f NITRO-2.11.4 (#575) fe309c4ba Merge branch 'main' of github.com:mdaus/nitro 10efa9990 latest from CODA-OSS (#574) d08f1c0a1 CRLF db5d3d484 latest from CODA-OSS 98c755048 CRLF aa1482543 CRLF bfdbe69a4 Latest from CODA-OSS (#573) 9e4ce0b58 latest from CODA-OSS (#572) 227a8a8f4 trust coda-oss for right -std flags 13869687e latest from CODA-OSS (#571) 5724d8c18 latest from CODA-OSS (#570) fb794f0fe latest from CODA-OSS (#569) 7a6132ba0 update files changes in cpp17 branch (#568) de91d4977 Fix bug creating NITFException (#567) 225273436 fix YAML for 'main' 5d1c83d11 single project for unittests (#566) 102a019db latest from CODA-OSS (known broken build) (#565) b4ae2d429 match YAML from coda-oss 176bcaf6d build NITRO.SLN using msbuild (#562) 85e9043b8 latest from CODA-OSS (#561) 49ec50325 use new "PlatformToolkit" special environment variable (#560) 6c06e3711 latest from CODA-OSS (#559) cee9feb42 latest from CODA-OSS (#558) 3f01809fa latest from coda-oss (#557) 471fb3fc1 Update test_j2k_loading++.cpp b12caf2fc latest from CODA-OSS (#556) 0cd432624 use sys::make_span (#555) 05dae18a3 patch to build other projects 8f974e995 NITRO-2.11.3 (#554) 870aa6afd update to coda-oss 2023-06-05 (#553) 2fd7a0bfa latest from coda-oss (#552) 0eecce004 invoke() utility to reduce code duplication (#550) 59fb02fe9 latest from coda-oss (#551) 9fbf2b7b8 Fill out adapter free block which is used for nitf decompression (#549) 089ba0b5b latest from coda-oss 3b52f0025 latest from coda-oss (#547) 90c6263e2 latest from coda-oss (#544) 90d513ac5 latest from coda-oss (#543) git-subtree-dir: externals/nitro git-subtree-split: 547d0aa9ffcf34ad94f9ea71aa415f39837b2e68 * CRLF * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from 168cbae01..22e050207 22e050207 utility routines to reduce duplicated code (#726) a5ea60647 remove str::EncodedStringView (#725) git-subtree-dir: externals/coda-oss git-subtree-split: 22e05020768d791498db105c261439dc78981445 * Squashed 'externals/nitro/' changes from 547d0aa9f..e7ea728ec e7ea728ec reduce differences between cpp17 and main branches (#576) git-subtree-dir: externals/nitro git-subtree-split: e7ea728ec6c80eb3a7564f9c721563c49d744c51 * str::format changes from CODA-OSS * latest from CODA-OSS * Squashed 'externals/coda-oss/' changes from 22e050207..bf7ae4a71 bf7ae4a71 use overloads rather than varargs for std::format() (#727) git-subtree-dir: externals/coda-oss git-subtree-split: bf7ae4a718bd97a55ed37d2dd0a514deebc97776 * Squashed 'externals/nitro/' changes from e7ea728ec..fc1f59799 fc1f59799 latest from CODA-OSS (#578) 02e8f80c6 latest from CODA-OSS (#577) git-subtree-dir: externals/nitro git-subtree-split: fc1f59799a3082a3c1605dd9a6c3dd12ce2412d3 * toString() changes from CODA-OSS * Squashed 'externals/coda-oss/' changes from bf7ae4a71..8dee6f7a6 8dee6f7a6 revert toString() changes (#728) git-subtree-dir: externals/coda-oss git-subtree-split: 8dee6f7a68d560f8bb3469f2d0375bb65e2f532f * Squashed 'externals/nitro/' changes from fc1f59799..72209535d 72209535d toString() changes from CODA-OSS (#579) git-subtree-dir: externals/nitro git-subtree-split: 72209535d071d6a6f18c475413f948d086cd8787 * Squashed 'externals/nitro/' changes from 72209535d..e488297c3 e488297c3 Merge commit '81ea6f1789863f26f06dc447f7784383dc7cb595' 81ea6f178 Squashed 'externals/coda-oss/' changes from e87c32b4de..8dee6f7a68 git-subtree-dir: externals/nitro git-subtree-split: e488297c31fbf52dd2c1ae6ba94f95a6cdf9eb30 * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from 8dee6f7a6..00e2dd928 00e2dd928 another FmtX() overload 165a799c5 more FmtX() overloads (#729) git-subtree-dir: externals/coda-oss git-subtree-split: 00e2dd9286b44e32f8393165f20485b543d52170 * Squashed 'externals/nitro/' changes from e488297c3..72cd86cbf 72cd86cbf latest from CODA-OSS (#580) e4920a743 FmtX() -> str::Format() git-subtree-dir: externals/nitro git-subtree-split: 72cd86cbf6abb1122350388c98ea448484d76d91 * latest from CODA-OSS * latest from NITRO * Squashed 'externals/coda-oss/' changes from 00e2dd928..333b91024 333b91024 Squashed commit of the following: ac8c312db Only allow va_args formatting under controlled circumstances (#735) 589aacfd7 str::to_native() for when conversion to std::string really is needed 743feb41e try hard not to lose string encoding (#734) 1854a9b46 hide use of str::cast() inside `details` namespace (#733) fbe0c85f9 compile-time getSIMDInstructionSet() (#732) ee2c46358 more consistent naming for routines to convert between encodings (#731) git-subtree-dir: externals/coda-oss git-subtree-split: 333b9102479d3d2c7d41425dbcfa41a7eabf7b1d * Squashed 'externals/nitro/' changes from 72cd86cbf..49f6338d2 49f6338d2 latest from CODA-OSS (#581) git-subtree-dir: externals/nitro git-subtree-split: 49f6338d2998fc6b4d033bf1456f1fb1bcb53567 * build after CODA-OSS updates * Squashed 'externals/coda-oss/' changes from 333b91024..c92a55d7c c92a55d7c build in SIX git-subtree-dir: externals/coda-oss git-subtree-split: c92a55d7c788ec177b094284572b227a40a8fcd7 * Squashed 'externals/nitro/' changes from 49f6338d2..e418beceb e418beceb Merge commit '6144b2cfb436a5696bab62c81651b47edf07aa8c' 6144b2cfb Squashed 'externals/coda-oss/' changes from 8dee6f7a68..c92a55d7c7 32d9c4fe4 latest from CODA-OSS git-subtree-dir: externals/nitro git-subtree-split: e418beceb503c1186119ea058211f1e5b493afc6 * latest from CODA-OSS * Squashed 'externals/coda-oss/' changes from c92a55d7c..369737085 369737085 use std::ssize() to reduce casts (#738) 8ae7dabac std::size() and std::ssize() (#737) 8db480be5 enable ASAN for GitHub builds (#736) git-subtree-dir: externals/coda-oss git-subtree-split: 369737085573989ba74a68a4dc2da9d4be8be3a6 * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from 369737085..95ff879ba 95ff879ba make it easier to turn on AVX2/AVX512F (#740) a950c848b enable AVX2 and AVX512F CMake builds (#739) git-subtree-dir: externals/coda-oss git-subtree-split: 95ff879babba421c57ece442c3324c98d68fdbc7 * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from 95ff879ba..959532681 959532681 reduce use of FmtX macro (#743) fffac7fc4 Fix memory leaks in "cli" (#741) git-subtree-dir: externals/coda-oss git-subtree-split: 95953268198a05486cd86cc17ac085805362c6ec * Squashed 'externals/nitro/' changes from e418beceb..edfa0f7ce edfa0f7ce latest from CODA-OSS (#585) b26e15318 latest from CODA-OSS (#583) 0db9bdb29 fix ASAN diagnostics (#582) git-subtree-dir: externals/nitro git-subtree-split: edfa0f7ce5951b09967bb92ec4aba4820d50561f * Squashed 'externals/nitro/' changes from edfa0f7ce..574bfe2b6 574bfe2b6 FmtX() -> str::Format() (#586) git-subtree-dir: externals/nitro git-subtree-split: 574bfe2b6c79955be16427ddf4f115b0333a05b9 --- .../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 +- .../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 +- .../c++/logging/include/logging/Enums.h | 6 +- .../c++/math.poly/include/math/poly/Fixed1D.h | 4 +- .../c++/net.ssl/source/SSLConnection.cpp | 10 +- .../source/SSLConnectionClientFactory.cpp | 4 +- .../modules/c++/net/source/DaemonUnix.cpp | 4 +- .../modules/c++/net/source/Socket.cpp | 2 +- .../include/plugin/BasicPluginManager.h | 6 +- .../sio.lite/include/sio/lite/SioFileWriter.h | 2 +- .../modules/c++/str/include/str/Format.h | 141 +++++++++--------- .../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 +- .../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 +- .../c++/xml.lite/source/Attributes.cpp | 6 +- .../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 +- .../c++/nitf/source/ImageSubheader.cpp | 2 +- .../nitro/modules/c++/nitf/source/TRE.cpp | 2 +- .../modules/c++/nitf/tests/test_create++.cpp | 2 +- .../modules/c++/nitf/tests/test_extract.cpp | 6 +- .../c++/nitf/tests/test_fhdr_clone++.cpp | 2 +- .../c++/nitf/tests/test_functional.cpp | 2 +- .../nitf/tests/test_j2k_nitf_read_region.cpp | 10 +- .../c++/nitf/tests/test_read_acftb.cpp | 2 +- .../c++/nitf/unittests/test_j2k_loading++.cpp | 10 +- 43 files changed, 241 insertions(+), 231 deletions(-) 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++/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++/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++/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/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++/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++/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++/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++/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++/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/externals/nitro/modules/c++/nitf/include/nitf/NITFException.hpp b/externals/nitro/modules/c++/nitf/include/nitf/NITFException.hpp index 46b9bac5bf..6c91837d71 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/NITFException.hpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/include/nitf/Object.hpp b/externals/nitro/modules/c++/nitf/include/nitf/Object.hpp index 035995bfc5..815943483e 100644 --- a/externals/nitro/modules/c++/nitf/include/nitf/Object.hpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/source/FileHeader.cpp b/externals/nitro/modules/c++/nitf/source/FileHeader.cpp index d5facc2f87..73dc5d3572 100644 --- a/externals/nitro/modules/c++/nitf/source/FileHeader.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/source/ImageSubheader.cpp b/externals/nitro/modules/c++/nitf/source/ImageSubheader.cpp index d45feee514..4e4f48f991 100644 --- a/externals/nitro/modules/c++/nitf/source/ImageSubheader.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/source/TRE.cpp b/externals/nitro/modules/c++/nitf/source/TRE.cpp index 9b10e5f095..97f697bb96 100644 --- a/externals/nitro/modules/c++/nitf/source/TRE.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/tests/test_create++.cpp b/externals/nitro/modules/c++/nitf/tests/test_create++.cpp index 64be835b37..a64f0868fb 100644 --- a/externals/nitro/modules/c++/nitf/tests/test_create++.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/tests/test_extract.cpp b/externals/nitro/modules/c++/nitf/tests/test_extract.cpp index ab72d78bdb..748e2981a0 100644 --- a/externals/nitro/modules/c++/nitf/tests/test_extract.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/tests/test_fhdr_clone++.cpp b/externals/nitro/modules/c++/nitf/tests/test_fhdr_clone++.cpp index 6149cc742c..3e0a3e8e38 100644 --- a/externals/nitro/modules/c++/nitf/tests/test_fhdr_clone++.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/tests/test_functional.cpp b/externals/nitro/modules/c++/nitf/tests/test_functional.cpp index 6f9e9e8450..19413e5437 100644 --- a/externals/nitro/modules/c++/nitf/tests/test_functional.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/tests/test_j2k_nitf_read_region.cpp b/externals/nitro/modules/c++/nitf/tests/test_j2k_nitf_read_region.cpp index d1ab434621..e219c8293b 100644 --- a/externals/nitro/modules/c++/nitf/tests/test_j2k_nitf_read_region.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/tests/test_read_acftb.cpp b/externals/nitro/modules/c++/nitf/tests/test_read_acftb.cpp index a91ece7697..fcd4309712 100644 --- a/externals/nitro/modules/c++/nitf/tests/test_read_acftb.cpp +++ b/externals/nitro/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/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp b/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp index fccc42361c..6e878d5184 100644 --- a/externals/nitro/modules/c++/nitf/unittests/test_j2k_loading++.cpp +++ b/externals/nitro/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);