From 32bafebb6d9e15a8c347587a067a723beef956e6 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Wed, 6 Dec 2023 11:26:38 -0500 Subject: [PATCH 1/3] get rid of class '...' needs to have dll-interface to be used by clients of struct '...' --- six/modules/c++/cpp_pch.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/six/modules/c++/cpp_pch.h b/six/modules/c++/cpp_pch.h index cb76151d1..993895289 100644 --- a/six/modules/c++/cpp_pch.h +++ b/six/modules/c++/cpp_pch.h @@ -1,5 +1,11 @@ #pragma once +// Needs to be outside of `#pragma warning(push)` +#pragma warning(suppress: 4193) // #pragma warning(pop): no matching '...' +#pragma warning(pop) +#pragma warning(disable: 4251) // '...' : class '...' needs to have dll-interface to be used by clients of struct '...' +#pragma warning(push) + #pragma warning(push) #pragma warning(disable: 5039) // '...': pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception. #pragma warning(disable: 5219) // implicit conversion from '...' to '...', possible loss of data From 16da687c4a1db85adf027f712978d6c5d9a9ffeb Mon Sep 17 00:00:00 2001 From: "J. Daniel Smith" Date: Mon, 11 Dec 2023 12:52:54 -0500 Subject: [PATCH 2/3] latest from CODA-OSS and NITRO (#726) * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from e87c32b4d..03f1a3bdf 03f1a3bdf release 2023-10-23 (#747) 4dd7b2fbd Merge branch 'main' of github.com:mdaus/coda-oss 9428f12a0 add extensions for .log and known Windows/Linux binaries (#746) c3fd20a88 added some OLD Visual Studio extensions d00db384a everything is text except for known binaries c3813bb29 eol=lf is the default 4a2f472c7 add extensions for .log and known Windows/Linux binaries (#746) 18f2c051f more FmtX() -> str::Format() changes (#745) 959532681 reduce use of FmtX macro (#743) fffac7fc4 Fix memory leaks in "cli" (#741) 95ff879ba make it easier to turn on AVX2/AVX512F (#740) a950c848b enable AVX2 and AVX512F CMake builds (#739) 369737085 use std::ssize() to reduce casts (#738) 8ae7dabac std::size() and std::ssize() (#737) 8db480be5 enable ASAN for GitHub builds (#736) c92a55d7c build in SIX 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) 00e2dd928 another FmtX() overload 165a799c5 more FmtX() overloads (#729) 8dee6f7a6 revert toString() changes (#728) bf7ae4a71 use overloads rather than varargs for std::format() (#727) 22e050207 utility routines to reduce duplicated code (#726) a5ea60647 remove str::EncodedStringView (#725) 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: 03f1a3bdfa72d1baf84625fb6bcf9467e5792ace * Squashed 'externals/nitro/' changes from c8ecbe9ae..0357b1432 0357b1432 NITRO-2.11.5 (#589) a0ad6f943 CODA-OSS 2023-10-23 (#588) 1b631e578 latest from CODA-OSS (#587) 574bfe2b6 FmtX() -> str::Format() (#586) edfa0f7ce latest from CODA-OSS (#585) b26e15318 latest from CODA-OSS (#583) 0db9bdb29 fix ASAN diagnostics (#582) e418beceb Merge commit '6144b2cfb436a5696bab62c81651b47edf07aa8c' 6144b2cfb Squashed 'externals/coda-oss/' changes from 8dee6f7a68..c92a55d7c7 32d9c4fe4 latest from CODA-OSS 49f6338d2 latest from CODA-OSS (#581) 72cd86cbf latest from CODA-OSS (#580) e4920a743 FmtX() -> str::Format() 81ea6f178 Squashed 'externals/coda-oss/' changes from e87c32b4de..8dee6f7a68 e488297c3 Merge commit '81ea6f1789863f26f06dc447f7784383dc7cb595' 72209535d toString() changes from CODA-OSS (#579) fc1f59799 latest from CODA-OSS (#578) 02e8f80c6 latest from CODA-OSS (#577) e7ea728ec reduce differences between cpp17 and main branches (#576) 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: 0357b143293bc7b1ce5d5d941f1a5e6564b319a9 * latest from CODA-OSS * Squashed 'externals/coda-oss/' changes from 03f1a3bdf..3ae8f6afb 3ae8f6afb Merge pull request #751 from mdaus/bugfix/hdf5-missing-files-main 3ec510861 Add missing files 1693eac7e Update build_unittest.yml git-subtree-dir: externals/coda-oss git-subtree-split: 3ae8f6afb3816bbb2ca9a72fbbd9ef78644eb5bf * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from 3ae8f6afb..92f8b88c7 92f8b88c7 std::ostringstream overloads 8cb27de27 reduce use of .c_str() and .str() (#752) git-subtree-dir: externals/coda-oss git-subtree-split: 92f8b88c758504e8d0d2a3dfb389b71d49b557e5 * Squashed 'externals/nitro/' changes from 0357b1432..0342b596a 0342b596a latest from CODA-OSS (#592) 0084f9bf7 reduce use of .str() (#591) 253f57b2b latest from CODA-OSS (#590) d6bc1d83a disable code-analysis to fix Github builds 981e75116 Update main.yml 907bf91cd Update frequent_check.yml git-subtree-dir: externals/nitro git-subtree-split: 0342b596aa3b4e1809086e4676d3e49fd8ccd261 * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from 92f8b88c7..aea8e7b1e aea8e7b1e reduce use of str::toString() (#754) 8062154a4 HighFive 2,8,0 (#753) git-subtree-dir: externals/coda-oss git-subtree-split: aea8e7b1ee845039a62fafca207a4df6e8df15e0 * Squashed 'externals/nitro/' changes from 0342b596a..a37046807 a37046807 latest from CODA-OSS (#596) 205bf8e36 infrastructure for "preloading" TREs (#593) git-subtree-dir: externals/nitro git-subtree-split: a37046807ab36de5268e1247e901e704e3f1e81e * return type needs to be explicit for subsequent specialization * latest from CODA-OSS and NITRO * Squashed 'externals/coda-oss/' changes from aea8e7b1e..5eae4c1f6 5eae4c1f6 turn of /Wall for MSVC (#755) 47d4b6b73 return type needs to be explicit (not `auto`) for subsequent specialization git-subtree-dir: externals/coda-oss git-subtree-split: 5eae4c1f6e3d2ba64bb78cd63ec0b525f7f6d98a * Squashed 'externals/nitro/' changes from a37046807..de4686af0 de4686af0 improve TRE unitesting (#599) a4d0a5130 remove /Wall from MSVC (#598) b97c4a867 disable pre-loaded TREs (#597) 1075b4ecd be sure the string is properly padded for the field type git-subtree-dir: externals/nitro git-subtree-split: de4686af03ed60f9881d4fbea876a84d6f202d46 * Squashed 'externals/coda-oss/' changes from 5eae4c1f6..df4e0fc1f df4e0fc1f changes to build SIX DLLs (#757) faf5d0521 allow CMake to switch between building SHARED (DLLs) or STATIC libraires d15173f38 export symbols used by NITRO (#756) 6ed3c048b use Debug DLL library in Debug git-subtree-dir: externals/coda-oss git-subtree-split: df4e0fc1f6c564c02121d1328e850ed92552bfc1 * Squashed 'externals/nitro/' changes from de4686af0..dc3a8ecf0 dc3a8ecf0 export more symbols (#604) 22f11f42b build as a DLL in Visual Studio (#603) 8d8184c27 NITRO can now build DLLs (#602) d3f58f038 added environment variable to enable pre-loading of TREs (#601) 85a113021 Merge branch 'main' of https://github.com/mdaus/nitro a1cec9cf6 Merge branch 'main' of https://github.com/mdaus/nitro 6801fa735 Merge branch 'main' of https://github.com/mdaus/nitro eca918471 /guard:cf 5d540334b /guard:cf git-subtree-dir: externals/nitro git-subtree-split: dc3a8ecf0e5e13c23ec1f2294c323d0bbd222e2a * latest from CODA-OSS * Squashed 'externals/coda-oss/' changes from df4e0fc1f..28926b673 28926b673 provide our own (simple) mdspan implementation (#759) 6bb722454 make SpanRC API match std::mdspan (#758) git-subtree-dir: externals/coda-oss git-subtree-split: 28926b673931c3f148882ceca7d3de203accfa4e * Squashed 'externals/nitro/' changes from dc3a8ecf0..3de4c5059 3de4c5059 latest from CODA-OSS (#605) git-subtree-dir: externals/nitro git-subtree-split: 3de4c5059eaf7d1ba2ccd1c16c7bc84efd3f028e * latest from NITRO * Squashed 'externals/nitro/' changes from 3de4c5059..09f2f458f 09f2f458f use $(SolutionDir) to get to externals git-subtree-dir: externals/nitro git-subtree-split: 09f2f458fe16fcaa6dd5f6c025b91a1ca657abe4 * latest from CODA-OSS * Squashed 'externals/coda-oss/' changes from 28926b673..ed283d676 ed283d676 Only need to actually create/destroy Xerces once (#761) 8087b1e11 utility routines to convert to/from collections of paths a869c8a8e use a lookup table for str::upper() and str::lower() (#760) 00e343177 Merge branch 'main' of https://github.com/mdaus/coda-oss 27085f06b DefaultErrorHandler is a base class 98ec79835 favor speed over size git-subtree-dir: externals/coda-oss git-subtree-split: ed283d676654023f2ea58fd7b6385fa30c03b08a * Squashed 'externals/nitro/' changes from 09f2f458f..847101014 847101014 latest from CODA-OSS (#606) git-subtree-dir: externals/nitro git-subtree-split: 8471010142ae5f85f596f2cf1737c8aa5d89c7fa --- externals/coda-oss/UnitTest/UnitTest.vcxproj | 3 +- .../modules/c++/logging/source/Setup.cpp | 3 +- .../c++/plugin/include/plugin/ErrorHandler.h | 2 +- .../modules/c++/str/include/str/Manip.h | 68 ++++++++- .../modules/c++/str/source/Encoding.cpp | 89 ++++++----- .../coda-oss/modules/c++/str/source/Manip.cpp | 140 ++++++++++++++++-- .../c++/str/unittests/test_base_convert.cpp | 31 ++-- .../modules/c++/str/unittests/test_str.cpp | 70 ++++++++- .../modules/c++/sys/include/sys/Path.h | 14 +- .../modules/c++/sys/source/AbstractOS.cpp | 19 +-- .../modules/c++/sys/source/DateTime.cpp | 20 +-- .../modules/c++/sys/source/FileFinder.cpp | 15 +- .../coda-oss/modules/c++/sys/source/Path.cpp | 17 +++ .../include/xml/lite/UtilitiesXerces.h | 14 +- .../include/xml/lite/ValidatorXerces.h | 14 +- .../include/xml/lite/XMLReaderXerces.h | 2 +- .../c++/xml.lite/source/UtilitiesXerces.cpp | 39 ++++- .../c++/xml.lite/source/ValidatorXerces.cpp | 29 ++-- .../c++/xml.lite/unittests/test_xmlparser.cpp | 4 +- 19 files changed, 426 insertions(+), 167 deletions(-) diff --git a/externals/coda-oss/UnitTest/UnitTest.vcxproj b/externals/coda-oss/UnitTest/UnitTest.vcxproj index 020ee7b39..d79dab6f9 100644 --- a/externals/coda-oss/UnitTest/UnitTest.vcxproj +++ b/externals/coda-oss/UnitTest/UnitTest.vcxproj @@ -23,7 +23,6 @@ DynamicLibrary true v143 - false Unicode @@ -31,7 +30,6 @@ false v143 true - false Unicode @@ -97,6 +95,7 @@ true /Zc:__cplusplus %(AdditionalOptions) AdvancedVectorExtensions2 + Speed Windows diff --git a/externals/coda-oss/modules/c++/logging/source/Setup.cpp b/externals/coda-oss/modules/c++/logging/source/Setup.cpp index 3c1c36363..345c6b516 100644 --- a/externals/coda-oss/modules/c++/logging/source/Setup.cpp +++ b/externals/coda-oss/modules/c++/logging/source/Setup.cpp @@ -53,8 +53,7 @@ logging::setupLogger(const path& program_, // setup logging formatter std::unique_ptr formatter; const auto logFile = logFile_.string(); - auto file = logFile; - str::lower(file); + const auto file = str::lower(logFile); if (str::endsWith(file, ".xml")) { formatter.reset( diff --git a/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h b/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h index 234e6c5a1..248b61f46 100644 --- a/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h +++ b/externals/coda-oss/modules/c++/plugin/include/plugin/ErrorHandler.h @@ -49,7 +49,7 @@ class CODA_OSS_API ErrorHandler virtual void onPluginError(except::Context& c) = 0; }; -class CODA_OSS_API DefaultErrorHandler final : public ErrorHandler +class CODA_OSS_API DefaultErrorHandler : public ErrorHandler { public: DefaultErrorHandler(logging::LoggerPtr logger = logging::LoggerPtr()); diff --git a/externals/coda-oss/modules/c++/str/include/str/Manip.h b/externals/coda-oss/modules/c++/str/include/str/Manip.h index 0b48673a5..c9c96eb60 100644 --- a/externals/coda-oss/modules/c++/str/include/str/Manip.h +++ b/externals/coda-oss/modules/c++/str/include/str/Manip.h @@ -1,4 +1,4 @@ -/* ========================================================================= +/* ========================================================================= * This file is part of str-c++ * ========================================================================= * @@ -34,6 +34,7 @@ #include "coda_oss/CPlusPlus.h" #include "coda_oss/string.h" #include "str/Convert.h" +#include "str/W1252string.h" namespace str { @@ -177,10 +178,71 @@ CODA_OSS_API std::vector split(const std::string& s, const std::string& splitter = " ", size_t maxSplit = std::string::npos); +/***********************************************************************************/ //! Uses std::transform to convert all chars to lower case //! Uses std::transform to convert all chars to upper case -CODA_OSS_API void lower(std::string& s); -CODA_OSS_API void upper(std::string& s); +//CODA_OSS_API void lower(std::string& s); +//CODA_OSS_API void upper(std::string& s); +// +// Using std::transform() with ::toupper() is considerably slower than a lookup-table +CODA_OSS_API void ascii_lower(std::string& s); +inline void lower(std::string& s) +{ + ascii_lower(s); +} +inline std::string lower(const std::string& s) +{ + std::string retval = s; + lower(retval); + return retval; +} + +CODA_OSS_API void ascii_upper(std::string& s); +inline void upper(std::string& s) +{ + ascii_upper(s); +} +inline std::string upper(const std::string& s) +{ + std::string retval = s; + upper(retval); + return retval; +} + +// At this point, you might want to `lower()` and `upper()` for UTF-8 and/or +// Windows-1252. That can be done, but ... our needs are mostly English (99.9%) +// with a very occassional smattering of French (Canada). We've gotten by this +// long without being able to upper/lower 'ä' and 'Ä' and there's no current +// requirement to do so. +// +// Furthermore, while Windows-1252 is easy as it's a single-byte encoding and +// covers many european languages, the standard is UTF-8. +// Upper/lower-casing in Unicode is quite a bit more complicated as there can be +// numerous rules for various languages. For example, in German, the "old +// rules" where that 'ß' was uppercased to "SS"; however, there is now a 'ẞ'. +// And then there are semantics: in German, no word can begin with 'ß' (or 'ẞ') +// making "ßanything" rather non-sensical. +// +// So for now (until there is a real use case), just "define these problems +// away" by not implementing `w1252_lower()`, `utf8_upper()`, etc. +/* +CODA_OSS_API void w1252_lower(std::string& s); +CODA_OSS_API void w1252_upper(std::string& s); +CODA_OSS_API void lower(str::W1252string& s); +CODA_OSS_API void upper(str::W1252string& s); + +CODA_OSS_API void utf8_lower(std::string& s); +CODA_OSS_API void utf8_upper(std::string& s); +CODA_OSS_API void lower(coda_oss::u8string& s); +CODA_OSS_API void upper(coda_oss::u8string& s); +*/ + +// I've already got these hooked up, keep the code around ... long ugly +// names to discourage use. +CODA_OSS_API str::Windows1252_T to_w1252_upper(str::Windows1252_T); +CODA_OSS_API str::Windows1252_T to_w1252_lower(str::Windows1252_T); + +/***********************************************************************************/ /*! * Replaces any characters that are invalid in XML (&, <, >, ', ") with their diff --git a/externals/coda-oss/modules/c++/str/source/Encoding.cpp b/externals/coda-oss/modules/c++/str/source/Encoding.cpp index eacc016d8..80603dae9 100644 --- a/externals/coda-oss/modules/c++/str/source/Encoding.cpp +++ b/externals/coda-oss/modules/c++/str/source/Encoding.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "gsl/gsl.h" #include "config/compiler_extensions.h" @@ -65,59 +66,58 @@ CODA_OSS_disable_warning_pop // Need to look up characters from \x80 (EURO SIGN) to \x9F (LATIN CAPITAL LETTER Y WITH DIAERESIS) // in a map: http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/WINDOWS/CP1252.TXT -inline coda_oss::u8string utf8_(uint32_t i) +inline coda_oss::u8string utf8_(char32_t i) { const auto ch = gsl::narrow(i); return str::to_u8string(std::u32string{ch}); } -static const auto& Windows1252_x80_x9F_to_u8string() -{ - static const std::map retval { - {0x80, utf8_(0x20AC) } // EURO SIGN - // , {0x81, replacement_character } // UNDEFINED - , {0x82, utf8_(0x201A) } // SINGLE LOW-9 QUOTATION MARK - , {0x83, utf8_(0x0192) } // LATIN SMALL LETTER F WITH HOOK - , {0x84, utf8_(0x201E) } // DOUBLE LOW-9 QUOTATION MARK - , {0x85, utf8_(0x2026) } // HORIZONTAL ELLIPSIS - , {0x86, utf8_(0x2020) } // DAGGER - , {0x87, utf8_(0x2021) } // DOUBLE DAGGER - , {0x88, utf8_(0x02C6) } // MODIFIER LETTER CIRCUMFLEX ACCENT - , {0x89, utf8_(0x2030) } // PER MILLE SIGN - , {0x8A, utf8_(0x0160) } // LATIN CAPITAL LETTER S WITH CARON - , {0x8B, utf8_(0x2039) } // SINGLE LEFT-POINTING ANGLE QUOTATION MARK - , {0x8C, utf8_(0x0152) } // LATIN CAPITAL LIGATURE OE - //, {0x8D, replacement_character } // UNDEFINED - , {0x8E, utf8_(0x017D) } // LATIN CAPITAL LETTER Z WITH CARON - //, {0x8F, replacement_character } // UNDEFINED - //, {0x90, replacement_character } // UNDEFINED - , {0x91, utf8_(0x2018) } // LEFT SINGLE QUOTATION MARK - , {0x92, utf8_(0x2019) } // RIGHT SINGLE QUOTATION MARK - , {0x93, utf8_(0x201C) } // LEFT DOUBLE QUOTATION MARK - , {0x94, utf8_(0x201D) } // RIGHT DOUBLE QUOTATION MARK - , {0x95, utf8_(0x2022) } // BULLET - , {0x96, utf8_(0x2013) } // EN DASH - , {0x97, utf8_(0x2014) } // EM DASH - , {0x98, utf8_(0x02DC) } // SMALL TILDE - , {0x99, utf8_(0x2122) } // TRADE MARK SIGN - , {0x9A, utf8_(0x0161) } // LATIN SMALL LETTER S WITH CARON - , {0x9B, utf8_(0x203A) } // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - , {0x9C, utf8_(0x0153) } // LATIN SMALL LIGATURE OE - //, {0x9D, replacement_character } // UNDEFINED - , {0x9E, utf8_(0x017E) } // LATIN SMALL LETTER Z WITH CARON - , {0x9F, utf8_(0x0178) } // LATIN CAPITAL LETTER Y WITH DIAERESIS +static const auto& Windows1252_x80_x9F_to_u8string_() +{ + static const std::map retval{ + {U'\x80', utf8_(U'\x20AC')} // EURO SIGN + // , {U'\x81, replacement_character } // UNDEFINED + , {U'\x82', utf8_(U'\x201A') } // SINGLE LOW-9 QUOTATION MARK + , {U'\x83', utf8_(U'\x0192') } // LATIN SMALL LETTER F WITH HOOK + , {U'\x84', utf8_(U'\x201E') } // DOUBLE LOW-9 QUOTATION MARK + , {U'\x85', utf8_(U'\x2026') } // HORIZONTAL ELLIPSIS + , {U'\x86', utf8_(U'\x2020') } // DAGGER + , {U'\x87', utf8_(U'\x2021') } // DOUBLE DAGGER + , {U'\x88', utf8_(U'\x02C6') } // MODIFIER LETTER CIRCUMFLEX ACCENT + , {U'\x89', utf8_(U'\x2030') } // PER MILLE SIGN + , {U'\x8A', utf8_(U'\x0160') } // LATIN CAPITAL LETTER S WITH CARON + , {U'\x8B', utf8_(U'\x2039') } // SINGLE LEFT-POINTING ANGLE QUOTATION MARK + , {U'\x8C', utf8_(U'\x0152') } // LATIN CAPITAL LIGATURE OE + //, {U'\x8D, replacement_character } // UNDEFINED + , {U'\x8E', utf8_(U'\x017D') } // LATIN CAPITAL LETTER Z WITH CARON + //, {U'\x8F, replacement_character } // UNDEFINED + //, {U'\x90, replacement_character } // UNDEFINED + , {U'\x91', utf8_(U'\x2018') } // LEFT SINGLE QUOTATION MARK + , {U'\x92', utf8_(U'\x2019') } // RIGHT SINGLE QUOTATION MARK + , {U'\x93', utf8_(U'\x201C') } // LEFT DOUBLE QUOTATION MARK + , {U'\x94', utf8_(U'\x201D') } // RIGHT DOUBLE QUOTATION MARK + , {U'\x95', utf8_(U'\x2022') } // BULLET + , {U'\x96', utf8_(U'\x2013') } // EN DASH + , {U'\x97', utf8_(U'\x2014') } // EM DASH + , {U'\x98', utf8_(U'\x02DC') } // SMALL TILDE + , {U'\x99', utf8_(U'\x2122') } // TRADE MARK SIGN + , {U'\x9A', utf8_(U'\x0161') } // LATIN SMALL LETTER S WITH CARON + , {U'\x9B', utf8_(U'\x203A') } // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + , {U'\x9C', utf8_(U'\x0153') } // LATIN SMALL LIGATURE OE + //, {U'\x9D, replacement_character } // UNDEFINED + , {U'\x9E', utf8_(U'\x017E') } // LATIN SMALL LETTER Z WITH CARON + , {U'\x9F', utf8_(U'\x0178') } // LATIN CAPITAL LETTER Y WITH DIAERESIS }; return retval; } - static auto Windows1252_to_u8string() { - auto retval = Windows1252_x80_x9F_to_u8string(); + auto retval = Windows1252_x80_x9F_to_u8string_(); // Add the ISO8859-1 values to the map too. 1) We're already looking // in the map anyway for Windows-1252 characters. 2) Need map // entires for conversion from UTF-8 to Windows-1252. - for (std::u32string::value_type ch = 0xA0; ch <= 0xff; ch++) + for (char32_t ch = U'\xA0'; ch <= U'\xff'; ch++) { // ISO8859-1 can be converted to UTF-8 with bit-twiddling @@ -186,7 +186,14 @@ static void fromWindows1252_(str::W1252string::value_type ch, std::basic_string< // If the input text contains a character that isn't defined in Windows-1252; return a // "replacement character." Yes, this will **corrupt** the input data as information is lost: // https://en.wikipedia.org/wiki/Specials_(Unicode_block)#Replacement_character - static const coda_oss::u8string replacement_character = utf8_(0xfffd); + // + // Or ... https://en.wikipedia.org/wiki/Windows-1252 + // > According to the information on Microsoft's and the Unicode + // > Consortium's websites, positions 81, 8D, 8F, 90, and 9D are + // > unused; however, the Windows API `MultiByteToWideChar` maps these + // > to the corresponding C1 control codes. The "best fit" mapping + // > documents this behavior, too. + static const coda_oss::u8string replacement_character = utf8_(U'\xfffd'); append(result, replacement_character); } else @@ -229,7 +236,7 @@ inline void w1252to32(str::W1252string::const_pointer p, size_t sz, std::u32stri } template -std::map kv_to_vk(const std::map& kv) +auto kv_to_vk(const std::map& kv) { std::map retval; for (const auto& p : kv) diff --git a/externals/coda-oss/modules/c++/str/source/Manip.cpp b/externals/coda-oss/modules/c++/str/source/Manip.cpp index f8dbce7db..1d6bae1c2 100644 --- a/externals/coda-oss/modules/c++/str/source/Manip.cpp +++ b/externals/coda-oss/modules/c++/str/source/Manip.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include "gsl/gsl.h" @@ -40,7 +41,7 @@ namespace { -char transformCheck(int c, int (*transform)(int)) +inline char transformCheck(int c, int (*transform)(int)) { // Ensure the character can be represented // as an unsigned char or is 'EOF', as the @@ -56,12 +57,12 @@ char transformCheck(int c, int (*transform)(int)) } } -char tolowerCheck(char c) +inline char tolowerCheck(char c) { return transformCheck(c, tolower); } -char toupperCheck(char c) +inline char toupperCheck(char c) { return transformCheck(c, toupper); } @@ -239,9 +240,8 @@ bool isAlphanumeric(const std::string& s) bool isAsciiPrintable(const std::string& s) { - for (const auto& ch : s) + for (const auto& c : s) { - char c = ch; if (c < 32 || c > 126) return false; } @@ -290,24 +290,136 @@ std::vector split(const std::string& s, return vec; } -template -inline void transform(std::basic_string& s, Fn f) + +// Calling ::toupper() can be slow as the CRT might check for locales. +// Since we only have 256 values, a lookup table is very fast and doesn't +// use much memory. +static const auto& make_lookup(std::array& result, + char (*to)(char)) +{ + // For each of 256 values, record the corresponding tolower/toupper value; + // this makes converting very fast as no checking or arithmetic must be done. + for (size_t i = 0; i <= 0xff; i++) + { + const auto ch = to(static_cast(i)); + result[i] = static_cast(ch); + } + return result; +} + +template +static void do_lookup(std::basic_string& s, const std::array& lookup) { - (void) std::transform(s.begin(), s.end(), s.begin(), f); + for (auto& ch : s) + { + const auto i = static_cast(ch); + ch = static_cast(lookup[i]); + } } -void lower(std::string& s) + +void ascii_upper(std::string& s) { - transform(s, tolowerCheck); + static std::array lookup_; + static const auto& lookup = make_lookup(lookup_, toupperCheck); + do_lookup(s, lookup); +} + +void ascii_lower(std::string& s) +{ + static std::array lookup_; + static const auto& lookup = make_lookup(lookup_, tolowerCheck); + do_lookup(s, lookup); +} + +inline char to_w1252_upper_(char ch) +{ + if ((ch >= 'a') && (ch <= 'z')) + { + return ch ^ 0x20; // ('a' - 'A'); + } + + // See chart at: https://en.wikipedia.org/wiki/Windows-1252 + constexpr uint8_t s_with_caron = 0x9a /* */; + constexpr uint8_t oe = 0x9c /* */; + constexpr uint8_t z_with_caron = 0x9e /* */; + constexpr uint8_t a_with_grave = 0xe0 /* */; + constexpr uint8_t o_with_diaeresis = 0xf6 /* */; + constexpr uint8_t o_with_slash = 0xf8 /* */; + constexpr uint8_t small_thorn = 0xfe /* */; + constexpr uint8_t y_with_diaeresis = 0xff /* */; + + const auto u8 = static_cast(ch); + if ((u8 == s_with_caron) || (u8 == oe) || (u8 == z_with_caron)) + { + return ch ^ 0x10; + } + if ((u8 >= a_with_grave) && (u8 <= o_with_diaeresis)) + { + return ch ^ 0x20; + } + if ((u8 >= o_with_slash) && (u8 <= small_thorn)) + { + return ch ^ 0x20; + } + if (u8 == y_with_diaeresis) + { + constexpr uint8_t Y_with_diaeresis = 0x9f /* */; + return Y_with_diaeresis; + } + + return ch; +} +str::Windows1252_T to_w1252_upper(str::Windows1252_T ch) +{ + const auto retval = to_w1252_upper_(static_cast(ch)); + return static_cast(retval); +} + +inline char to_w1252_lower_(char ch) +{ + if ((ch >= 'A') && (ch <= 'Z')) + { + return ch | 0x20; + } + + constexpr uint8_t S_with_caron = 0x8a /* */; + constexpr uint8_t OE = 0x8c /* */; + constexpr uint8_t Z_with_caron = 0x8e /* */; + constexpr uint8_t Y_with_diaeresis = 0x9f /* */; + constexpr uint8_t A_with_grave = 0xc0 /* */; + constexpr uint8_t O_with_diaeresis = 0xd6 /* */; + constexpr uint8_t O_with_slash = 0xd8 /* */; + constexpr uint8_t capital_thorn = 0xde /* */; + + const auto u8 = static_cast(ch); + if ((u8 == S_with_caron) || (u8 == OE) || (u8 == Z_with_caron)) + { + return ch | 0x10; + } + if (u8 == Y_with_diaeresis) + { + constexpr uint8_t y_with_diaeresis = 0xff /* */; + return y_with_diaeresis; + } + if ((u8 >= A_with_grave) && (u8 <= O_with_diaeresis)) + { + return ch | 0x20; + } + if ((u8 >= O_with_slash) && (u8 <= capital_thorn)) + { + return ch | 0x20; + } + return ch; } -void upper(std::string& s) +str::Windows1252_T to_w1252_lower(str::Windows1252_T ch) { - transform(s, toupperCheck); + const auto retval = to_w1252_lower_(static_cast(ch)); + return static_cast(retval); } void escapeForXML(std::string& str) { - // & needs to be first or else it'll mess up the other characters that we - // replace + // & needs to be first or else it'll mess up the other characters that we replace replaceAll(str, "&", "&"); replaceAll(str, "<", "<"); replaceAll(str, ">", ">"); diff --git a/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp b/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp index 3b951015a..c2ecf4f36 100644 --- a/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp +++ b/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp @@ -216,21 +216,18 @@ TEST_CASE(test_string_to_u8string_iso8859_1) } } -template -static void test_change_case_(const std::string& testName, const TString& lower, const TString& upper) +template +static void test_change_case_(const std::string& testName, + const std::basic_string& lower, const std::basic_string& upper) { - auto s = upper; - str::lower(s); + auto s = str::lower(upper); TEST_ASSERT(s == lower); - s = lower; - str::upper(s); + s = str::upper(lower); TEST_ASSERT(s == upper); - s = upper; - str::upper(s); + s = str::upper(upper); TEST_ASSERT(s == upper); - s = lower; - str::lower(s); + s = str::lower(lower); TEST_ASSERT(s == lower); } TEST_CASE(test_change_case) @@ -243,14 +240,16 @@ TEST_CASE(test_change_case) //const std::wstring abc_w = L"abc"; //test_change_case_(testName, abc_w, ABC_w); - //// Yes, this can really come up, "non classifi" is French (Canadian) for "unclassified". - //const std::string DEF_1252{'D', '\xc9', 'F'}; // "DF" Windows-1252 - //const auto DEF8 = from_windows1252(DEF_1252); + // Yes, this can really come up, "non classifi" is French (Canadian) for "unclassified". + const std::string DEF_1252_{'D', '\xc9', 'F'}; // "DF" Windows-1252 + const auto DEF_1252 = str::str(DEF_1252_); + const auto DEF8 = str::to_u8string(DEF_1252); - //const std::string def_1252{'d', '\xe9', 'f'}; // "df" Windows-1252 - //const auto def8 = from_windows1252(def_1252); + const std::string def_1252_{'d', '\xe9', 'f'}; // "df" Windows-1252 + const auto def_1252 = str::str(def_1252_); + const auto def8 = str::to_u8string(def_1252); - ////test_change_case_(testName, def, DEF); + //test_change_case_(testName, def8, DEF8); //test_change_case_(testName, def_1252, DEF_1252); } diff --git a/externals/coda-oss/modules/c++/str/unittests/test_str.cpp b/externals/coda-oss/modules/c++/str/unittests/test_str.cpp index 2d00862d8..eb4821608 100644 --- a/externals/coda-oss/modules/c++/str/unittests/test_str.cpp +++ b/externals/coda-oss/modules/c++/str/unittests/test_str.cpp @@ -57,16 +57,78 @@ TEST_CASE(testData) TEST_CASE(testUpper) { - std::string s = "test-something1"; + const std::string s_ = "test-something1"; + std::string s = s_; + TEST_ASSERT(str::eq(s, "TEST-SOMETHING1")); str::upper( s); TEST_ASSERT_EQ(s, "TEST-SOMETHING1"); + + //#if _WIN32 + //s = ""; + //str::w1252_upper(s); + //TEST_ASSERT_EQ(s, ""); + //#endif +} + +TEST_CASE(test_toupper) +{ + for (uint16_t i = 0x20; i <= 0xff; i++) // uint16_t to avoid wrap-around + { + const auto w1252 = static_cast(i); + const auto w1252_upper = str::to_w1252_upper(w1252); + + const auto w1252_lower = w1252 == w1252_upper ? w1252 : str::to_w1252_lower(w1252_upper); // round-trip + TEST_ASSERT_EQ(static_cast(w1252), static_cast(w1252_lower)); + + if (i <= 0x7f) // ASCII + { + const auto ch = static_cast(i); + const auto upper = toupper(ch); + TEST_ASSERT_EQ(static_cast(upper), static_cast(w1252_upper)); + + const auto lower = ch == upper ? ch : tolower(upper); // round-trip + TEST_ASSERT_EQ(ch, lower); + TEST_ASSERT_EQ(static_cast(lower), static_cast(w1252_lower)); + } + } } TEST_CASE(testLower) { - std::string s = "TEST1"; - str::lower( s); + const std::string s_ = "TEST1"; + std::string s = s_; + TEST_ASSERT(str::eq(s, "test1")); + str::lower(s); TEST_ASSERT_EQ(s, "test1"); + + //#if _WIN32 + //s = "[]"; + //str::w1252_lower(s); + //TEST_ASSERT_EQ(s, "[]"); + //#endif +} + +TEST_CASE(test_tolower) +{ + for (uint16_t i = 0x20; i <= 0xff; i++) // uint16_t to avoid wrap-around + { + const auto w1252 = static_cast(i); + const auto w1252_lower = str::to_w1252_lower(w1252); + + const auto w1252_upper = w1252 == w1252_lower ? w1252 : str::to_w1252_upper(w1252_lower); // round-trip + TEST_ASSERT_EQ(static_cast(w1252), static_cast(w1252_upper)); + + if (i <= 0x7f) // ASCII + { + const auto ch = static_cast(i); + const auto lower = tolower(ch); + TEST_ASSERT_EQ(static_cast(lower), static_cast(w1252_lower)); + + const auto upper = ch == lower ? ch : toupper(lower); // round-trip + TEST_ASSERT_EQ(ch, upper); + TEST_ASSERT_EQ(static_cast(upper), static_cast(w1252_upper)); + } + } } TEST_CASE(test_eq_ne) @@ -309,7 +371,9 @@ TEST_MAIN( TEST_CHECK(testTrim); TEST_CHECK(testData); TEST_CHECK(testUpper); + TEST_CHECK(test_toupper); TEST_CHECK(testLower); + TEST_CHECK(test_tolower); TEST_CHECK(test_eq_ne); TEST_CHECK(testReplace); TEST_CHECK(testReplaceAllInfinite); diff --git a/externals/coda-oss/modules/c++/sys/include/sys/Path.h b/externals/coda-oss/modules/c++/sys/include/sys/Path.h index d7d950202..74d78af5c 100644 --- a/externals/coda-oss/modules/c++/sys/include/sys/Path.h +++ b/externals/coda-oss/modules/c++/sys/include/sys/Path.h @@ -27,13 +27,15 @@ #include #include #include +#include #include "config/Exports.h" - #include +#include "coda_oss/span.h" #include "sys/OS.h" #include "sys/filesystem.h" +#include "sys/Span.h" /*! @@ -295,6 +297,16 @@ class CODA_OSS_API Path std::ostream& operator<<(std::ostream& os, const sys::Path& path); std::istream& operator>>(std::istream& os, sys::Path& path); + +// Convert between collections of paths as strings and sys::filesystem::path +CODA_OSS_API std::vector convertPaths(coda_oss::span); +CODA_OSS_API std::vector convertPaths(coda_oss::span); +template +inline auto convertPaths(const std::vector& paths) +{ + return convertPaths(make_span(paths)); +} + } #endif // CODA_OSS_sys_Path_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp b/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp index dd22c3786..436e12bb6 100644 --- a/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp +++ b/externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp @@ -86,29 +86,14 @@ AbstractOS::search(const std::vector& searchPaths, return elementsFound; } -inline auto convert(const std::vector& paths) -{ - std::vector retval; - std::transform(paths.begin(), paths.end(), std::back_inserter(retval), - [](const fs::path& p) { return p.string(); }); - return retval; -} -inline auto convert(const std::vector& paths) -{ - std::vector retval; - std::transform(paths.begin(), paths.end(), std::back_inserter(retval), - [](const auto& p) { return p; }); - return retval; -} - std::vector AbstractOS::search( const std::vector& searchPaths, const std::string& fragment, const std::string& extension, bool recursive) const { - const auto results = search(convert(searchPaths), fragment, extension, recursive); - return convert(results); + const auto results = search(convertPaths(searchPaths), fragment, extension, recursive); + return convertPaths(results); } void AbstractOS::remove(const std::string& path) const diff --git a/externals/coda-oss/modules/c++/sys/source/DateTime.cpp b/externals/coda-oss/modules/c++/sys/source/DateTime.cpp index b6669002d..0679aed62 100644 --- a/externals/coda-oss/modules/c++/sys/source/DateTime.cpp +++ b/externals/coda-oss/modules/c++/sys/source/DateTime.cpp @@ -169,15 +169,13 @@ char* strptime(const char *buf, const char *fmt, struct tm& tm, double& millis) // Full name. len = DAY[i].size(); std::string day(bp, len); - str::lower(day); - if (day == DAY[i]) + if (str::eq(day, DAY[i])) break; // Abbreviated name. len = AB_DAY[i].size(); day = std::string(bp, len); - str::lower(day); - if (day == AB_DAY[i]) + if (str::eq(day, AB_DAY[i])) break; } @@ -202,15 +200,13 @@ char* strptime(const char *buf, const char *fmt, struct tm& tm, double& millis) // Full name. len = MONTH[i].size(); std::string month(bp, len); - str::lower(month); - if (month == MONTH[i]) + if (str::eq(month, MONTH[i])) break; // Abbreviated name. len = AB_MONTH[i].size(); month = std::string(bp, len); - str::lower(month); - if (month == AB_MONTH[i]) + if (str::eq(month, AB_MONTH[i])) break; } @@ -467,9 +463,7 @@ std::string sys::DateTime::dayOfWeekToStringAbbr(int dayOfWeek) int sys::DateTime::monthToValue(const std::string& month) { - std::string m = month; - str::lower(m); - + const auto m = str::lower(month); if (str::startsWith(m, "jan")) return 1; else if (str::startsWith(m, "feb")) @@ -501,9 +495,7 @@ int sys::DateTime::monthToValue(const std::string& month) int sys::DateTime::dayOfWeekToValue(const std::string& dayOfWeek) { - std::string d = dayOfWeek; - str::lower(d); - + const auto d = str::lower(dayOfWeek); if (str::startsWith(d, "sun")) return 1; else if (str::startsWith(d, "mon")) diff --git a/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp b/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp index b33cc47c4..7edf1a512 100644 --- a/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp +++ b/externals/coda-oss/modules/c++/sys/source/FileFinder.cpp @@ -56,12 +56,8 @@ bool sys::FragmentPredicate::operator()(const std::string& entry) const { if (mIgnoreCase) { - std::string base = entry; - str::lower(base); - - std::string match = mFragment; - str::lower(match); - + const auto base = str::lower(entry); + const auto match = str::lower(mFragment); return str::contains(base, match); } else @@ -80,13 +76,10 @@ bool sys::ExtensionPredicate::operator()(const std::string& filename) const if (!sys::FileOnlyPredicate::operator()(filename)) return false; - std::string ext = sys::Path::splitExt(filename).second; + const std::string ext = sys::Path::splitExt(filename).second; if (mIgnoreCase) { - std::string matchExt = mExt; - str::lower(matchExt); - str::lower(ext); - return ext == matchExt; + return str::eq(ext, mExt); } else return ext == mExt; diff --git a/externals/coda-oss/modules/c++/sys/source/Path.cpp b/externals/coda-oss/modules/c++/sys/source/Path.cpp index 4c91e6d18..99233b236 100644 --- a/externals/coda-oss/modules/c++/sys/source/Path.cpp +++ b/externals/coda-oss/modules/c++/sys/source/Path.cpp @@ -22,6 +22,7 @@ #include "sys/Path.h" #include +#include #include namespace fs = coda_oss::filesystem; @@ -849,4 +850,20 @@ std::string Path::expandEnvironmentVariables(const std::string& path, fs::file_t return expandEnvironmentVariables_(path, unused_checkIfExists, &type); } +template +inline auto convertPaths_(coda_oss::span paths, TFunc fun) +{ + std::vector retval; + std::transform(paths.begin(), paths.end(), std::back_inserter(retval), fun); + return retval; +} +std::vector convertPaths(coda_oss::span paths) +{ + return convertPaths_(paths, [](const auto& p) { return p.string(); }); } +std::vector convertPaths(coda_oss::span paths) +{ + return convertPaths_(paths, [](const auto& p) { return p; }); +} + +} \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h index ef2039123..159bbb6ea 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h @@ -29,6 +29,7 @@ #include #include #include +#include #include "config/compiler_extensions.h" #include "config/Exports.h" @@ -409,17 +410,20 @@ struct XercesErrorHandler final : public XercesErrorHandlerInterface_T */ struct CODA_OSS_API XercesContext final { - //! Constructor XercesContext(); - - //! Destructor ~XercesContext(); + XercesContext(const XercesContext&) = delete; + XercesContext& operator=(const XercesContext&) = delete; + XercesContext(XercesContext&&) = delete; + XercesContext& operator=(XercesContext&&) = delete; + void destroy(); private: - static std::mutex mMutex; - bool mIsDestroyed; + struct Impl; + static std::shared_ptr getInstance(); + std::shared_ptr mpImpl; }; } } diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h index 8d5d79ba0..56e9689ae 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h @@ -89,12 +89,8 @@ struct ValidationErrorHandler final : public xercesc::DOMErrorHandler * * This class is the Xercesc schema validator */ -class CODA_OSS_API ValidatorXerces : public ValidatorInterface +struct CODA_OSS_API ValidatorXerces : public ValidatorInterface { - XercesContext mCtxt; //! this must be the first member listed - -public: - /*! * Constructor * \param schemaPaths Vector of both paths and singular schemas @@ -104,10 +100,10 @@ class CODA_OSS_API ValidatorXerces : public ValidatorInterface * input */ ValidatorXerces(const std::vector& schemaPaths, - logging::Logger* log, + logging::Logger* log = nullptr, bool recursive = true); - ValidatorXerces(const std::vector&, // fs::path -> mLegacyStringConversion = false - logging::Logger* log, + ValidatorXerces(const std::vector&, + logging::Logger* log = nullptr, bool recursive = true); ValidatorXerces(const ValidatorXerces&) = delete; @@ -133,6 +129,8 @@ class CODA_OSS_API ValidatorXerces : public ValidatorInterface static std::vector loadSchemas(const std::vector& schemaPaths, bool recursive=true); private: + XercesContext mCtxt; + bool validate_(const coda_oss::u8string& xml, const std::string& xmlID, std::vector& errors) const; diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h index a808be8d8..d40aea202 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h @@ -61,7 +61,7 @@ namespace lite */ class CODA_OSS_API XMLReaderXerces final : public XMLReaderInterface { - XercesContext mCtxt; //! this must be the first member listed + XercesContext mCtxt; std::unique_ptr mNative; std::unique_ptr mDriverContentHandler; std::unique_ptr mErrorHandler; diff --git a/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp b/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp index ffb0f7fd7..943eb5e5f 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp @@ -28,8 +28,6 @@ namespace xml { namespace lite { -std::mutex XercesContext::mMutex; - XercesLocalString::XercesLocalString(XMLCh* xmlStr) : mLocal(xmlStr) { @@ -186,8 +184,16 @@ fatalError(const SAXParseException &exception) throw except::Error(Ctxt(xex.getMessage())); } -XercesContext::XercesContext() : - mIsDestroyed(false) +/*! + * \class XercesContext::Impl + * \brief This class safely creates and destroys Xerces + */ +struct XercesContext::Impl final +{ + static std::mutex mMutex; + bool mIsDestroyed = false; + +Impl() { //! XMLPlatformUtils::Initialize is not thread safe! try @@ -203,7 +209,7 @@ XercesContext::XercesContext() : } } -XercesContext::~XercesContext() +~Impl() { try { @@ -214,7 +220,7 @@ XercesContext::~XercesContext() } } -void XercesContext::destroy() +void destroy() { // wrapping it here saves the mutex lock if (!mIsDestroyed) @@ -235,7 +241,28 @@ void XercesContext::destroy() } } } +}; +std::mutex XercesContext::Impl::mMutex; + +std::shared_ptr XercesContext::getInstance() +{ + // The one and only instance; call XMLPlatformUtils::Initialize() and XMLPlatformUtils::Terminate() just once. + static auto impl = std::make_shared(); + return impl; // increment reference count +} +XercesContext::XercesContext() : mpImpl(getInstance()) // increment reference count +{ +} +XercesContext::~XercesContext() +{ + destroy(); } +void XercesContext::destroy() +{ + mpImpl.reset(); } +} // lite +} // xml + #endif diff --git a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp index 3950d1242..dba996bd9 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp @@ -37,6 +37,7 @@ CODA_OSS_disable_warning(-Wshadow) CODA_OSS_disable_warning_pop #include +#include #include #include @@ -89,26 +90,11 @@ bool ValidationErrorHandler::handleError( return true; } -inline std::vector convert(const std::vector& schemaPaths) -{ - std::vector retval; - std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(retval), - [](const fs::path& p) { return p.string(); }); - return retval; -} -inline auto convert(const std::vector& paths) -{ - std::vector retval; - std::transform(paths.begin(), paths.end(), std::back_inserter(retval), - [](const auto& p) { return p; }); - return retval; -} - ValidatorXerces::ValidatorXerces( const std::vector& schemaPaths, logging::Logger* log, bool recursive) : - ValidatorXerces(convert(schemaPaths), log, recursive) + ValidatorXerces(sys::convertPaths(schemaPaths), log, recursive) { } ValidatorXerces::ValidatorXerces( @@ -169,7 +155,7 @@ ValidatorXerces::ValidatorXerces( // load our schemas -- // search each directory for schemas - const auto schemas = loadSchemas(convert(schemaPaths), recursive); + const auto schemas = loadSchemas(sys::convertPaths(schemaPaths), recursive); // add the schema to the validator // add the schema to the validator @@ -179,9 +165,12 @@ ValidatorXerces::ValidatorXerces( xercesc::Grammar::SchemaGrammarType, true)) { - std::ostringstream oss; - oss << "Error: Failure to load schema " << schema; - log->warn(Ctxt(oss)); + if (log != nullptr) + { + std::ostringstream oss; + oss << "Error: Failure to load schema " << schema; + log->warn(Ctxt(oss)); + } } } diff --git a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp index e35911651..b39f411fb 100644 --- a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp @@ -463,8 +463,8 @@ static void testValidateXmlFile_(const std::string& testName, const std::string& static const auto xsd = find_unittest_file("doc.xsd"); const auto path = find_unittest_file(xmlFile); - const std::vector schemaPaths{xsd.parent_path()}; // fs::path -> new string-conversion code - const xml::lite::Validator validator(schemaPaths, nullptr /*log*/); + const std::vector schemaPaths{xsd.parent_path()}; + const xml::lite::Validator validator(schemaPaths); io::FileInputStream fis(path); std::vector errors; From 938fa48767af89d9947132ee8ee8a79273511244 Mon Sep 17 00:00:00 2001 From: "J. Daniel Smith" Date: Mon, 11 Dec 2023 13:18:58 -0500 Subject: [PATCH 3/3] use sys::convertPaths() utility (#727) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * copy six.sidd to six.sidd30 * six.sidd30 project and unittests * sidd -> sidd30 * more sidd -> sidd30 * more sidd -> sidd30 * begin removing SIDD 3.0 support from six.sidd; it is now (or will be) just in six.sidd30 * remove more SIDD 3.0 unittest code from six.sidd, it's not just in six.sidd30 * remove last? traces of SIDD3.0 from six.sidd * tweaks from feature/ISM * latest from coda-oss and nitro * Squashed 'externals/coda-oss/' changes from 1582c6ac9..aabc5818e aabc5818e remove more C++11 work-arounds (#642) b04ccca17 remove more C++11 work-arounds (#641) e460970a7 increase GCC warnings (#640) 91284249b provide ComplexView iterator support (#639) 453b7ec68 try to get std::make_unique working with old Intel compiler (#638) 5736cfd4d is_trivially_copyable for old Intel compiler (#637) 7c2aea38f use H5 SDK naming conventions (#636) fc3008b8d use 'modern' C pre-processor b44709a95 added ComplexSpansView utility (#635) 986307c9c Merge branch 'master' e1b0fa349 commit (but not build) HDF5 source code (#634) 3fd5ddae5 Merge branch 'main' into develop/remove-cpp11-workarounds 37d7ec76e restore C++14 workarounds for older compilers (#632) 244dfdb3d Merge branch 'develop/main' into develop/remove-cpp11-workarounds 714ca4ed7 restore C++14 workarounds for older compilers 640f2247c Delete hdf5-hdf5-1_13_2.tar.gz eb365cbfb Merge branch 'master' into develop/remove-cpp11-workarounds 57b938eeb don't need __INTEL_COMPILER work-around with C++14 65779f3b1 build C code with -std=gnu99 94dc9280f C++14 work-arounds for an old version of the Intel compiler 3744d05e2 slam-in "main" 82b2fd63b restore some C++14 work-arounds for old compilers that only have partial C++14 support 94f6950a2 Merge branch 'main' into develop/remove-cpp11-workarounds 1ac97fe48 add HDF5 source code (not built) (#612) 8ab982820 Squashed commit of the following: 31781a14a remove C++17 work-arounds c15f6930c Revert " is in C++17" 0fe38c16f restore recent buld.py changes 0c75411ee is in C++17 bbbcd562a remove C++11 work-arounds c1e15e9d9 Merge branch 'main' into main-cpp17 bea818fb0 must use C++17 in this branch 91653a096 another place where C++17 is set 7d555f2be back to C++17 b1969d996 merge main 0792c77bf Merge branch 'main' into develop/remove-cpp11-workarounds e49f273c1 Merge branch 'main' into develop/remove-cpp11-workarounds 240b61044 allow sys::Mutex references, instead of pointers, to be passed to sys::ConditionVar 9500d6f4b Merge branch 'main' into develop/remove-cpp11-workarounds f1529942f std::make_unique instead of new be9b6a71c Squashed commit of the following: 62a2ec4e1 Revert "remove our GSL work-around for C++11" 1db082c21 Revert "try the current "main" of GSL" 44b70edde try the current "main" of GSL 4edbf6bad Revert ""There is no warning 4814"" bcd7458be "There is no warning 4814" c185bf3f1 starting working on MutexCpp11 313bdd1d9 AtomicCounter* files have been removed c1c448051 remove our GSL work-around for C++11 37ae1193e remove our mem::SharedPtr, it's now always std::shared_ptr 71f3c1299 remove no-longer-used NSPR code 8e77cb210 removed no-longer-used Irix and Solaris files fabef6966 use std::atomic for all AtomicCounter implementations ace5b6d5a TEST_FAIL -> TEST_FAIL_MSG 30076c1d1 turns out there was already a TEST_FAIL macro d73ee16fb need "::" to find global test ba01c48df remove C++11 workarounds for C++14 features cbd4a31ae Squashed commit of the following: b21c203b8 Squashed commit of the following: 5b542c60f Squashed commit of the following: cb0cf94ff ByteStream.cpp is now warning-free f5daa37fc cast to DWORD; "const" correctness bfaf644ff #pragma-away compiler warnings from standard headers 72d202dbe Merge branch 'master' into develop/reduce-compiler-warnings b076580cd trying to fix GCC compiler warning 1687dc7fc Merge branch 'master' into develop/reduce-compiler-warnings 2c5db86db Merge branch 'master' into develop/reduce-compiler-warnings 6f76c2e3e Update CMakeLists.txt c3ca4a538 do in-line initialization 8e6733618 remove G++ compiler warning a0eff51cf Merge branch 'master' into develop/reduce-compiler-warnings af19d88a6 Merge branch 'master' into develop/reduce-compiler-warnings ba31cbaa9 use "void*" to avoid reinterpret_cast<> 08da1f8a1 Merge branch 'master' into develop/reduce-compiler-warnings d1d453a2e Merge branch 'master' into develop/reduce-compiler-warnings f5074a996 CODA_OSS_NDEBUG is extra gunk and not used; omit for now. 22de48858 don't even bother compiling our own versions of localtime_s() and gmtime_s() if we're not going to use them (compiler warning about "unused static funtion.") 0c92eba58 tweak NDEBUG/CODA_OSS_NDEBUG; update comments 544604775 Don't need to expose our own versions of localtime_s() and gmtime_s() a050796c1 Merge branch 'develop/reduce-compiler-warnings' of github.com:mdaus/coda-oss into develop/reduce-compiler-warnings fed604617 older compilers want std::string() as argument to std::logic_error() cf2c502a6 do more debug & release builds on GitHub d4aa99256 build some debug targets on Gitlab 368245258 tweak CODA_OSS_DEBUG again for G++ 24ba64f71 tweak how CODA_OSS_DEBUG is set 9680e8f0e add check for _GLIBCXX_DEBUG 943218f83 Merge branch 'master' into develop/reduce-compiler-warnings 01c68e705 %#@*@%)*%@ fix RowCol::cast() again! :-( b8472b457 oops ... gsl::narrow<> should be gsl::narrow_cast<> so that int/double conversion doesn't throw 109255ca8 "final" breaks SWIG; wrap RowCol use of gsl::narrow e51e4c2ad no need to create local just to return e546f2510 Merge branch 'master' into develop/reduce-compiler-warnings d1391f989 use template for to_std_string() overloading 566942680 fix std::char8_t when building with C++20 cf604b1ab fix C++17 build errors 48a0fbedb get rid of coda_oss namespace; use CODA_OSS_cpp17 instead 9706a4336 remove code-analysis diagnostics 50592e4f8 G++ complains about an unneeded call to std::move() 9c7643c3f Merge branch 'master' into develop/reduce-compiler-warnings ecfe1f8a7 more "noexcept" b7ac50fb9 Merge branch 'master' into develop/reduce-compiler-warnings eaecf46ed tweak CODA_OSS_cplusplus from "main" 5773b1ec1 trying to get C++17 WAF build working on Windows a048a00a1 unique names for waf & CMake 7a5a0d5b2 do a better job of setting CODA_OSS_DEBUG 4355aae92 Merge branch 'master' into develop/reduce-compiler-warnings 1fd8cede2 cleanup for VS 2019 16.10 4dffa1394 explicitly =delete copy/assignment df8f8920a Merge branch 'master' into develop/reduce-compiler-warnings 42b4e99b6 remove code-analysis diagnostics 70ce322c9 reduce compiler warnings/code-analysis diagnostics when building six 20eac2f49 Merge branch 'master' into develop/reduce-compiler-warnings ff3ded56d get rid of more compiler warnings/code-analysis diagnostics 669dd51ff Merge branch 'master' into develop/reduce-compiler-warnings 623b65ab9 Merge branch 'master' into develop/reduce-compiler-warnings 11c75df53 fix release build errors 66f048b92 turn on more compiler warnings where possible eb615e315 consolidate calls to mem::make::unique a6f5eb690 reduce use of explicit new 84d5e1b01 use mem::make::unique instead of explicit new 019d726ea = default for default constructors 86ab5d8f3 use std::unique_ptr and "const noexcept" b071972d7 another batch of =default for default constructors 98276da94 more =default for default .ctor()s ceb7bc596 do default constructors with =default 7bed51750 more code-analysis cleanup f9c04b117 "noexcept" code-analysis warnings 6586ae390 need gsl::make_span from gsl/span_ext 722089774 remove gsl/mem dependency cycle d741a0761 use gsl::narrow<> instead of static_cast 99eb4b36e get rid of signed/unsigned mismatch compiler warning 814450522 remove more code-analysis diagnostics c8441b309 Merge branch 'master' into develop/reduce-compiler-warnings e6d70a9ff last of "const" from code-analysis b8445814a mark a few more things as "const" per code-analysis d18544ec7 don't need to create temporary std::strings ee7faa979 still more code-analysis cleanup 5cd6f864d cleanup more code-analysis diagnostics 492fb0a86 one more compiler warning about implicitly deleted copy/assignment b8f782c88 remove compiler warnings about implicitly deleted copy/assignment/move 14d1d1cb8 #pragma-away warnings from GSL 86c40ea6c assert() to prevent some code-analysis diagnostics 7204517a9 make copy/assignment explicit 3ce824079 reduce code-analysis diagnostics 01e367a56 Merge branch 'master' into develop/reduce-compiler-warnings 03f3ddde9 proper printf format 877d7dc93 Merge branch 'master' into develop/reduce-compiler-warnings 5a4a3d575 code-analysis doesn't like C-style casts a3fdae416 code-analysis doesn't like NULL 6309baedc Merge branch 'master' into develop/reduce-compiler-warnings d1194a2fe Merge branch 'master' into develop/reduce-compiler-warnings 535b4757d Merge branch 'develop/reduce-compiler-warnings' of github.com:mdaus/coda-oss into develop/reduce-compiler-warnings a60b95d60 "constexpr" can be hard to get right with older C++11 compilers; don't even try c07b5303e Merge branch 'master' into develop/reduce-compiler-warnings 04306bbee need at least VS2017 to use the real GSL 796ad820b Merge branch 'master' into develop/reduce-compiler-warnings 16c240cd6 Merge branch 'master' into develop/reduce-compiler-warnings e07e89f0c turn on "warnings as errors" for CMAKE builds 5c019f891 complex "constexpr" functions not available with our version of g++ 4ab074a58 fix a few more compiler warnings ... nearing the end! :-) dea7ea41b And still more compiler warnings ... almost done 🤞🏻 fbe3bbb20 remove assorted compiler warnings e60b7fd3c Merge branch 'master' into develop/reduce-compiler-warnings e9df212c6 Arguments should be "const&" to prevent C4866 94e75cbed Merge branch 'master' into develop/reduce-compiler-warnings d3130414a Merge branch 'master' into develop/reduce-compiler-warnings 9a5e71f31 Merge branch 'master' into develop/reduce-compiler-warnings bd27c0232 Merge branch 'master' into develop/reduce-compiler-warnings c053362d2 remove still more compiler warnings 9f133b85a remove some more compiler warnings 0883c729c Merge branch 'master' into develop/reduce-compiler-warnings f4b766880 avoid comparision between signed/unsigned to prevent compiler warning 1e6564a6e eliminate more compiler warnings 85a7b8ad0 remove a few compiler warnings 09c82049f Merge branch 'master' into develop/reduce-compiler-warnings 31f1662fa Merge branch 'master' into develop/reduce-compiler-warnings a313562a3 Merge branch 'feature/fix-compiler-warnings' into develop/reduce-compiler-warnings 8547cdd24 eliminiate GCC warnings from Filesystem.h b5044b2a2 fix several compiler warnings/code-analysis diagnostics 9d2f90b8c GetEnvironmentVariable() and getenv() aren't quite the same 6faa3666f remove more compiler warnings git-subtree-dir: externals/coda-oss git-subtree-split: aabc5818e651be550c0fcc53be6f94902c61905e * Squashed 'externals/nitro/' changes from e1a64da1f..24ff32863 24ff32863 -j 6 seems to work for SIX, how about NITRO? 713ee8538 -j 6 seems to work for SIX, how about NITRO? 4ccdf5b37 latest from coda-oss (#527) c71acc492 latest from coda-oss (#526) 08cbb96f9 build with older C++14 compilers (#524) git-subtree-dir: externals/nitro git-subtree-split: 24ff328636e3acbf1745e49df45b787403ecb113 * latest from coda-oss and nitro * use common code from six.sidd * consistent convertDerivedClassificationToXML() API * use common code from six.sidd * compile SIDD30 Utilities.cpp * get six.sidd30 unittests working * remove files duplicated between six.sidd and six.sidd30 * build with CMake * SIDD_V3.0.0 directory in "schema" * easy access to test XML files from Visual Studio * ValidatorXerces can be moved, but not copied * fix SIDD version bug when generating fake data * set things up for different schema paths for SIDD 3.0 (not yet implemented) * more detailed output from schema validation failure * SIDD_V3.0.0 * SIDD 3.0 schemas are in the SIDD_V3.0.0 directory * no ISM-v201609 in this branch * IonoParameters/F2Height is optional * remove six.sidd30 * remove SIDD_V3.0.0 * slam in 'main' * ISMVersion enum for 201609 and 13 * need to be able to set the ISM version in more places * start rippling changes for ISMVersion * add a "current" to make it easy for developers to switch between V201609 and v13 * change the ISM namespace * restore SIDD-3.0_ISM-v13 to a separate directory * Create sidd300_ISM-v13.xml * wrap the xml::lite::validator in our own class * pass a XmlLiteValidator instance * xml.lite changes from coda-oss * despite various checks for a NULL logger, it really can't be NULL * use xml::lite::Validator directly * move ISMVersion to the a sidd300 namespace to make it clear it's part of SIDD 3.0 * got a scoping issue somewhere :-( * unittest for ISM-v13 * hack to read ISM-v13 SIDD from unittest code; WIP * don't need make_ utility, at least right now * log_errors_and_throw() utility * prepare for validating a schema-path at a time * latest xml.lite tweaks from coda-oss * "new" code does XML validation one path at a time * adjust schema paths if ISMVersion is set * automatically prepend the ISM schema path * remove ISMVersion from DerivedXMLControl * allow the hard-coded "SIDD_V3.0.0_ISM-" name to be changed * first pass at finding the corresponding XSD for a XML * add a "hook" so that we can intercept validate() in SIDD code * provide standard validateXMLImpl() implementation * Revert "first pass at finding the corresponding XSD for a XML" This reverts commit 6bb593748a3f4209ae333217364d244770ded4bd. * move schema finding code to six.sidd * new code only needs to work with std::vector * If we found the right XSD, use that directory first. * Revert "allow the hard-coded "SIDD_V3.0.0_ISM-" name to be changed" This reverts commit 80554309db6fdc72d665679cb58de679996add81. * always validate one schema-path at a time * try not to open so many XSDs * getEnvIfSet() * look for SICommonTypes_V1.0.xsd to find the schema directory * "hook" for validating created XML * find_SIDD_schema_V_files() utility * put the hard-code SIDD schema name in one place * copy ISM-v201609 files to separate directory * There is now a separate directory for each SIDD 3.0 ISM * latest from coda-oss * Squashed 'externals/coda-oss/' changes from e87c32b4d..ff4f820ed 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: ff4f820ed8c406d43e3768508ca06d1a334b831f * Squashed 'externals/nitro/' changes from c8ecbe9ae..2fd7a0bfa 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: 2fd7a0bfa708a93a4bd17e44dbb4eba400b424d2 * toXMLImplValidate() isn't needed (at least not right now) * simplify validation code by converting to std::filesystem::path rather than using templates * No longer need ScoppedISMVersion to read ISM-v13 XML * comments to indicate the attributes for which we're looking * be sure SIDD XML is really SIDD * latest coda-oss from xml.lite branch * use std::vector::insert * create a SIDD Version enum rather than using strings * expose ISMVersion in fromXML() and toXML() * don't need old ISM with SIDD 3.0 * use six::sidd::Version rather than a string for creating fake data * require ISMVersion for SIDD 3.0.0 * more use of six::sidd::Version * save ISMVersion for SIDD 3.0.0 * adjust desVersion for ISMVersion * use the ISMVersion from the environment, if any * still more use of sidd::Version * still more use of sidd::Version instead of strVersion * latest from CODA-OSS and NITRO * latest from CODA-OSS * Squashed 'externals/coda-oss/' changes from ff4f820ed..d1244a080 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) git-subtree-dir: externals/coda-oss git-subtree-split: d1244a080457bb87e03879f743e3b2467145da08 * Squashed 'externals/nitro/' changes from 2fd7a0bfa..05dae18a3 05dae18a3 patch to build other projects 8f974e995 NITRO-2.11.3 (#554) 870aa6afd update to coda-oss 2023-06-05 (#553) git-subtree-dir: externals/nitro git-subtree-split: 05dae18a3a9c5ad70e1ce814c21ca8ec278829be * latest from CODA-OSS * latest from CODA-OSS * xml.lite tweaks from CODA-OSS speed things up * allow schema paths to be found/validated separate from XML validation * XercesContext can't be "static" (yet) * only initialize Xerces for multiple ValidatorXerces instances * use sys::convertPaths() utility * remove unneeded ValidatorXerces() overloads * don't expose findValidSchemaPaths() right now; no actual use-case * account for xml.lite changes in CODA-OSS * latest from CODA-OSS --- six/modules/c++/cphd/source/CPHDReader.cpp | 6 +- six/modules/c++/cphd/source/CPHDWriter.cpp | 10 +- .../c++/cphd/source/CPHDXMLControl.cpp | 18 +-- six/modules/c++/six.sicd/source/CropUtils.cpp | 5 +- six/modules/c++/six.sicd/source/Utilities.cpp | 21 +--- .../c++/six.sicd/unittests/test_valid_six.cpp | 4 +- six/modules/c++/six.sidd/source/Utilities.cpp | 11 +- .../c++/six/include/six/NITFWriteControl.h | 5 +- six/modules/c++/six/include/six/ReadControl.h | 8 +- .../c++/six/source/NITFWriteControl.cpp | 16 +-- six/modules/c++/six/source/Utilities.cpp | 7 +- six/modules/c++/six/source/XMLControl.cpp | 103 +++++++++++------- 12 files changed, 98 insertions(+), 116 deletions(-) diff --git a/six/modules/c++/cphd/source/CPHDReader.cpp b/six/modules/c++/cphd/source/CPHDReader.cpp index 40258717e..8cb31fbb9 100644 --- a/six/modules/c++/cphd/source/CPHDReader.cpp +++ b/six/modules/c++/cphd/source/CPHDReader.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -60,10 +61,7 @@ static cphd::Metadata fromXML(io::SeekableInputStream& inStream, logger = std::make_shared(); } - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); - + const auto schemaPaths = sys::convertPaths(schemaPaths_); return cphd::CPHDXMLControl(logger.get()).fromXML(xmlParser.getDocument(), schemaPaths); } cphd::CPHDReader::CPHDReader(std::shared_ptr inStream, diff --git a/six/modules/c++/cphd/source/CPHDWriter.cpp b/six/modules/c++/cphd/source/CPHDWriter.cpp index 89f719332..60d0d5f7f 100644 --- a/six/modules/c++/cphd/source/CPHDWriter.cpp +++ b/six/modules/c++/cphd/source/CPHDWriter.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -62,13 +63,6 @@ CPHDWriter::CPHDWriter(const Metadata& metadata, { } -static auto transform(const std::vector& schemaPaths) -{ - std::vector retval; - std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(retval), - [](const std::string& s) { return s; }); - return retval; -} CPHDWriter::CPHDWriter(const Metadata& metadata, std::shared_ptr outStream, const std::vector& schemaPaths, @@ -78,7 +72,7 @@ CPHDWriter::CPHDWriter(const Metadata& metadata, mElementSize(metadata.data.getNumBytesPerSample()), mScratchSpaceSize(scratchSpaceSize), mNumThreads(numThreads), - mSchemaPaths(transform(schemaPaths)), + mSchemaPaths(sys::convertPaths(schemaPaths)), mpSchemaPaths(&mSchemaPaths), mSharedStream(outStream), mStream(*mSharedStream), diff --git a/six/modules/c++/cphd/source/CPHDXMLControl.cpp b/six/modules/c++/cphd/source/CPHDXMLControl.cpp index f7902398d..791549005 100644 --- a/six/modules/c++/cphd/source/CPHDXMLControl.cpp +++ b/six/modules/c++/cphd/source/CPHDXMLControl.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -62,8 +63,7 @@ std::u8string CPHDXMLControl::toXMLString( std::vector schemaPaths; if (pSchemaPaths != nullptr) { - std::transform(pSchemaPaths->begin(), pSchemaPaths->end(), std::back_inserter(schemaPaths), - [](const std::filesystem::path& p) { return p.string(); }); + schemaPaths = sys::convertPaths(*pSchemaPaths); } std::unique_ptr doc(toXML(metadata, schemaPaths)); @@ -78,10 +78,7 @@ std::u8string CPHDXMLControl::toXMLString( const std::vector& schemaPaths_, bool prettyPrint) { - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); - + const auto schemaPaths = sys::convertPaths(schemaPaths_); return toXMLString(metadata, &schemaPaths, prettyPrint); } std::string CPHDXMLControl::toXMLString_( @@ -130,10 +127,7 @@ std::unique_ptr CPHDXMLControl::toXMLImpl(const Metadata& m std::unique_ptr CPHDXMLControl::fromXML(const std::string& xmlString, const std::vector& schemaPaths_) { - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); - + const auto schemaPaths = sys::convertPaths(schemaPaths_); return fromXML(str::u8FromNative(xmlString), schemaPaths); } std::unique_ptr CPHDXMLControl::fromXML(const std::u8string& xmlString, @@ -158,9 +152,7 @@ std::unique_ptr CPHDXMLControl::fromXML(const xml::lite::Document* doc } Metadata CPHDXMLControl::fromXML(const xml::lite::Document& doc, const std::vector& schemaPaths) { - std::vector schemaPaths_; - std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(schemaPaths_), - [](const std::filesystem::path& p) { return p.string(); }); + const auto schemaPaths_ = sys::convertPaths(schemaPaths); auto result = fromXML(&doc, schemaPaths_); auto retval = std::move(*(result.release())); diff --git a/six/modules/c++/six.sicd/source/CropUtils.cpp b/six/modules/c++/six.sicd/source/CropUtils.cpp index 64b25cd5c..347cca5e0 100644 --- a/six/modules/c++/six.sicd/source/CropUtils.cpp +++ b/six/modules/c++/six.sicd/source/CropUtils.cpp @@ -31,6 +31,8 @@ #include #include #include +#include + #include #include #include @@ -126,8 +128,7 @@ void cropSICD(six::NITFReadControl& reader, // Write the AOI SICD out six::NITFWriteControl writer(std::move(aoiData)); const std::span image(buffer.get(), origDims.area()); - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), [](const std::string& s) { return s; }); + const auto schemaPaths = sys::convertPaths(schemaPaths_); writer.save_image(image, outPathname, schemaPaths); } diff --git a/six/modules/c++/six.sicd/source/Utilities.cpp b/six/modules/c++/six.sicd/source/Utilities.cpp index c56b8eed3..039c528c2 100644 --- a/six/modules/c++/six.sicd/source/Utilities.cpp +++ b/six/modules/c++/six.sicd/source/Utilities.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -632,8 +633,7 @@ void Utilities::readSicd(const fs::path& sicdPathname, std::unique_ptr& complexData, std::vector& widebandData) { - std::vector schemaPaths_; - std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(schemaPaths_), [](const fs::path& p) { return p.string(); }); + const auto schemaPaths_ = sys::convertPaths(schemaPaths); readSicd(sicdPathname.string(), schemaPaths_, complexData, widebandData); } ComplexImageResult Utilities::readSicd(const fs::path& sicdPathname, const std::vector& schemaPaths) @@ -1026,11 +1026,7 @@ std::unique_ptr Utilities::parseDataFromString( logging::Logger& log) { const auto xmlStr = str::u8FromNative(xmlStr_); - - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); - + const auto schemaPaths = sys::convertPaths(schemaPaths_); return parseDataFromString(xmlStr, &schemaPaths, &log); } std::unique_ptr Utilities::parseDataFromString(const std::u8string& xmlStr, @@ -1045,10 +1041,7 @@ std::u8string Utilities::toXMLString(const ComplexData& data, const std::vector& schemaPaths_, logging::Logger* logger) { - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); - + const auto schemaPaths = sys::convertPaths(schemaPaths_); return toXMLString(data, &schemaPaths, logger); } std::string Utilities::toXMLString_(const ComplexData& data, @@ -1641,8 +1634,7 @@ static void writeAsNITF(const fs::path& pathname, const std::vector writer.setLogger(logging::setupLogger("out")); const std::span image(image_, getExtent(data).area()); - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), [](const std::string& s) { return s; }); + const auto schemaPaths = sys::convertPaths(schemaPaths_); writer.save_image(image, pathname, schemaPaths); } void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths, const ComplexData& data, std::span image) @@ -1655,8 +1647,7 @@ void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths, const ComplexData& data, std::span image) { - std::vector schemaPaths_; - std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(schemaPaths_), [](const fs::path& p) { return p.string(); }); + const auto schemaPaths_ = sys::convertPaths(schemaPaths); writeAsNITF(pathname, schemaPaths_, data, image); } void six::sicd::writeAsNITF(const fs::path& pathname, const std::vector& schemaPaths, const ComplexImage& image) diff --git a/six/modules/c++/six.sicd/unittests/test_valid_six.cpp b/six/modules/c++/six.sicd/unittests/test_valid_six.cpp index 456569108..03f5b0d4b 100644 --- a/six/modules/c++/six.sicd/unittests/test_valid_six.cpp +++ b/six/modules/c++/six.sicd/unittests/test_valid_six.cpp @@ -184,9 +184,7 @@ TEST_CASE(sicd_French_xml) // const auto schemaPaths = ::six::testing::getSchemaPaths(); // // // Use legacy APIs ... to test other XML processing path -// std::vector schemaPaths_; -// std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(schemaPaths_), -// [](const std::filesystem::path& p) { return p.string(); }); +// const auto schemaPaths_ = sys::convertPaths(schemaPaths); // // six::sicd::NITFReadComplexXMLControl reader; // reader.setLogger(); diff --git a/six/modules/c++/six.sidd/source/Utilities.cpp b/six/modules/c++/six.sidd/source/Utilities.cpp index 8a2455db2..3cd07c034 100644 --- a/six/modules/c++/six.sidd/source/Utilities.cpp +++ b/six/modules/c++/six.sidd/source/Utilities.cpp @@ -26,6 +26,7 @@ #include #include +#include #include "six/Utilities.h" #include "six/sidd/DerivedXMLControl.h" @@ -564,10 +565,7 @@ std::unique_ptr Utilities::parseDataFromString(const std::string& x const std::vector& schemaPaths_, logging::Logger& log) { const auto xmlStr = str::u8FromNative(xmlStr_); - - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); + const auto schemaPaths = sys::convertPaths(schemaPaths_); auto result = parseDataFromString(xmlStr, &schemaPaths, &log); return std::unique_ptr(result.release()); @@ -583,10 +581,7 @@ std::unique_ptr Utilities::parseDataFromString(const std::u8string& std::u8string Utilities::toXMLString(const DerivedData& data, const std::vector& schemaPaths_, logging::Logger* logger) { - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); - + const auto schemaPaths = sys::convertPaths(schemaPaths_); return toXMLString(data, &schemaPaths, logger); } std::string Utilities::toXMLString_(const DerivedData& data, diff --git a/six/modules/c++/six/include/six/NITFWriteControl.h b/six/modules/c++/six/include/six/NITFWriteControl.h index c72806999..642bbed97 100644 --- a/six/modules/c++/six/include/six/NITFWriteControl.h +++ b/six/modules/c++/six/include/six/NITFWriteControl.h @@ -35,6 +35,7 @@ #include #include +#include #include "six/Types.h" #include "six/Container.h" @@ -573,9 +574,7 @@ template inline void save(NITFWriteControl& writeControl, std::span imageData, const std::string& outputFile, const std::vector& schemaPaths_) { - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); + const auto schemaPaths = sys::convertPaths(schemaPaths_); save(writeControl, imageData, outputFile, schemaPaths); } diff --git a/six/modules/c++/six/include/six/ReadControl.h b/six/modules/c++/six/include/six/ReadControl.h index a522c6502..570cd3fad 100644 --- a/six/modules/c++/six/include/six/ReadControl.h +++ b/six/modules/c++/six/include/six/ReadControl.h @@ -27,6 +27,10 @@ #include #include +#include +#include +#include + #include "six/Types.h" #include "six/Region.h" #include "six/Container.h" @@ -34,8 +38,6 @@ #include "six/XMLControlFactory.h" #include "six/Logger.h" #include "six/Exports.h" -#include -#include namespace six { @@ -95,7 +97,7 @@ struct SIX_SIX_API ReadControl std::vector schemaPaths_; if (pSchemaPaths != nullptr) { - std::transform(pSchemaPaths->begin(), pSchemaPaths->end(), std::back_inserter(schemaPaths_), [](const std::filesystem::path& p) { return p.string(); }); + schemaPaths_ = sys::convertPaths(*pSchemaPaths); } load(fromFile.string(), schemaPaths_); } diff --git a/six/modules/c++/six/source/NITFWriteControl.cpp b/six/modules/c++/six/source/NITFWriteControl.cpp index add7312eb..f92806cb9 100644 --- a/six/modules/c++/six/source/NITFWriteControl.cpp +++ b/six/modules/c++/six/source/NITFWriteControl.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -510,36 +511,29 @@ void NITFWriteControl::do_save_(const T& imageData, bool doByteSwap, bool enable } } -static std::vector convert_paths( const std::vector& schemaPaths) -{ - std::vector retval; - std::transform(schemaPaths.begin(), schemaPaths.end(), std::back_inserter(retval), - [](const std::filesystem::path& p) { return p.string(); }); - return retval; -} void NITFWriteControl::save_image(std::span imageData, nitf::IOInterface& outputFile, const std::vector& schemaPaths) { - do_save(imageData, outputFile, convert_paths(schemaPaths)); + do_save(imageData, outputFile, sys::convertPaths(schemaPaths)); } void NITFWriteControl::save_image(std::span imageData, nitf::IOInterface& outputFile, const std::vector& schemaPaths) { - do_save(imageData, outputFile, convert_paths(schemaPaths)); + do_save(imageData, outputFile, sys::convertPaths(schemaPaths)); } void NITFWriteControl::save_image(std::span imageData, nitf::IOInterface& outputFile, const std::vector& schemaPaths) { - do_save(imageData, outputFile, convert_paths(schemaPaths)); + do_save(imageData, outputFile, sys::convertPaths(schemaPaths)); } void NITFWriteControl::save_image(std::span imageData, nitf::IOInterface& outputFile, const std::vector& schemaPaths) { - do_save(imageData, outputFile, convert_paths(schemaPaths)); + do_save(imageData, outputFile, sys::convertPaths(schemaPaths)); } void NITFWriteControl::save(const BufferList& list, const std::string& outputFile, const std::vector& schemaPaths) diff --git a/six/modules/c++/six/source/Utilities.cpp b/six/modules/c++/six/source/Utilities.cpp index 857b01f5a..52d688375 100644 --- a/six/modules/c++/six/source/Utilities.cpp +++ b/six/modules/c++/six/source/Utilities.cpp @@ -29,6 +29,8 @@ #include #include #include +#include + #include "six/Init.h" #include "six/Utilities.h" #include "six/XMLControl.h" @@ -712,10 +714,7 @@ std::unique_ptr six::parseDataFromString(const XMLControlRegistry& xmlReg, const std::vector& schemaPaths_, logging::Logger& log) { - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); - + const auto schemaPaths = sys::convertPaths(schemaPaths_); auto result = parseDataFromString(xmlReg, str::u8FromNative(xmlStr), dataType, &schemaPaths, &log); return std::unique_ptr(result.release()); } diff --git a/six/modules/c++/six/source/XMLControl.cpp b/six/modules/c++/six/source/XMLControl.cpp index 5f755caed..0b3157841 100644 --- a/six/modules/c++/six/source/XMLControl.cpp +++ b/six/modules/c++/six/source/XMLControl.cpp @@ -27,6 +27,8 @@ #include #include +#include + #include #include #include @@ -99,15 +101,13 @@ std::vector XMLControl::loadSchemaPaths(const std::vector // a NULL pointer indicates that we don't want to validate against a schema if (pSchemaPaths != nullptr) { - std::vector paths; - std::transform(pSchemaPaths->begin(), pSchemaPaths->end(), std::back_inserter(paths), - [&](const std::filesystem::path& p) { return p.string(); }); + std::vector paths = sys::convertPaths(*pSchemaPaths); // If *pSchemaPaths is empty, this will use a default value. To avoid all validation against a schema, // pass NULL for pSchemaPaths. loadSchemaPaths(paths); - std::transform(paths.begin(), paths.end(), std::back_inserter(retval), [&](const std::string& s) { return s; }); + retval = sys::convertPaths(paths); } return retval; } @@ -182,7 +182,7 @@ static void log_any_errors_and_throw(const std::vector& schemaPaths, logging::Logger& log) + const std::vector& foundSchemas, logging::Logger& log) { xml::lite::Uri uri; rootElement.getUri(uri); @@ -195,10 +195,10 @@ static void validate_(const xml::lite::Element& rootElement, // Process schema paths one at a time. This will reduce the "noise" from XML validation failures // and could also make instantiating an xml::lite::ValidatorXerces faster. std::vector all_errors; - for (auto&& schemaPath : schemaPaths) + for (auto&& foundSchema : foundSchemas) { - const std::vector schemaPaths_{ schemaPath }; // use one path at a time - const xml::lite::ValidatorXerces validator(schemaPaths_, &log, true); // this can be expensive to create as all sub-directories might be traversed + const std::vector foundSchemas_{ { foundSchema } }; + const xml::lite::ValidatorXerces validator(foundSchemas_, &log); // validate against any specified schemas std::vector errors; @@ -215,14 +215,12 @@ static void validate_(const xml::lite::Element& rootElement, } // log any error found and throw - log_any_errors_and_throw(all_errors, schemaPaths, log); + log_any_errors_and_throw(all_errors, foundSchemas, log); } + static void validate_(const xml::lite::Document& doc, - const std::vector& paths_, logging::Logger& log) + const std::vector& foundSchemas, logging::Logger& log) { - // If the paths we have don't exist, throw - const auto paths = check_whether_paths_exist(paths_); - auto rootElement = doc.getRootElement(); if (rootElement->getUri().empty()) { @@ -230,8 +228,12 @@ static void validate_(const xml::lite::Document& doc, } // validate against any specified schemas - validate_(*rootElement, paths, log); + validate_(*rootElement, foundSchemas, log); } + +static std::vector findValidSchemaPaths(const std::vector&, logging::Logger*); +static std::vector findValidSchemaPaths(const std::vector*, logging::Logger*); + void XMLControl::validate(const xml::lite::Document* doc, const std::vector& schemaPaths, logging::Logger* log) @@ -241,45 +243,64 @@ void XMLControl::validate(const xml::lite::Document* doc, // Existing code in xml::lite requires that the Logger be non-NULL assert(log != nullptr); + // validate against any specified schemas + const auto foundSchemas = findValidSchemaPaths(schemaPaths, log); // If the paths we have don't exist, throw + validate_(*doc, foundSchemas, *log); +} +void XMLControl::validate(const xml::lite::Document& doc, + const std::vector* pSchemaPaths, + logging::Logger* log) +{ + // Existing code in xml::lite requires that the Logger be non-NULL + assert(log != nullptr); + + // validate against any specified schemas + const auto foundSchemas = findValidSchemaPaths(pSchemaPaths, log); + validate_(doc, foundSchemas, *log); +} + +static auto findValidSchemas(const std::vector& paths_) +{ + // If the paths we have don't exist, throw + const auto paths = check_whether_paths_exist(paths_); + return xml::lite::ValidatorXerces::loadSchemas(paths, true /*recursive*/); +} +static std::vector findValidSchemaPaths(const std::vector& schemaPaths, + logging::Logger* log) +{ // attempt to get the schema location from the // environment if nothing is specified std::vector paths(schemaPaths); - loadSchemaPaths(paths); + XMLControl::loadSchemaPaths(paths); if (paths.empty()) { - std::ostringstream oss; - oss << "Coudn't validate XML - no schemas paths provided " - << " and " << six::SCHEMA_PATH << " not set."; - - log->warn(oss); + if (log != nullptr) + { + std::ostringstream oss; + oss << "Coudn't validate XML - no schemas paths provided " + << " and " << six::SCHEMA_PATH << " not set."; + log->warn(oss); + } } - std::vector schemaPaths_; - std::transform(paths.begin(), paths.end(), std::back_inserter(schemaPaths_), [&](const std::string& s) { return s; }); - - // validate against any specified schemas - validate_(*doc, schemaPaths_, *log); + return findValidSchemas(sys::convertPaths(paths)); // If the paths we have don't exist, throw } -void XMLControl::validate(const xml::lite::Document& doc, - const std::vector* pSchemaPaths, +static std::vector findValidSchemaPaths(const std::vector* pSchemaPaths, logging::Logger* log) { - // Existing code in xml::lite requires that the Logger be non-NULL - assert(log != nullptr); - // attempt to get the schema location from the environment if nothing is specified - auto paths = loadSchemaPaths(pSchemaPaths); + auto paths = XMLControl::loadSchemaPaths(pSchemaPaths); if ((pSchemaPaths != nullptr) && paths.empty()) { - std::ostringstream oss; - oss << "Coudn't validate XML - no schemas paths provided " - << " and " << six::SCHEMA_PATH << " not set."; - - log->warn(oss); + if (log != nullptr) + { + std::ostringstream oss; + oss << "Coudn't validate XML - no schemas paths provided " + << " and " << six::SCHEMA_PATH << " not set."; + log->warn(oss); + } } - - // validate against any specified schemas - validate_(doc, paths, *log); + return findValidSchemas(paths); // If the paths we have don't exist, throw } std::string XMLControl::getDefaultURI(const Data& data) @@ -360,9 +381,7 @@ std::unique_ptr XMLControl::fromXMLImpl(const xml::lite::Document& doc) co Data* XMLControl::fromXML(const xml::lite::Document* doc, const std::vector& schemaPaths_) { - std::vector schemaPaths; - std::transform(schemaPaths_.begin(), schemaPaths_.end(), std::back_inserter(schemaPaths), - [](const std::string& s) { return s; }); + const auto schemaPaths = sys::convertPaths(schemaPaths_); assert(doc != nullptr); auto data = fromXML(*doc, &schemaPaths);