From 3d81b639b281ecae97d233ca6fbfbc5d4a0430d0 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 5 Jun 2023 14:14:55 -0400 Subject: [PATCH] copy_externals --- .../nitro/externals/coda-oss/ReleaseNotes.md | 85 -- .../modules/c++/cli/source/ArgumentParser.cpp | 884 ------------ .../modules/c++/coda-oss-lite.vcxproj | 513 ------- .../modules/c++/coda-oss-lite.vcxproj.filters | 1229 ----------------- .../c++/coda_oss/include/coda_oss/bit.h | 103 -- .../c++/coda_oss/include/coda_oss/span.h | 78 -- .../c++/config/include/config/Version.h | 71 - .../modules/c++/mt/include/mt/RequestQueue.h | 146 -- .../coda-oss/modules/c++/net/source/URL.cpp | 214 --- .../polygon/include/polygon/Intersections.h | 288 ---- .../c++/sio.lite/source/FileHeader.cpp | 213 --- .../modules/c++/str/include/str/Format.h | 60 - .../modules/c++/str/include/str/Manip.h | 210 --- .../modules/c++/str/include/str/Tokenizer.h | 77 -- .../coda-oss/modules/c++/str/source/Manip.cpp | 359 ----- .../modules/c++/str/unittests/test_str.cpp | 250 ---- .../c++/sys/include/sys/AtomicCounterCpp11.h | 73 - .../modules/c++/sys/include/sys/ByteSwap.h | 298 ---- .../c++/sys/include/sys/ByteSwapValue.h | 202 --- .../sys/include/sys/ConditionVarInterface.h | 125 -- .../modules/c++/sys/include/sys/Conf.h | 251 ---- .../modules/c++/sys/include/sys/DateTime.h | 191 --- .../modules/c++/sys/include/sys/Err.h | 177 --- .../c++/sys/include/sys/LocalDateTime.h | 101 -- .../modules/c++/sys/include/sys/MutexCpp11.h | 79 -- .../modules/c++/sys/include/sys/MutexWin32.h | 78 -- .../modules/c++/sys/include/sys/OSWin32.h | 284 ---- .../modules/c++/sys/include/sys/Span.h | 194 --- .../modules/c++/sys/include/sys/SysInt.h | 45 - .../modules/c++/sys/include/sys/TimeStamp.h | 102 -- .../coda-oss/modules/c++/sys/source/Conf.cpp | 349 ----- .../c++/sys/unittests/test_byte_swap.cpp | 320 ----- .../c++/tiff/include/tiff/GenericType.h | 183 --- .../modules/c++/tiff/source/ImageWriter.cpp | 485 ------- .../modules/c++/tiff/source/Utils.cpp | 181 --- .../c++/xml.lite/include/xml/lite/QName.h | 221 --- .../modules/c++/xml.lite/source/Element.cpp | 564 -------- .../c++/xml.lite/source/NamespaceStack.cpp | 72 - 38 files changed, 9355 deletions(-) delete mode 100644 externals/nitro/externals/coda-oss/ReleaseNotes.md delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/config/include/config/Version.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/mt/include/mt/RequestQueue.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/net/source/URL.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/polygon/include/polygon/Intersections.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sio.lite/source/FileHeader.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/str/include/str/Format.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/str/include/str/Manip.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/str/include/str/Tokenizer.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/str/source/Manip.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/str/unittests/test_str.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/AtomicCounterCpp11.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ConditionVarInterface.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Conf.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/DateTime.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Err.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/LocalDateTime.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexCpp11.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexWin32.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/OSWin32.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Span.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/SysInt.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/TimeStamp.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/source/Conf.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/tiff/include/tiff/GenericType.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/tiff/source/ImageWriter.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/tiff/source/Utils.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp delete mode 100644 externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp diff --git a/externals/nitro/externals/coda-oss/ReleaseNotes.md b/externals/nitro/externals/coda-oss/ReleaseNotes.md deleted file mode 100644 index bf8f97f3a..000000000 --- a/externals/nitro/externals/coda-oss/ReleaseNotes.md +++ /dev/null @@ -1,85 +0,0 @@ -``` - _________________________ - | ____ _||_ ___ __ | - | /___ \/_||_\| __\/ \ | - | // \// || \|| \\ _ \ | - | || [===||===] ||(_)| | - | || _|| || ||| ||__ | | - | \\ _/ |\_||_/||__/|| || | - | \___/ \_||_/|___/|| || | - |__________||_____________| - ``` -# coda-oss Release Notes - -## [Release 2023-06-05](https://github.com/mdaus/coda-oss/releases/tag/2023-06-05) -* *zlib* updated to [1.2.13](https://github.com/madler/zlib/releases/tag/v1.2.13). -* new `mem::ComplexView` class to make it easier to process complex data stored in parallel. -* adjust compiler flags for clean *CMake* builds. -* wrap common "file open" routines (e.g., `fopen()`) to support `sys::expandEnvironmentVariables()`. -* add header-only [HighFive](https://github.com/BlueBrain/HighFive) HDF5-wrapper library. -* Added a handful of [HighFive](https://github.com/BlueBrain/HighFive) utility routines. -* `mt::transform_async()` removed, it doesn't match C++17 techniques.' -* Revamp `sys::byteSwap()` for improved type-safety and - [better performance](https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/). - * Added case-insensitive string comparison utilties: `str::eq()` and `str::ne()`; - `xml::lite::Uri`s compare case-insensitive. - -## [Release 2022-12-14](https://github.com/mdaus/coda-oss/releases/tag/2022-12-14) -* removed remaining vestiges of `std::auto_ptr`, provide `mem::AutoPtr` for the tiny handful of - places (e.g., SWIG bindings) that still need copying. -* `xml::lite::Element` overloads to make creting new XML documents easier; see unittests for examples. -* try even harder to find unittest files in various scenarios. -* build *hdf5.lite* with **waf**. -* New `--optz=fastest-possible` (**waf** only) which adds - [`-march=native`](https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/x86-Options.html#x86-Options) - to *fastest* for **waf** builds. There is a new *faster* option (the default) which is currently - the same as *fastest* (i.e., no `-march=native`). - -## [Release 2022-11-04](https://github.com/mdaus/coda-oss/releases/tag/2022-11-04) -* "Cut" from [main](https://github.com/mdaus/coda-oss/tree/main), not *master*. -* The [HDFGroup](https://hdfgroup.org/)s [HDF5 library](https://github.com/HDFGroup/hdf5) is built - and installed; a simple (and very incomplete!) wrapper is provided, this is at the "hello world!" stage. -* A few **cli** routines have been tweaked to make unit-testing easier. -* Utilitiy routines for finding various files when unit-testing. -* Removed C++14 work-arounds needed in C++11. Legacy C++ exception specificatons removed. -* Rebuild `waf` for FIPS error; added more debug options. - -## [Release 2022-08-30](https://github.com/mdaus/coda-oss/releases/tag/2022-08-30) -* XML is now always written as UTF-8; the code will still try to read Windows-1252. -* `Uri`s are no longer validated by default. -* Minor tweaks from other projects. -* ~~Final C++11 release 🤞🏻; future releases will be C++14 from [main](https://github.com/mdaus/coda-oss/tree/main).~~ - -## [Release 2022-08-02](https://github.com/mdaus/coda-oss/releases/tag/2022-08-02) -* remove *Expat* and *libXML* modules and support in **xml.lite**; only *Xerces* was actively used. -* ~~fix `waf` to work-around FIPS warning because of insecure *md5* hashing.~~ -* tweak `str::EncodedStringView` and `str::EncodedString` for - [future XML changes](https://github.com/mdaus/coda-oss/tree/feature/always-write-xml-as-utf8). - -## [Release 2022-06-29](https://github.com/mdaus/coda-oss/releases/tag/2022-06-29) -* remove **modules/drivers/boost** as it was empty (and unused); - **modules/c++/serialize** depended on boost, so it has also been removed. -* Update to [zlib 1.2.12](https://www.zlib.net/zlib-1.2.12.tar.gz), - ["Due to the bug fixes, any installations of 1.2.11 should be replaced with 1.2.12."](https://www.zlib.net/) -* Build most code in Visual Studio 2022 -* Removed more compiler warnings -* Begin work on `CODA_OSS_API` (needed for building a shared-library/DLL) -* Add `run1D()` method to `mt::GenerationThreadPool` - -## [Release 2022-05-03](https://github.com/mdaus/coda-oss/releases/tag/2022-05-03) -* Fixed a bug in `Poly2D::atY()`; improved `flipXY()` behavior. -* Implement [std::filesystem::file_size()](https://en.cppreference.com/w/cpp/filesystem/file_size). -* use `inline` functions for `TEST_` macros -* force use of [64-bit `time_t`](https://en.wikipedia.org/wiki/Year_2038_problem) -* more routines now support a `std::span` overload; e.g., `io::InputStream::read()`. - -## [Release 2022-02-22](https://github.com/mdaus/coda-oss/releases/tag/2022-02-22) -* new `EnocdedString` and `EncodedStringView` to manage strings in different encodings -* XML containing UTF-8 characters can now be validated -* Update to [GSL 4.0.0](https://github.com/microsoft/GSL/releases/tag/v4.0.0) -* our implementation of `std` stuff is all in the `coda_oss` namespace -* old, unused **log4j.jar** deleted to remove any questions about the security vulnerability - -## [Release 2021-12-13](https://github.com/mdaus/coda-oss/releases/tag/2021-12-13) -* Try hard to parse XML encoded in various ways -* Simplify XML element creation for common idioms diff --git a/externals/nitro/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp b/externals/nitro/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp deleted file mode 100644 index 2a31bda45..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp +++ /dev/null @@ -1,884 +0,0 @@ -/* ========================================================================= - * This file is part of cli-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * cli-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include "cli/ArgumentParser.h" - -#include -#include - -#include -#include - -namespace -{ -static const size_t MAX_ARG_LINE_LENGTH = 21; - -bool containsOnly(const std::string& str, - const std::map& flags) -{ - for (size_t ii = 0; ii < str.length(); ++ii) - { - if (flags.find(str.substr(ii, 1)) == flags.end()) - { - return false; - } - } - - return true; -} - -void writeArgumentHelp(std::ostream& out, const std::string& heading, - size_t maxFlagsWidth, - const std::vector& flags, - const std::vector& helps) -{ - std::ostringstream s; - out << heading << std::endl; - for (size_t i = 0, num = flags.size(); i < num; ++i) - { - s.str(""); - std::string flag = flags[i]; - std::string help = helps[i]; - if (flag.size() <= maxFlagsWidth) - { - s << " "; - s.width(maxFlagsWidth + 1); - s << std::left << flag; - s.width(0); - s << help; - out << s.str() << std::endl; - } - else - { - s << " "; - s << flag; - out << s.str() << std::endl; - s.str(""); - s.width(maxFlagsWidth + 3); - s << " "; - s.width(0); - s << help; - out << s.str() << std::endl; - } - } -} -} - -cli::ArgumentParser::ArgumentParser(bool ignoreUnknownArguments, - std::ostream* iuOStream ) : - mHelpEnabled(true), - mPrefixChar('-'), - mIgnoreUnknownArguments(ignoreUnknownArguments), - mIgnoreUnknownOStream(iuOStream) -{ -} - -cli::ArgumentParser::~ArgumentParser() -{ -} - -/** - * Shortcut for adding an argument - */ -std::shared_ptr -cli::ArgumentParser::addArgument(const std::string& nameOrFlags, - const std::string& help, - cli::Action action, - const std::string& dest, - const std::string& metavar, - int minArgs, int maxArgs, - bool required) -{ - std::shared_ptr arg(new cli::Argument(nameOrFlags, this)); - - if (arg->isPositional()) - { - action = cli::STORE; - // if it is positional and a min args is supplied, require it - if (minArgs > 0) - required = true; - } - - switch (action) - { - case cli::STORE: - case cli::SUB_OPTIONS: - if (minArgs < 0) - { - minArgs = 1; - maxArgs = 1; - } - break; - case cli::STORE_TRUE: - case cli::STORE_FALSE: - case cli::STORE_CONST: - case cli::VERSION: - minArgs = 1; - maxArgs = 1; - break; - } - - arg->setMinArgs(minArgs); - arg->setMaxArgs(maxArgs); - arg->setAction(action); - arg->setDestination(dest); - arg->setHelp(help); - arg->setMetavar(metavar); - arg->setRequired(required); - mArgs.push_back(arg); - return arg; -} - -cli::ArgumentParser& cli::ArgumentParser::setDescription(const std::string& d) -{ - mDescription = d; - return *this; -} - -cli::ArgumentParser& cli::ArgumentParser::setProlog(const std::string& prolog) -{ - mProlog = prolog; - return *this; -} - -cli::ArgumentParser& cli::ArgumentParser::setEpilog(const std::string& epilog) -{ - mEpilog = epilog; - return *this; -} - -cli::ArgumentParser& cli::ArgumentParser::setUsage(const std::string& usage) -{ - mUsage = usage; - return *this; -} - -cli::ArgumentParser& cli::ArgumentParser::enableHelp(bool flag) -{ - mHelpEnabled = flag; - return *this; -} - -cli::ArgumentParser& cli::ArgumentParser::setProgram(const std::string& program) -{ - mProgram = program; - return *this; -} - -cli::ArgumentParser& cli::ArgumentParser::setIgnoreUnknownArgumentsFlag(bool iuFlag) -{ - mIgnoreUnknownArguments = iuFlag; - return *this; -} - -cli::ArgumentParser& cli::ArgumentParser::setIgnoreUnknownArgumentsOutputStream( - std::ostream* iuaOutstream) -{ - mIgnoreUnknownOStream = iuaOutstream; - return *this; -} - -void cli::ArgumentParser::printHelp(std::ostream& out, bool andExit) const -{ - FlagInfo flagInfo; - processFlags(flagInfo); - - if (!mProlog.empty()) - out << mProlog << std::endl << std::endl; - - out << "usage: "; - if (mUsage.empty()) - { - std::string progName = mProgram; - out << (progName.empty() ? "program" : progName); - if (!flagInfo.opUsage.empty()) - out << " " << str::join(flagInfo.opUsage, " "); - if (!flagInfo.posUsage.empty()) - out << " " << str::join(flagInfo.posUsage, " "); - out << std::endl; - } - else - out << mUsage << std::endl; - - if (!mDescription.empty()) - out << std::endl << mDescription << std::endl; - - if (!flagInfo.posFlags.empty()) - { - out << std::endl; - writeArgumentHelp(out, "positional arguments:", flagInfo.maxFlagsWidth, - flagInfo.posFlags, flagInfo.posHelps); - } - - if (!flagInfo.requiredFlags.empty()) - { - out << std::endl; - writeArgumentHelp(out, "required arguments:", flagInfo.maxFlagsWidth, - flagInfo.requiredFlags, flagInfo.requiredHelps); - } - - if (!flagInfo.opFlags.empty()) - { - out << std::endl; - writeArgumentHelp(out, "optional arguments:", flagInfo.maxFlagsWidth, - flagInfo.opFlags, flagInfo.opHelps); - } - - if (!mEpilog.empty()) - out << std::endl << mEpilog << std::endl; - - if (andExit) - exit(cli::EXIT_USAGE); -} - -std::vector cli::ArgumentParser::make_args(int argc, const char** argv, std::string& program) -{ - if (argc > 0) - program = std::string(argv[0]); - std::vector args; - for (int i = 1; i < argc; ++i) - args.emplace_back(argv[i]); - return args; -} -std::vector cli::ArgumentParser::make_args(int argc, const char** argv) -{ - std::string program; - auto args = make_args(argc, argv, program); - if (mProgram.empty() && !program.empty()) - setProgram(program); - return args; -} - -cli::Results* cli::ArgumentParser::parse(int argc, const char** argv) -{ - return parse(make_args(argc, argv)); -} -cli::Results* cli::ArgumentParser::parse(const std::vector& args) -{ - if (!mProgram.empty()) - { - return parse("" /*don't change any value already set*/, args).release(); - } - else - { - return parse("cli::ArgumentParser::parse" /*program*/, args).release(); // provide a "meaningful" default program name - } -} -std::unique_ptr cli::ArgumentParser::parse(const std::string& program, const std::vector& args) -{ - if (!program.empty()) - setProgram(program); - - std::map shortFlags; - std::map longFlags; - std::map shortOptionsFlags; - std::map longOptionsFlags; - std::vector positionalArgs; - - positionalArgs.reserve(mArgs.size()); - for (auto& arg_ : mArgs) - { - cli::Argument* arg = arg_.get(); - std::string argVar = arg->getVariable(); - - if (arg->isPositional()) - { - positionalArgs.push_back(arg); - } - else - { - const std::vector& argShortFlags = - arg->getShortFlags(); - const std::vector& argLongFlags = arg->getLongFlags(); - bool subOption = (arg->getAction() == cli::SUB_OPTIONS); - for (std::vector::const_iterator it = - argShortFlags.begin(); it != argShortFlags.end(); ++it) - { - std::string op = *it; - std::map& flagMap = - (subOption ? shortOptionsFlags : shortFlags); - if (flagMap.find(op) != flagMap.end()) - parseError(FmtX("Conflicting option: %c%s", mPrefixChar, - op.c_str())); - flagMap[op] = arg; - } - for (std::vector::const_iterator it = - argLongFlags.begin(); it != argLongFlags.end(); ++it) - { - std::string op = *it; - std::map& flagMap = - (subOption ? longOptionsFlags : longFlags); - if (flagMap.find(op) != flagMap.end()) - parseError(FmtX("Conflicting option: %c%c%s", mPrefixChar, - mPrefixChar, op.c_str())); - flagMap[op] = arg; - } - } - - } - - std::vector < std::string > explodedArgs; - explodedArgs.reserve(args.size()); - // next, check for combined short options - for (size_t i = 0, s = args.size(); i < s; ++i) - { - std::string argStr = args[i]; - if (argStr.size() > 1 && argStr[0] == mPrefixChar && argStr[1] - != mPrefixChar) - { - std::string flag = argStr.substr(1); - if (shortFlags.find(flag) != shortFlags.end()) - { - explodedArgs.push_back(argStr); - } - else - { - // check for = - if (argStr.find("=") != std::string::npos) - { - std::vector < std::string > parts = str::split(argStr, "=", - 2); - std::copy(parts.begin(), parts.end(), - std::back_inserter(explodedArgs)); - } - else - { - // first, see if it is an extra option - std::vector < std::string > parts = str::split(argStr, ":", - 2); - if (parts.size() == 2) - { - explodedArgs.push_back(argStr); - } - else - { - // Check if every single character in this flag is - // one of the short flags - if (containsOnly(flag, shortFlags)) - { - // Split up each char as separate options - // Only the last will get any additional args - const std::string prefixStr(1, mPrefixChar); - for (size_t jj = 0; jj < flag.length(); ++jj) - { - explodedArgs.push_back(prefixStr + flag[jj]); - } - } - else - { - // If we find a character that isn't one of the - // short flags, then it's probably just an - // argument that happens to start with a dash, - // like "-1", and we want to leave it alone - explodedArgs.push_back(argStr); - } - } - } - } - } - else if (argStr.size() > 2 && argStr[0] == mPrefixChar && argStr[1] - == mPrefixChar) - { - // check for = - if (argStr.find("=") != std::string::npos) - { - std::vector < std::string > parts = str::split(argStr, "=", 2); - std::copy(parts.begin(), parts.end(), - std::back_inserter(explodedArgs)); - } - else - explodedArgs.push_back(argStr); - } - else - { - explodedArgs.push_back(argStr); - } - } - - auto results = std::make_unique(); - cli::Results *currentResults = NULL; - for (size_t i = 0, s = explodedArgs.size(); i < s; ++i) - { - currentResults = results.get(); // set the pointer - std::string argStr = explodedArgs[i]; - cli::Argument *arg = NULL; - std::string optionsStr(""); - if (argStr.size() > 2 && argStr[0] == mPrefixChar && argStr[1] - == mPrefixChar) - { - std::string flag = argStr.substr(2); - if (longFlags.find(flag) != longFlags.end()) - { - arg = longFlags[flag]; - } - else if (mHelpEnabled && flag == "help") - { - printHelp(std::cerr, true); - } - else - { - // check if it's an options flag - std::vector < std::string > parts = str::split(flag, ":", 2); - if (parts.size() == 2 && longOptionsFlags.find(parts[0]) - != longOptionsFlags.end()) - { - arg = longOptionsFlags[parts[0]]; - optionsStr = parts[1]; - std::string argVar = arg->getVariable(); - if (!results->hasSubResults(argVar)) - results->put(argVar, new cli::Results); - currentResults = results->getSubResults(argVar); - } - else - { - if (mIgnoreUnknownArguments) - { - *mIgnoreUnknownOStream << "Unknown arg: " << argStr - << std::endl; - continue; - } - else - { - throw except::Exception(Ctxt( - FmtX("Invalid option: [%s]", argStr.c_str()))); - } - } - } - } - else if (argStr.size() > 1 && argStr[0] == mPrefixChar && argStr[1] - != mPrefixChar) - { - std::string flag = argStr.substr(1); - if (shortFlags.find(flag) != shortFlags.end()) - { - arg = shortFlags[flag]; - } - else if (mHelpEnabled && flag == "h") - { - printHelp(std::cerr, true); - } - else - { - // check if it's an options flag - std::vector < std::string > parts = str::split(flag, ":", 2); - if (parts.size() == 2 && shortOptionsFlags.find(parts[0]) - != shortOptionsFlags.end()) - { - arg = shortOptionsFlags[parts[0]]; - optionsStr = parts[1]; - std::string argVar = arg->getVariable(); - if (!results->hasSubResults(argVar)) - results->put(argVar, new cli::Results); - currentResults = results->getSubResults(argVar); - } - else - { - if (mIgnoreUnknownArguments) - { - *mIgnoreUnknownOStream << "Unknown arg: " << argStr - << std::endl; - continue; - } - else - { - throw except::Exception(Ctxt( - FmtX("Invalid option: [%s]", argStr.c_str()))); - } - - } - } - } - - - if (arg != NULL) - { - std::string argVar = arg->getVariable(); - switch (arg->getAction()) - { - case cli::STORE: - { - cli::Value* v = currentResults->hasValue(argVar) - ? currentResults->getValue(argVar) - : new cli::Value; - int maxArgs = arg->getMaxArgs(); - // risky, I know... - bool added = false; - while (i < s - 1) - { - std::string nextArg(explodedArgs[i + 1]); - if (nextArg.size() > 1 && nextArg[0] == mPrefixChar) - { - // It might be another flag, but it might just be a - // value that starts with a negative sign - if ((nextArg.size() > 2 && nextArg[1] == mPrefixChar) || - str::contains(nextArg, ":") || - containsOnly(nextArg.substr(1), shortFlags)) - { - // Fine, it's another flag - break; - } - } - if (maxArgs >= 0 && - v->size() >= static_cast(maxArgs)) - { - // it's another positional argument, so we break out - break; - } - v->add(nextArg); - ++i; - added = true; - } - - if (!added) - parseError( - FmtX( - "option requires value or has exceeded its max: [%s]", - argVar.c_str())); - - currentResults->put(argVar, v); - break; - } - case cli::STORE_TRUE: - currentResults->put(argVar, new cli::Value(true)); - break; - case cli::STORE_FALSE: - currentResults->put(argVar, new cli::Value(false)); - break; - case cli::STORE_CONST: - { - const Value* constVal = arg->getConst(); - currentResults->put(argVar, constVal ? constVal->clone() : NULL); - break; - } - case cli::SUB_OPTIONS: - { - if (optionsStr.empty()) - parseError(FmtX("invalid sub option: [%s]", argVar.c_str())); - cli::Value* v = currentResults->hasValue(optionsStr) - ? currentResults->getValue(optionsStr) - : new cli::Value; - if (i < s - 1) - { - std::string nextArg = explodedArgs[i + 1]; - if (nextArg.size() > 1 && nextArg[0] == mPrefixChar) - { - // it's another flag - // this indicates the sub op is a bool - v->add(true); - } - else - { - v->add(nextArg); - ++i; - } - } - else - { - // this indicates the sub op is a bool - v->add(true); - } - currentResults->put(optionsStr, v); - break; - } - case cli::VERSION: - //TODO - break; - } - } - else - { - // it's a positional argument - cli::Value *lastPosVal = NULL; - for (std::vector::iterator it = - positionalArgs.begin(); it != positionalArgs.end(); ++it) - { - cli::Argument *posArg = *it; - std::string argVar = posArg->getVariable(); - int maxArgs = posArg->getMaxArgs(); - if (currentResults->hasValue(argVar)) - { - cli::Value *posVal = lastPosVal - = currentResults->getValue(argVar); - if (static_cast(posVal->size()) >= maxArgs) - continue; - break; - } - else if (maxArgs != 0) - { - lastPosVal = new cli::Value; - currentResults->put(argVar, lastPosVal); - break; - } - } - if (lastPosVal) - { - lastPosVal->add(argStr); - } - else - { - if (!mIgnoreUnknownArguments) - { - parseError("too many arguments"); - } - } - } - } - - // add the defaults - for (auto& arg_ : mArgs) - { - cli::Argument* arg = arg_.get(); - std::string argMeta = arg->getMetavar(); - std::string argVar = arg->getVariable(); - std::string argId = arg->isPositional() && !argMeta.empty() ? argMeta - : argVar; - - if (!results->hasValue(argVar)) - { - const Value* defaultVal = arg->getDefault(); - if (defaultVal != NULL) - results->put(argVar, defaultVal->clone()); - else if (arg->getAction() == cli::STORE_FALSE) - results->put(argVar, new cli::Value(true)); - else if (arg->getAction() == cli::STORE_TRUE) - results->put(argVar, new cli::Value(false)); - else if (arg->isRequired()) - parseError(FmtX("missing required argument: [%s]", - argVar.c_str())); - } - - - // validate # of args - int minArgs = arg->getMinArgs(); - int maxArgs = arg->getMaxArgs(); - size_t numGiven = - results->hasValue(argVar) ? results->getValue(argVar)->size() - : 0; - - if (arg->isRequired() || numGiven > 0) - { - if (minArgs > 0 && numGiven < static_cast(minArgs)) - parseError(FmtX("not enough arguments, %d required: [%s]", - minArgs, argId.c_str())); - if (maxArgs >= 0 && numGiven > static_cast(maxArgs)) - parseError(FmtX("too many arguments, %d supported: [%s]", - maxArgs, argId.c_str())); - } - - - // validate the argument value against the choices - // TODO: add option to make case insensitive - std::vector choices = arg->getChoices(); - if (numGiven > 0 && !choices.empty()) - { - bool isValid = false; - cli::Value *vals = results->getValue(argVar); - - for (size_t ii = 0; ii < numGiven; ++ii) - { - if (std::find(choices.begin(), choices.end(), - vals->at(ii)) != choices.end()) - { - isValid = true; - break; - } - } - if (!isValid) - { - parseError(FmtX("invalid option for [%s]", argVar.c_str())); - } - } - } - - return results; -} - -void cli::ArgumentParser::printUsage(std::ostream& out, bool andExit, - const std::string& message) const -{ - out << "usage: "; - if (mUsage.empty()) - { - FlagInfo flagInfo; - processFlags(flagInfo); - - out << (mProgram.empty() ? "program" : mProgram); - if (!flagInfo.opUsage.empty()) - out << " " << str::join(flagInfo.opUsage, " "); - if (!flagInfo.posUsage.empty()) - out << " " << str::join(flagInfo.posUsage, " "); - } - else - out << mUsage; - if (!message.empty()) - out << std::endl << std::endl << message; - out << std::endl; - if (andExit) - exit(cli::EXIT_USAGE); -} - -void cli::ArgumentParser::parseError(const std::string& msg) -{ - std::ostringstream s; - s << "usage: "; - if (mUsage.empty()) - { - FlagInfo flagInfo; - processFlags(flagInfo); - - s << (mProgram.empty() ? "program" : mProgram); - if (!flagInfo.opUsage.empty()) - s << " " << str::join(flagInfo.opUsage, " "); - if (!flagInfo.posUsage.empty()) - s << " " << str::join(flagInfo.posUsage, " "); - } - else - s << mUsage; - s << "\n" << msg; - throw except::ParseException(s.str()); -} - -void cli::ArgumentParser::processFlags(FlagInfo& info) const -{ - std::ostringstream s; - - if (mHelpEnabled) - { - const std::string prefixStr(1, mPrefixChar); - const std::string helpMsg = - std::string(1, mPrefixChar) + "h, " + - std::string(2, mPrefixChar) + "help"; - - info.maxFlagsWidth = std::max(helpMsg.size(), info.maxFlagsWidth); - info.opFlags.push_back(helpMsg); - info.opHelps.push_back("show this help message and exit"); - } - - for (auto& arg_ : mArgs) - { - cli::Argument* arg = arg_.get(); - const std::string& argName = arg->getName(); - const cli::Action& argAction = arg->getAction(); - const std::vector& argChoices = arg->getChoices(); - const std::string& argMetavar = arg->getMetavar(); - const std::string& argHelp = arg->getHelp(); - const cli::Value* defaultVal = arg->getDefault(); - - s.str(""); - s << argHelp; - if (defaultVal) - s << " (default: " << defaultVal->toString() << ")"; - std::string helpMsg = s.str(); - - s.str(""); - if (!argMetavar.empty()) - s << argMetavar; - else if (!argChoices.empty()) - s << "{" << str::join(argChoices, ",") << "}"; - std::string meta = s.str(); - - if (arg->isPositional()) - { - //positional argument - std::string op = meta.empty() ? argName : meta; - info.maxFlagsWidth = std::max(op.size(), info.maxFlagsWidth); - info.posFlags.push_back(op); - if (arg->showsHelp()) - { - info.posHelps.push_back(helpMsg); - info.posUsage.push_back(op); - } - } - else - { - std::vector < std::string > ops; - const std::vector& argShortFlags = - arg->getShortFlags(); - const std::vector& argLongFlags = arg->getLongFlags(); - for (size_t i = 0, n = argShortFlags.size(); i < n; ++i) - { - s.str(""); - s << mPrefixChar << argShortFlags[i]; - if (argAction == cli::SUB_OPTIONS) - { - if (meta.empty()) - s << ":ARG[=VALUE]"; - else - s << ":" << meta; - } - else if (!meta.empty()) - s << " " << meta; - ops.push_back(s.str()); - } - for (size_t i = 0, n = argLongFlags.size(); i < n; ++i) - { - s.str(""); - s << mPrefixChar << mPrefixChar << argLongFlags[i]; - if (argAction == cli::SUB_OPTIONS) - { - if (meta.empty()) - s << ":ARG[=VALUE]"; - else - s << ":" << meta; - } - else if (!meta.empty()) - s << " " << meta; - ops.push_back(s.str()); - } - if (!ops.empty()) - { - s.str(""); - if (arg->isRequired()) - { - s << ops[0]; - } - else - { - s << "[" << ops[0] << "]"; - } - - if (arg->showsHelp()) - { - info.opUsage.push_back(s.str()); - } - - const std::string opMsg = str::join(ops, ", "); - info.maxFlagsWidth = - std::max(opMsg.size(), info.maxFlagsWidth); - if (arg->showsHelp()) - { - if (arg->isRequired()) - { - info.requiredFlags.push_back(opMsg); - info.requiredHelps.push_back(helpMsg); - } - else - { - info.opFlags.push_back(opMsg); - info.opHelps.push_back(helpMsg); - } - } - } - } - } - info.maxFlagsWidth = std::min(info.maxFlagsWidth, MAX_ARG_LINE_LENGTH); -} diff --git a/externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj b/externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj deleted file mode 100644 index 2baf272d8..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj +++ /dev/null @@ -1,513 +0,0 @@ - - - - - Debug - x64 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Create - Create - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 16.0 - Win32Proj - {9997e895-5161-4ddf-8f3f-099894cb2f21} - codaoss - 10.0 - coda-oss-lite - - - - DynamicLibrary - true - v143 - - - DynamicLibrary - false - v143 - true - - - - - - - - - - - - - - - true - true - AllRules.ruleset - - - false - - - - EnableAllWarnings - true - _DEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 - pch.h - cli\include\;coda_oss\include;config\include\;except\include\;gsl\include\;io\include\;logging\include\;math\include\;math.linear\include\;math.poly\include\;mem\include\;mt\include\;plugin\include\;polygon\include\;re\include\;sio.lite\include\;std\include\;str\include\;sys\include\;tiff\include;types\include\;units\include\ - Use - pch.h - true - Guard - ProgramDatabase - true - true - true - true - true - /Zc:__cplusplus %(AdditionalOptions) - true - - - - - true - - - - - Level3 - true - true - true - NDEBUG;_LIB;%(PreprocessorDefinitions);CODA_OSS_EXPORTS;CODA_OSS_DLL;MT_DEFAULT_PINNING=0;RE_ENABLE_STD_REGEX=1 - pch.h - cli\include\;coda_oss\include;config\include\;except\include\;gsl\include\;io\include\;logging\include\;math\include\;math.linear\include\;math.poly\include\;mem\include\;mt\include\;plugin\include\;polygon\include\;re\include\;sio.lite\include\;std\include\;str\include\;sys\include\;tiff\include;types\include\;units\include\ - Use - pch.h - true - Guard - true - true - true - true - true - /Zc:__cplusplus %(AdditionalOptions) - - - - - true - true - true - - - - - - \ No newline at end of file diff --git a/externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters b/externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters deleted file mode 100644 index 1e84491f2..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/coda-oss-lite.vcxproj.filters +++ /dev/null @@ -1,1229 +0,0 @@ - - - - - - - config - - - config - - - gsl - - - gsl - - - gsl - - - gsl - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - coda_oss - - - except - - - except - - - except - - - except - - - except - - - except - - - except - - - str - - - str - - - str - - - str - - - str - - - str - - - str - - - str - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - types - - - types - - - types - - - types - - - types - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - mem - - - math - - - math - - - math - - - math - - - math - - - units - - - units - - - units - - - math.linear - - - math.linear - - - math.linear - - - math.linear - - - math.linear - - - math.linear - - - math.poly - - - math.poly - - - math.poly - - - math.poly - - - math.poly - - - math.poly - - - math.poly - - - math.poly - - - polygon - - - polygon - - - polygon - - - config - - - include - - - cli - - - cli - - - cli - - - cli - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - avx - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - re - - - re - - - re - - - sio.lite - - - sio.lite - - - sio.lite - - - sio.lite - - - sio.lite - - - sio.lite - - - sio.lite - - - sio.lite - - - sio.lite - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - sio.lite - - - sio.lite - - - plugin - - - plugin - - - plugin - - - sys - - - mem - - - mem - - - std - - - std - - - std - - - config - - - sys - - - sys - - - mt - - - sys - - - sys - - - - - - except - - - except - - - except - - - except - - - str - - - str - - - str - - - str - - - str - - - str - - - str - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - sys - - - types - - - types - - - mem - - - mem - - - math - - - math - - - math - - - math.linear - - - polygon - - - cli - - - cli - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - io - - - mt - - - mt - - - mt - - - mt - - - mt - - - mt - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - logging - - - re - - - re - - - sio.lite - - - sio.lite - - - sio.lite - - - sio.lite - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - tiff - - - plugin - - - sys - - - sys - - - - - {89602880-5929-45e9-a603-d13f81972397} - - - {619ad1da-f21c-4027-9b5d-23f08225b96f} - - - {59f3d9a1-06d3-4779-aef2-cc55223c3017} - - - {3051f4b6-dad4-47ea-b4bd-d25d9e09f782} - - - {44a8dfa7-099c-4dd5-87b6-3b05ce13580b} - - - {d714ac63-ef19-4629-a13f-59b550604842} - - - {d8059280-e435-4365-be67-865195b9e813} - - - {3613caf2-18d1-4af7-bfa0-a3712a44da45} - - - {0e318d08-1ee3-4644-a299-a81e436c9a32} - - - {6d8f380f-54e3-4d0d-bd1a-a2edd0efbaa7} - - - {1bf84676-4c62-4e2b-b943-59bf82f89126} - - - {b3d7f0e3-2e9f-4a19-b181-27cace7536c0} - - - {15f9b62f-d17e-4d84-bc34-de6fd5fbcb33} - - - {f2544ccb-0933-44c7-af39-cd986982af3d} - - - {9050a469-23a5-4da0-92b1-a07a8e52e9fc} - - - {de76f131-1cd6-4c3d-aa9c-37ca3b5079f0} - - - {cc681a99-da96-483e-a92a-eab0ea3a0ec0} - - - {4875d8c0-f285-460a-98a9-38a60f3fcffd} - - - {9720bf2c-6d77-4685-9318-d6e714065c99} - - - {9f9acff4-c149-4908-ae9d-67557974f4ee} - - - {83ae731c-66f7-468c-bc71-7cb57a363b5b} - - - {327a7b72-9a2d-48e4-9c23-2b5b9d2f3519} - - - {d76b6d3f-51f8-4cf8-bc56-35f720080a8b} - - - {387bc6cb-323a-42b3-8502-4fac72586d12} - - - - - gsl - - - gsl - - - gsl - - - gsl - - - gsl - - - gsl - - - gsl - - - gsl - - - gsl - - - gsl - - - std - - - std - - - std - - - std - - - std - - - std - - - std - - - std - - - sys - - - \ No newline at end of file diff --git a/externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h b/externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h deleted file mode 100644 index 271935ab0..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/bit.h +++ /dev/null @@ -1,103 +0,0 @@ -/* ========================================================================= - * This file is part of coda_oss-c++ - * ========================================================================= - * - * (C) Copyright 2020-2022, Maxar Technologies, Inc. - * - * coda_oss-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, http://www.gnu.org/licenses/. - * - */ -#pragma once -#ifndef CODA_OSS_coda_oss_bit_h_INCLUDED_ -#define CODA_OSS_coda_oss_bit_h_INCLUDED_ - -#include -#include -#ifdef __GNUC__ -#include // "These functions are GNU extensions." -#endif - -#include - -#include "coda_oss/namespace_.h" -namespace coda_oss -{ - // https://en.cppreference.com/w/cpp/types/endian - enum class endian - { - #ifdef _WIN32 - little = 0, - big = 1, - native = little - #else - little = __ORDER_LITTLE_ENDIAN__, - big = __ORDER_BIG_ENDIAN__, - native = __BYTE_ORDER__ - #endif - }; - - // https://en.cppreference.com/w/cpp/numeric/byteswap - namespace details - { - // Overloads for common types - inline constexpr uint8_t byteswap(uint8_t val) noexcept - { - return val; // no-op - } - #if defined(_MSC_VER) - // These routines should generate a single instruction; see - // https://devblogs.microsoft.com/cppblog/a-tour-of-4-msvc-backend-improvements/ - inline uint16_t byteswap(uint16_t val) noexcept - { - return _byteswap_ushort(val); - } - inline uint32_t byteswap(uint32_t val) noexcept - { - return _byteswap_ulong(val); - } - inline uint64_t byteswap(uint64_t val) noexcept - { - return _byteswap_uint64(val); - } - #elif defined(__GNUC__) - inline uint16_t byteswap(uint16_t val) noexcept - { - return bswap_16(val); - } - inline uint32_t byteswap(uint32_t val) noexcept - { - return bswap_32(val); - } - inline uint64_t byteswap(uint64_t val) noexcept - { - return bswap_64(val); - } - #else - #error "No platform-specific byteswap()" // TODO: do something else? - #endif - } - - template - inline T byteswap(T n) noexcept - { - // "std::byteswap participates in overload resolution only if T satisfies integral, i.e., T is an integer type. The program is - // ill-formed if T has padding bits." - static_assert(std::is_integral::value, "T must be integral"); - - using unsigned_t = std::make_unsigned_t; // "Since C++14" https://en.cppreference.com/w/cpp/types/make_unsigned - return details::byteswap(static_cast(n)); - } -} - -#endif // CODA_OSS_coda_oss_bit_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h b/externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h deleted file mode 100644 index 6aff3b5d5..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/coda_oss/include/coda_oss/span.h +++ /dev/null @@ -1,78 +0,0 @@ -/* ========================================================================= - * This file is part of coda_oss-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * coda_oss-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ -#pragma once -#ifndef CODA_OSS_coda_oss_span_h_INCLUDED_ -#define CODA_OSS_coda_oss_span_h_INCLUDED_ - -#include - -#include - -#include "coda_oss/namespace_.h" -#include "coda_oss/span_.h" -#include "coda_oss/cstddef.h" // byte - -// Need a fairly decent C++ compiler to use the real GSL. This brings in more than -// we really need for span (e.g., gsl::narrow()), but it keeps things simple. -#include "gsl/gsl.h" // not gsl/span; need #pragma here to turn off warnings - -namespace coda_oss -{ -#if defined(GSL_SPAN_H) // the above #include'd gsl/span - using gsl::span; -#else // no gsl::span, use our own - using details::span; -#endif // GSL_SPAN_H - -// https://en.cppreference.com/w/cpp/container/span/as_bytes -template -inline auto as_bytes(span s) noexcept -{ - // https://en.cppreference.com/w/cpp/types/is_trivially_copyable "... serialized to/from binary files ..." - static_assert(std::is_trivially_copyable::value, "must be 'trivially' copyable."); - - const void* const p_ = s.data(); - auto const p = static_cast(p_); - return span(p, s.size_bytes()); -} -template -inline auto as_bytes(span s) noexcept -{ - const span s_(s.data(), s.size()); - return as_bytes(s_); -} -template -inline span as_writable_bytes(span s) noexcept -{ - // https://en.cppreference.com/w/cpp/types/is_trivially_copyable "... serialized to/from binary files ..." - static_assert(std::is_trivially_copyable::value, "must be 'trivially' copyable."); - - static_assert(!std::is_const::value, "T cannot be 'const'"); - - void* const p_ = s.data(); - auto const p = static_cast(p_); - return span(p, s.size_bytes()); -} - -} - -#endif // CODA_OSS_coda_oss_span_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/config/include/config/Version.h b/externals/nitro/externals/coda-oss/modules/c++/config/include/config/Version.h deleted file mode 100644 index 69944fc0b..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/config/include/config/Version.h +++ /dev/null @@ -1,71 +0,0 @@ -/* ========================================================================= - * This file is part of config-c++ - * ========================================================================= - * - * (C) Copyright 2021, Maxar Technologies, Inc. - * - * config-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ -#ifndef CODA_OSS_config_Version_h_INCLUDED_ -#define CODA_OSS_config_Version_h_INCLUDED_ -#pragma once - -#include - -// Using 1'0000 makes it easy to see the version number in the IDE. -// Note that 1'000 or even 100 won't work of because 2019 (below) ... and it's nice having all fields be four digits -#define CODA_OSS_VERSION_major_ static_cast(1000000000000) // 1'0000'0000'0000 -#define CODA_OSS_VERSION_minor_ static_cast (100000000) // 1'0000'0000 -#define CODA_OSS_VERSION_patch_ static_cast (10000) // 1'0000 -#define CODA_OSS_MAKE_VERSION_MMPB(major, minor, patch, build) (major * CODA_OSS_VERSION_major_) + (minor * CODA_OSS_VERSION_minor_) + (patch * CODA_OSS_VERSION_patch_) + build -static_assert(CODA_OSS_MAKE_VERSION_MMPB(9999, 9999, 9999, 9999) <= UINT64_MAX, "version calculation is wrong."); -#define CODA_OSS_MAKE_VERSION_MMP(major, minor, patch) CODA_OSS_MAKE_VERSION_MMPB(major, minor, patch, 0 /*build*/) - -#define CODA_OSS_GET_VERSION_MAJOR(version) ((version) / CODA_OSS_VERSION_major_) -#define CODA_OSS_GET_VERSION_(version, factor) (((version) / factor) % static_cast(10000)) -#define CODA_OSS_GET_VERSION_MINOR(version) CODA_OSS_GET_VERSION_(version, CODA_OSS_VERSION_minor_) -#define CODA_OSS_GET_VERSION_PATCH(version) CODA_OSS_GET_VERSION_(version, CODA_OSS_VERSION_patch_) -#define CODA_OSS_GET_VERSION_BUILD(version) CODA_OSS_GET_VERSION_(version, 1 /*factor*/) - -// Do this ala C++ ... we don't currently have major/minor/patch -//#define CODA_OSS_VERSION_ 20210910L // c.f. __cplusplus -#define CODA_OSS_VERSION_ 2023 ## 0006 ## 0005 ## 0000 ## L - -// Use the same macros other projects might want to use; overkill for us. -#define CODA_OSS_VERSION_MAJOR 2023 -#define CODA_OSS_VERSION_MINOR 6 -#define CODA_OSS_VERSION_PATCH 5 -#define CODA_OSS_VERSION_BUILD 0 -#define CODA_OSS_VERSION CODA_OSS_MAKE_VERSION_MMPB(CODA_OSS_VERSION_MAJOR, CODA_OSS_VERSION_MINOR, CODA_OSS_VERSION_PATCH, CODA_OSS_VERSION_BUILD) - -namespace config -{ -constexpr auto coda_oss_version = CODA_OSS_VERSION; -constexpr auto coda_oss_version_major = CODA_OSS_GET_VERSION_MAJOR(CODA_OSS_VERSION); -constexpr auto coda_oss_version_minor = CODA_OSS_GET_VERSION_MINOR(CODA_OSS_VERSION); -constexpr auto coda_oss_version_patch = CODA_OSS_GET_VERSION_PATCH(CODA_OSS_VERSION); -constexpr auto coda_oss_version_build = CODA_OSS_GET_VERSION_BUILD(CODA_OSS_VERSION); - -// Be sure the macros above are correct -static_assert(CODA_OSS_VERSION == CODA_OSS_VERSION_, "version calculation is wrong."); -static_assert(CODA_OSS_VERSION == coda_oss_version, "version calculation is wrong."); -static_assert(CODA_OSS_VERSION_MAJOR == coda_oss_version_major, "version calculation is wrong."); -static_assert(CODA_OSS_VERSION_MINOR ==coda_oss_version_minor, "version calculation is wrong."); -static_assert(CODA_OSS_VERSION_PATCH == coda_oss_version_patch, "version calculation is wrong."); -static_assert(CODA_OSS_VERSION_BUILD == coda_oss_version_build, "version calculation is wrong."); -} - -#endif // CODA_OSS_config_Version_h_INCLUDED_ \ No newline at end of file diff --git a/externals/nitro/externals/coda-oss/modules/c++/mt/include/mt/RequestQueue.h b/externals/nitro/externals/coda-oss/modules/c++/mt/include/mt/RequestQueue.h deleted file mode 100644 index ad33a53a1..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/mt/include/mt/RequestQueue.h +++ /dev/null @@ -1,146 +0,0 @@ -/* ========================================================================= - * This file is part of mt-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * mt-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#ifndef __MT_REQUEST_QUEUE_H__ -#define __MT_REQUEST_QUEUE_H__ - -#include -#include "sys/Thread.h" -#include "sys/ConditionVar.h" -#include "sys/Mutex.h" -#include "sys/Dbg.h" - -namespace mt -{ - -/*! - * - * \class RequestQueue - * \brief Locked, dual condition request queue - * - * This is a generic class for locked buffers. Stick - * anything in T and it will be protected by a queue lock - * and two condition variables. When you call dequeue, this - * class blocks until there is data (there is a critical section). - * - * This class is the basis for the two provided thread pool APIs, - * AbstractThreadPool and BasicThreadPool - * - * - */ - -template -struct RequestQueue -{ - //! Default constructor - RequestQueue() : - mAvailableSpace(&mQueueLock), - mAvailableItems(&mQueueLock) - { - } - - // Put a (copy of, unless T is a pointer) request on the queue - void enqueue(T request) - { -#ifdef THREAD_DEBUG - dbg_printf("Locking (enqueue)\n"); -#endif - mQueueLock.lock(); - mRequestQueue.push(request); -#ifdef THREAD_DEBUG - dbg_printf("Unlocking (enqueue), new size [%d]\n", mRequestQueue.size()); -#endif - mQueueLock.unlock(); - - mAvailableItems.signal(); - } - - // Retrieve (by reference) T from the queue. blocks until ok - void dequeue(T& request) - { -#ifdef THREAD_DEBUG - dbg_printf("Locking (dequeue)\n"); -#endif - mQueueLock.lock(); - while (isEmpty()) - { - mAvailableItems.wait(); - } - - request = mRequestQueue.front(); - mRequestQueue.pop(); - -#ifdef THREAD_DEBUG - dbg_printf("Unlocking (dequeue), new size [%d]\n", mRequestQueue.size()); -#endif - mQueueLock.unlock(); - mAvailableSpace.signal(); - } - - // Check to see if its empty - bool isEmpty() const - { - return mRequestQueue.empty(); - } - - // Check the length - int length() const - { - return mRequestQueue.size(); - } - - void clear() - { -#ifdef THREAD_DEBUG - dbg_printf("Locking (dequeue)\n"); -#endif - mQueueLock.lock(); - while (!isEmpty()) - { - mRequestQueue.pop(); - } - -#ifdef THREAD_DEBUG - dbg_printf("Unlocking (dequeue), new size [%d]\n", mRequestQueue.size()); -#endif - mQueueLock.unlock(); - mAvailableSpace.signal(); - } - - RequestQueue(const RequestQueue&) = delete; - RequestQueue& operator=(const RequestQueue&) = delete; - -private: - //! The internal data structure - std::queue mRequestQueue; - //! The synchronizer - sys::Mutex mQueueLock; - //! This condition is "is there space?" - sys::ConditionVar mAvailableSpace; - //! This condition is "is there an item?" - sys::ConditionVar mAvailableItems; -}; - -typedef RequestQueue RunnableRequestQueue; -} - -#endif // __MT_REQUEST_QUEUE_H__ diff --git a/externals/nitro/externals/coda-oss/modules/c++/net/source/URL.cpp b/externals/nitro/externals/coda-oss/modules/c++/net/source/URL.cpp deleted file mode 100644 index 8791e0c6b..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/net/source/URL.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* ========================================================================= - * This file is part of net-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * net-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include "net/URL.h" -#include -#include - -net::URL::URL(std::string url) -{ - if (!url.empty()) - set(url); -} - -net::URL& net::URL::operator=(const URL& url) -{ - if (this != &url) - { - mProtocol = url.getProtocol(); - mHost = url.getHost(); - setPort(url.getPort()); - mPath = url.getPath(); - mFragment = url.getFragment(); - mParams = net::URLParams(url.getParams().toString()); - } - return *this; -} -net::URL::URL(const URL& url) -{ - *this = url; -} - -void net::URL::set(std::string url) -{ - std::vector parts = net::urlSplit(url); - mProtocol = parts[0]; - mHost = parts[1]; - setPort(parts[2].empty() ? -1 : str::toType(parts[2])); - mPath = parts[3]; - std::string params = parts[4]; - mFragment = parts[5]; - mParams = net::URLParams(params); -} - -void net::URL::setPort(int port) -{ - mPort = port; - if (mPort < 0) - mPort = net::getStandardPort(getProtocol()); -} - -std::string net::URL::getProtocol() const -{ - return mProtocol; -} -std::string net::URL::getHost() const -{ - return mHost; -} -int net::URL::getPort() const -{ - return mPort; -} -std::string net::URL::getPath() const -{ - return mPath; -} -std::string net::URL::getFragment() const -{ - return mFragment; -} -std::string net::URL::getQuery() const -{ - return mParams.toString(); -} - -std::string net::URL::getDocument() const -{ - std::ostringstream doc; - std::string path = getPath(); - if (!str::startsWith(path, "/")) - doc << "/"; - doc << path; - std::string query = getQuery(); - if (!query.empty()) - doc << "?" << query; - std::string fragment = getFragment(); - if (!fragment.empty()) - doc << "#" << fragment; - return doc.str(); -} - -std::string net::URL::getServer() const -{ - std::ostringstream server; - server << getHost(); - int port = getPort(); - if (port >= 0) - server << ":" << port; - return server.str(); -} - -std::string net::URL::toString() const -{ - return net::urlJoin(getProtocol(), getHost(), getPort(), getPath(), - getQuery(), getFragment()); -} - -bool net::URL::operator==(const net::URL& url) const -{ - return toString() == url.toString(); -} - -net::URLParams::URLParams(std::string paramString) -{ - if (!paramString.empty()) - { - str::Tokenizer tokenizer(paramString, "&;"); //can be & or ; - str::Tokenizer::Tokens& paramParts = - (str::Tokenizer::Tokens&) tokenizer; - for (size_t i = 0, size = paramParts.size(); i < size; ++i) - { - std::string param = paramParts[i]; - std::string val = ""; - size_t pos = param.find("="); - if (pos > 0) - { - std::string key = param.substr(0, pos); - val = (pos < (param.length() - 1)) ? param.substr(pos + 1) : ""; - param = key; - } - add(param, val); - } - } -} - -bool net::URLParams::contains(std::string key) const -{ - net::URLParams::Params::const_iterator it = mParams.find(key); - return it != mParams.end() && it->second.size() > 0; -} - -net::URLParams::ParamValues& net::URLParams::get(std::string key) -{ - net::URLParams::Params::iterator it = mParams.find(key); - if (it == mParams.end() || it->second.empty()) - throw except::NoSuchKeyException(Ctxt(key)); - return it->second; -} - -const net::URLParams::ParamValues& net::URLParams::get(std::string key) const -{ - net::URLParams::Params::const_iterator it = mParams.find(key); - if (it == mParams.end() || it->second.empty()) - throw except::NoSuchKeyException(Ctxt(key)); - return it->second; -} -std::string net::URLParams::getFirst(std::string key) const -{ - net::URLParams::Params::const_iterator it = mParams.find(key); - if (it == mParams.end() || it->second.empty()) - throw except::NoSuchKeyException(Ctxt(key)); - return it->second.front(); -} -void net::URLParams::add(std::string key, std::string value) -{ - if (mParams.find(key) == mParams.end()) - mParams[key] = net::URLParams::ParamValues(); - mParams[key].push_back(value); -} -void net::URLParams::remove(std::string key) -{ - if (mParams.find(key) != mParams.end()) - mParams.erase(key); -} - -std::string net::URLParams::toString() const -{ - std::ostringstream s; - bool firstParam = true; - for (net::URLParams::Params::const_iterator it = mParams.begin(); it - != mParams.end(); ++it) - { - std::string key = it->first; - const net::URLParams::ParamValues& vals = it->second; - for (net::URLParams::ParamValues::const_iterator it2 = vals.begin(); it2 - != vals.end(); ++it2) - { - if (!firstParam) - s << "&"; - s << net::quote(key) << "=" << net::quote(*it2); - firstParam = false; - } - } - return s.str(); -} diff --git a/externals/nitro/externals/coda-oss/modules/c++/polygon/include/polygon/Intersections.h b/externals/nitro/externals/coda-oss/modules/c++/polygon/include/polygon/Intersections.h deleted file mode 100644 index d73ac1f6d..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/polygon/include/polygon/Intersections.h +++ /dev/null @@ -1,288 +0,0 @@ -/* ========================================================================= - * This file is part of polygon-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2019, MDA Information Systems LLC - * - * polygon-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ -#ifndef __POLYGON_INTERSECTIONS_H__ -#define __POLYGON_INTERSECTIONS_H__ - -#include -#include -#include - -#include -#include - -namespace polygon -{ -/*! - * \class Intersections - * \brief Given a list of points, draws lines between them to create a - * polygon. Then, given a row, reports the columns that the resulting - * polygon intersects that row at. - * \tparam PointT Data type of points. Must be a floating type (float/double) - * to work properly - * - * \note Implementation uses horizontal "scan lines" to determine - * whether or not an element is inside the polygon's edges. As a result, - * polygon vertices cannot be exactly on the scanlines. The polygon vertices - * are bumped "down" if they have integral row indices to avoid falling - * directly on a scanline. Since the fill algorithm is conservative, - * horizontal-top-edges will typically not be filled in. For instance, a - * square will have 1 pixel of its top edge missing. - */ -template -struct Intersections final -{ - /*! - * \class Intersection - * \brief Represents an intersection - */ - struct Intersection final - { - //! First (inclusive) column - size_t first; - - //! Last (inclusive) column - size_t last; - - //! \return Number of columns - size_t length() const noexcept - { - return last - first + 1; - } - }; - - /*! - * \param points List of points - * \param dims Dimensions to compute a polygon over. If the provided - * points are not completely within these dimensions, the polygon will - * simply be truncated at the dimension boundary. - * \param offset Offset to apply to all input points. Positive row - * value shifts the polygon up (equivalently the frame shifts down), and - * positive col value shifts the polygon left (equiv. the frame shifts - * right). Defaults to no offset. - */ - Intersections(const std::vector >& points, - const types::RowCol& dims, - types::RowCol offset = - types::RowCol(0, 0)) : - mDims(dims) - { - if (!points.empty()) - { - computeIntersections(points, dims, offset); - } - } - - /*! - * \param row Row to get intersections for - * \param[out] intersections Polygon intersections for this row. If the - * vector is empty, that means the polygon does not intersect at this row. - */ - void get(size_t row, std::vector& intersections) const - { - // Clear out any old intersections in the vector we're given - intersections.clear(); - - if (row >= mIntersections.size()) - { - // Could be because of no points or this is a row greater than - // we computed for - return; - } - - const std::vector& interRow(mIntersections[row]); - if (interRow.empty() || interRow.size() % 2 != 0) - { - // No intersections on this row - return; - } - - const size_t numPairs = interRow.size() / 2; - for (size_t pair = 0, idx = 0; pair < numPairs; ++pair) - { - double first = static_cast(interRow[idx++]); - double last = static_cast(interRow[idx++]); - - // If the pair of intersections lies outside of the image, - // there is no intersection for this pair. - const auto lastCol = static_cast(mDims.col - 1); - if ((first < 0.0 && last < 0.0) || - (first > lastCol && last > lastCol)) - { - continue; - } - - // Clamp the intersections to the image boundary - first = std::max(0.0, std::min(lastCol, first)); - last = std::max(0.0, std::min(lastCol, last)); - - Intersection intersection; - intersection.first = static_cast(std::ceil(first)); - intersection.last = static_cast(std::floor(last)); - - if(intersection.last > intersection.first) - { - intersections.push_back(intersection); - } - else - { - if (first < last) - { - // This happens when first = 55.01, last = 55.99 - // Then intersection.first = 56, intersection.last = 55 - // We should count 55 as an intersection - intersection.first = intersection.last; - intersections.push_back(intersection); - } - } - } - } - -private: - void orderPoints(PointT& r0, PointT& c0, PointT& r1, PointT& c1) - { - if (r0 > r1) - { - std::swap(r0, r1); - std::swap(c0, c1); - } - } - - void computeIntersections( - const std::vector >& points, - const types::RowCol& dims, - types::RowCol offset) - { - std::vector > shiftedPoints(points); - for (auto&& shiftedPoint : shiftedPoints) - { - // Get the polygon points with respect to the offset - shiftedPoint -= offset; - - // TODO: The original implementation did this (plus subtracted 0.5 - // from each row and col which we're not doing here). - // Without this small delta, if you have points that are - // right on a row, we skip drawing some rows - // (test_draw_polygon will illustrate this). I wonder if we - // could tweak the sl0 and sl1 logic to avoid this. - PointT& rowPoint(shiftedPoint.row); - if (std::floor(rowPoint) == rowPoint) - { - // Add small amount to move it off the scan line - rowPoint += 0.0001; - } - } - - // We need to get all scanline intersections of polygon edges - mIntersections.resize(dims.row); - - const auto lastRow = gsl::narrow(dims.row) - 1; - - for (size_t ii = 0; ii < shiftedPoints.size(); ++ii) - { - PointT r1(shiftedPoints[ii].row); - PointT c1(shiftedPoints[ii].col); - - const size_t idx = (ii == 0) ? shiftedPoints.size() - 1 : ii - 1; - PointT r0(shiftedPoints[idx].row); - PointT c0(shiftedPoints[idx].col); - - // Skip horizontal lines - if (r1 == r0) - { - continue; - } - - // Make sure r0 < r1 - orderPoints(r0, c0, r1, c1); - - // Find first and last scan line that we cross - sys::SSize_T sl0 = static_cast(std::ceil( - static_cast(r0))); - - sys::SSize_T sl1 = static_cast(std::floor( - static_cast(r1))); - - // Skip rows where the edge intersects scan line outside of image - // Have to do this carefully though... we can't just restrict both - // sl0 and sl1 to be in the [0, lastRow] range because if they were - // both negative or both > lastRow, we'd end up capping them both - // in-bounds and going through the for loop below one time, putting - // on a bogus point which is going to mess us up later. - // Instead, first we do a sanity check to see if both points are out - // of bounds... if so, we skip to the next set of points. - if (sl0 > lastRow || sl1 < 0) - { - continue; - } - - // Now that we know that at least some of our data is in bounds - // we CAN cap to [0, lastRow]. - if (sl0 < 0) - { - sl0 = 0; - } - if (sl1 > lastRow) - { - sl1 = lastRow; - } - - // Calculate rate of change - const PointT dcdr = (c1 - c0) / (r1 - r0); - - // Calculate intersections - // We do not clamp to the image dimensions at this time -- this is - // done inside get(), and allows us to determine if intersection - // pairs lie fully outside of the image. Clamping here ambiguates - // that situation. - for (sys::SSize_T row = sl0; row <= sl1; ++row) - { - const auto delt = static_cast(row) - r0; - const auto sli = c0 + delt * dcdr; - mIntersections[gsl::narrow(row)].push_back(sli); - } - } - - // We're going to need these sorted eventually - might as well do it - // now - for (size_t row = 0; row < mIntersections.size(); ++row) - { - std::vector& interRow(mIntersections[row]); - if (interRow.size() % 2 == 0) - { - std::sort(interRow.begin(), interRow.end()); - } - } - } - - // `const` member data means copy/move must be implemented - Intersections(const Intersections&) = delete; - Intersections& operator=(const Intersections&) = delete; - Intersections(Intersections&&) = delete; - Intersections& operator=(Intersections&&) = delete; - -private: - const types::RowCol mDims; - std::vector > mIntersections; -}; -} - -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/sio.lite/source/FileHeader.cpp b/externals/nitro/externals/coda-oss/modules/c++/sio.lite/source/FileHeader.cpp deleted file mode 100644 index 8a7c8a40f..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sio.lite/source/FileHeader.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* ========================================================================= - * This file is part of sio.lite-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sio.lite-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ -#include "sio/lite/FileHeader.h" - -// magic + nl + ne + et + es -const int SIO_HEADER_LENGTH = 20; - -std::string sio::lite::FileHeader::getElementTypeAsString() const -{ - std::string type; - // Switch on the enumerated type and produce something useful - switch ( et ) - { - case UNSIGNED: - type = "Unsigned byte"; - break; - case SIGNED: - type = "Signed byte"; - break; - case FLOAT: - type = "Float"; - break; - case COMPLEX_UNSIGNED: - type = "Complex unsigned"; - break; - case COMPLEX_SIGNED: - type = "Complex signed"; - break; - case COMPLEX_FLOAT: - type = "Complex float"; - break; - case N_BYTE_UNSIGNED: - type = "N-Byte unsigned"; - break; - case N_BYTE_SIGNED: - type = "N-Byte signed"; - break; - default: - type = "Unknown type"; - - } - return type; -} - -long sio::lite::FileHeader::getLength() const -{ - size_t length = SIO_HEADER_LENGTH; - - if (userData.size() > 0) - length += 4; //num fields int - for (sio::lite::UserDataDictionary::ConstIterator it = userData.begin(); - it != userData.end(); ++it) - { - length += 4; //key size - length += it->first.length(); //key data - if (idsAreNullTerminated()) - length += 1; //1 (null-byte) - length += 4; //data size - length += it->second.size(); //num bytes of data - } - return static_cast(length); -} - - -bool sio::lite::FileHeader::userDataFieldExists(const std::string& key) const -{ - return userData.exists(key); -} - -void sio::lite::FileHeader::getAllUserDataFields( - std::vector& keys) const -{ - for (sio::lite::UserDataDictionary::ConstIterator p = userData.begin(); - p != userData.end(); ++p) - keys.push_back(p->first); -} - -std::vector& sio::lite::FileHeader::getUserData(const std::string& key) -{ - if (!userData.exists(key)) - throw except::NoSuchKeyException(key); - return userData[key]; -} - - -void sio::lite::FileHeader::to(size_t numBands, io::OutputStream& os) -{ - if (numBands <= 0) numBands = 1; - //compare the input numBands to the elementType - - int elementType = et; - int elementSize = es; - - if (numBands > 2) - { - if (elementType == sio::lite::FileHeader::UNSIGNED) - { - elementType = sio::lite::FileHeader::N_BYTE_UNSIGNED; - elementSize *= static_cast(numBands); - } - else if (elementType == sio::lite::FileHeader::SIGNED) - { - elementType = sio::lite::FileHeader::N_BYTE_SIGNED; - elementSize *= static_cast(numBands); - } - /*! - * To really handle this properly, we need to know - * how to lay out the bands for them. For instance, - * If the bands were 'interleaved by pixel' we would - * expect that numElems would be multiplied by numBands - * - * For now, we punt... - */ - else - nl *= static_cast(numBands); - } - - if (elementType != sio::lite::FileHeader::UNSIGNED && elementType != sio::lite::FileHeader::SIGNED && - elementType != sio::lite::FileHeader::FLOAT && elementType != sio::lite::FileHeader::COMPLEX_UNSIGNED && - elementType != sio::lite::FileHeader::COMPLEX_SIGNED && elementType != sio::lite::FileHeader::COMPLEX_FLOAT && - elementType != sio::lite::FileHeader::N_BYTE_UNSIGNED && elementType != sio::lite::FileHeader::N_BYTE_SIGNED) - throw except::Exception(Ctxt("Unknown element type")); - - //update the version based on the user data fields - version = getNumUserDataFields() > 0 ? 2 : 1; - - //construct the magic byte - int magic = (255 - version) | 127 << 8 | version << 16 | 255 << 24; - - os.write((const sys::byte*)&magic, 4); - os.write((const sys::byte*)&nl, 4); - os.write((const sys::byte*)&ne, 4); - os.write((const sys::byte*)&elementType, 4); - os.write((const sys::byte*)&elementSize, 4); - - if (version > 1) - writeUserData(os); -} - -void sio::lite::FileHeader::writeUserData(io::OutputStream& os) -{ - const auto numFields = static_cast(userData.size()); - os.write((const sys::byte*)&numFields, 4); - - for(sio::lite::UserDataDictionary::Iterator it = userData.begin(); - it != userData.end(); ++it) - { - std::string key = it->first; - //add 1 for null-byte termination - const auto keySize = static_cast(key.length() + 1); - os.write((const sys::byte*)&keySize, 4); - os.write((const sys::byte*)key.c_str(), keySize); - - std::vector& uData = it->second; - const auto udSize = static_cast(uData.size()); - os.write((const sys::byte*)&udSize, 4); - - //Do we need to check for endian-ness and possibly byteswap??? - for (std::vector::iterator iter = uData.begin(); - iter != uData.end(); ++iter) - { - sys::byte x = *iter; - os.write(&x, 1); - } - } -} - -void sio::lite::FileHeader::addUserData(const std::string& field, - const std::string& data) -{ - const sys::byte* const begin = - reinterpret_cast(data.c_str()); - - const std::vector vec(begin, begin + data.length()); - userData.add(field, vec); -} - - -void sio::lite::FileHeader::addUserData(const std::string& field, - const std::vector& data) -{ - userData.add(field, data); -} - -void sio::lite::FileHeader::addUserData(const std::string& field, int data) -{ - std::vector vec; - vec.reserve(sizeof(int)); - char* cData = (char*)&data; - for (int i = 0, size = sizeof(int); i < size; ++i) - vec.push_back((sys::byte)cData[i]); - userData.add(field, vec); -} - diff --git a/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Format.h b/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Format.h deleted file mode 100644 index 240943807..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Format.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ========================================================================= - * This file is part of str-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * str-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef __STR_FORMAT_H__ -#define __STR_FORMAT_H__ - -#include -#include - -#include "config/Exports.h" - -namespace str -{ - -/*! - * \param format The format - * \param ... Any printf like thing - */ -CODA_OSS_API std::string format(const char* format, ...); - -struct CODA_OSS_API Format final -{ - Format(const char* format, ...); - - operator std::string() const - { - return mString; - } - - operator std::string& () noexcept - { - return mString; - } - -protected: - std::string mString; -}; - -} -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Manip.h b/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Manip.h deleted file mode 100644 index 0e942d91e..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Manip.h +++ /dev/null @@ -1,210 +0,0 @@ -/* ========================================================================= - * This file is part of str-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * str-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#ifndef __STR_MANIP_H__ -#define __STR_MANIP_H__ - -#include -#include - -#include -#include - -#include "config/compiler_extensions.h" -#include "config/Exports.h" -#include "coda_oss/CPlusPlus.h" -#include "coda_oss/string.h" -#include "str/Convert.h" - -namespace str -{ - -CODA_OSS_disable_warning_push -#if _MSC_VER -#pragma warning(disable: 26460) //The reference argument 's' for function 'str::data' can be marked as const (con.3). -#endif - // non-const overload for .data() in C++17 -template -inline CharT* data(std::basic_string& s) noexcept -{ - return s.data(); -} -CODA_OSS_disable_warning_pop -template -inline const CharT* data(const std::basic_string& s) noexcept // to make generic programming easier -{ - return s.data(); -} - -/** - * Trim the white space off the back and front of a string - * @param s String to trim - */ -CODA_OSS_API void trim(std::string& s); -CODA_OSS_API std::string trim(const std::string& s); -CODA_OSS_API void trim(coda_oss::u8string& s); -CODA_OSS_API coda_oss::u8string trim(const coda_oss::u8string& s); - -/** - * Checks the end of s with match - * @param s String to check - * @param match String to compare with - * @return true if it matches, otherwise false - */ -CODA_OSS_API bool endsWith(const std::string& s, const std::string& match); -CODA_OSS_API bool ends_with(const std::string& s, const std::string&) noexcept; - -/** - * Checks the start of s with match - * @param s String to check - * @param s String to compare with - * @return true if it matches, otherwise false - */ -CODA_OSS_API bool startsWith(const std::string& s, const std::string& match); -CODA_OSS_API bool starts_with(const std::string& s, const std::string&) noexcept; - - -/** - * finds the first instance of "search" and - * substitutes it for "replace", it then returns - * the start of search, so you can loop and replace - * all instances of "search". - * @param str String to check - * @param search String to search for - * @param replace String to replace with - * @param start starting position to start search - * @return position of first find, str.length() if not found - */ -CODA_OSS_API size_t replace(std::string& str, - const std::string& search, - const std::string& replace, - size_t start = 0); - -/** - * finds all instances of "search" and - * substitutes them for "replace" - * @param string String to check - * @param search String to search for - * @param replace String to replace with - */ -CODA_OSS_API void replaceAll(std::string& string, - const std::string& search, - const std::string& replace); - -/** - * Returns true if the string contains the match - */ -CODA_OSS_API bool contains(const std::string& str, const std::string& match); - - -/** - * Returns true if the string contains only letters. - */ -CODA_OSS_API bool isAlpha(const std::string& s); - -/** - * Returns true if the string contains only letters and spaces. - */ -CODA_OSS_API bool isAlphaSpace(const std::string& s); - -/** - * Returns true if the string contains only digits. This does not include - * decimal points. - */ -CODA_OSS_API bool isNumeric(const std::string& s); - -/** - * Returns true if the string contains only digits and spaces. - */ -CODA_OSS_API bool isNumericSpace(const std::string& s); - -/** - * Returns true if the string contains only whitespace characters (or empty). - */ -CODA_OSS_API bool isWhitespace(const std::string& s); - -/** - * Returns true if the string contains only letters and digits. - */ -CODA_OSS_API bool isAlphanumeric(const std::string& s); - -/** - * Returns true if the string contains only ASCII printable characters. - */ -CODA_OSS_API bool isAsciiPrintable(const std::string& s); - -/** - * Returns true if the string contains only the given allowed characters. - */ -CODA_OSS_API bool containsOnly(const std::string& s, const std::string& validChars); - -/** - * Splits a string based on a splitter string. Similar to tokenization, except - * the splitter string can be of any length. - * @param s String to check - * @param splitter String to split upon - * @return vector of strings - */ -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); - -/*! - * Replaces any characters that are invalid in XML (&, <, >, ', ") with their - * escaped counterparts - */ -CODA_OSS_API void escapeForXML(std::string& str); - -template -inline std::string join(const std::vector& toks, const std::string& with) -{ - if (toks.empty()) - return ""; - - const auto len = toks.size(); - std::ostringstream oss; - size_t i = 0; - for (; i < len - 1; i++) - { - oss << str::toString(toks[i]) << with; - } - oss << str::toString(toks[i]); - return oss.str(); -} - -// CASE INSENSTIVE string comparision routines. -// Short names w/o a "case insenstive" indicator would seem OK as -// normal (i.e., case sensitive) comparisons will use `==` and `!=` operators. -// -// Note that calling ne() directly can be faster than !eq() because the -// comparison can stop as soon as a mis-match is found. -CODA_OSS_API bool eq(const std::string& lhs, const std::string& rhs) noexcept; -CODA_OSS_API bool ne(const std::string& lhs, const std::string& rhs) noexcept; - -} - -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Tokenizer.h b/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Tokenizer.h deleted file mode 100644 index 4433b1fdc..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/str/include/str/Tokenizer.h +++ /dev/null @@ -1,77 +0,0 @@ -/* ========================================================================= - * This file is part of str-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * str-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef __STR_TOKENIZER_H__ -#define __STR_TOKENIZER_H__ - -/*! - * \file Tokenizer.h - * \brief A class functor for string tokenization - * - * Provides the implemenation of the Tokenizer class, which is - * a function object that can do tokenization base on a delimiter - * - */ - -#include -#include - -namespace str -{ - -/*! - * \class Tokenizer - * \brief A class functor for string tokenization - * - * By specifying a set of delimiters and an input string, - * the user can tokenize using this method. - * example: vector v = Tokenizer(str, ";"); - * - * - */ - -class Tokenizer -{ -public: - typedef std::vector Tokens; - /*! - * Constructor. Take a string to parse, and a delimiter set - * \param str String to parse - * \param delim string to divide str up using - */ - Tokenizer(const std::string& str, const std::string& delim); - - /*! - * Method to return the resultant vector - * \return The vector that was created by the tokenizer - */ - operator Tokenizer::Tokens& () noexcept - { - return vec; - } -protected: - Tokenizer::Tokens vec; -}; - -} -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/str/source/Manip.cpp b/externals/nitro/externals/coda-oss/modules/c++/str/source/Manip.cpp deleted file mode 100644 index 33cbb47c1..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/str/source/Manip.cpp +++ /dev/null @@ -1,359 +0,0 @@ -/* ========================================================================= - * This file is part of str-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * str-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ -#include "str/Manip.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "str/Convert.h" -#include "str/Encoding.h" - -namespace -{ -char transformCheck(int c, int (*transform)(int)) -{ - // Ensure the character can be represented - // as an unsigned char or is 'EOF', as the - // behavior for all other characters is undefined - if ((c >= 0 && c <= UCHAR_MAX) || c == EOF) - { - return static_cast(transform(c)); - } - else - { - // Invalid char for transform: no-op - return static_cast(c); - } -} - -char tolowerCheck(char c) -{ - return transformCheck(c, tolower); -} - -char toupperCheck(char c) -{ - return transformCheck(c, toupper); -} -} - - -namespace str -{ - -// TODO: https://stackoverflow.com/questions/31959532/best-way-to-remove-white-spaces-from-stdstring -template -inline void trim_(std::basic_string & s) -{ - size_t i; - for (i = 0; i < s.length(); i++) - { - if (!iswspace(static_cast(s[i]))) - break; - } - s.erase(0, i); - - for (i = s.length() - 1; (int) i >= 0; i--) - { - if (!iswspace(static_cast(s[i]))) - break; - - } - if (i + 1 < s.length()) - s.erase(i + 1); -} -void trim(std::string& s) -{ - trim_(s); -} -std::string trim(const std::string& str) -{ - auto retval = str; - trim(retval); - return retval; -} -void trim(coda_oss::u8string& s) -{ - trim_(s); -} -coda_oss::u8string trim(const coda_oss::u8string& str) -{ - auto retval = str; - trim(retval); - return retval; -} - -bool ends_with(const std::string& s, const std::string& match) noexcept -{ - const size_t mLen = match.length(); - const size_t sLen = s.length(); - for (size_t i = 0; i < sLen && i < mLen; ++i) - if (!(s[sLen - i - 1] == match[mLen - i - 1])) - return false; - return sLen >= mLen; -} -bool endsWith(const std::string& s, const std::string& match) -{ - return ends_with(s, match); -} - -bool starts_with(const std::string& s, const std::string& match) noexcept -{ - const size_t mLen = match.length(); - const size_t sLen = s.length(); - for (size_t i = 0; i < sLen && i < mLen; ++i) - if (!(s[i] == match[i])) - return false; - return sLen >= mLen; -} -bool startsWith(const std::string& s, const std::string& match) -{ - return starts_with(s, match); -} - -size_t replace(std::string& str, - const std::string& search, - const std::string& replace, - size_t start) -{ - size_t index = str.find(search, start); - - if (index != std::string::npos) - { - // ASAN error: str.replace(index, search.length(), replace); - str = str.substr(0, index) + replace + str.substr(index + search.length()); - start = index; - } - else - { - start = str.length(); - } - - return start; -} - -void replaceAll(std::string& string, - const std::string& search, - const std::string& replace) -{ - size_t start = 0; - while (start < string.length()) - { - start = str::replace(string, search, replace, start); - // skip ahead -- - // avoids inifinite loop if replace contains search - start += replace.length(); - } -} - -bool contains(const std::string& str, const std::string& match) -{ - return str.find(match) != std::string::npos; -} - -static inline bool isTest(const std::string& s, int (*is)(int)) -{ - for (const auto& ch : s) - { - if (!is(ch)) - return false; - } - return !s.empty(); -} - -bool isAlpha(const std::string& s) -{ - return isTest(s, isalpha); -} - -template -static inline bool isTest(const std::string& s, int (*is1)(int), Pred is2) -{ - for (const auto& ch : s) - { - if (!is1(ch) && !is2(ch)) - return false; - } - return !s.empty(); -} - -bool isAlphaSpace(const std::string& s) -{ - return isTest(s, isalpha, isspace); -} - -bool isNumeric(const std::string& s) -{ - return isTest(s, isdigit); -} - -bool isNumericSpace(const std::string& s) -{ - return isTest(s, isdigit, isspace); -} - -bool isWhitespace(const std::string& s) -{ - for (const auto& ch : s) - { - if (!isspace(ch)) - return false; - } - return true; -} - -bool isAlphanumeric(const std::string& s) -{ - return isTest(s, isalpha, isdigit); -} - -bool isAsciiPrintable(const std::string& s) -{ - for (const auto& ch : s) - { - char c = ch; - if (c < 32 || c > 126) - return false; - } - return true; -} - -bool containsOnly(const std::string& s, const std::string& validChars) -{ - typedef std::string::const_iterator StringIter; - std::vector chars(255, false); - for (StringIter it = validChars.begin(); it != validChars.end(); ++it) - chars[(unsigned int)*it] = true; - for (StringIter it = s.begin(); it != s.end(); ++it) - if (!chars[(unsigned int)*it]) - return false; - return true; -} - -std::vector split(const std::string& s, - const std::string& splitter, size_t maxSplit) -{ - std::vector < std::string > vec; - const auto str_l = s.length(); - const auto split_l = splitter.length(); - size_t pos = 0; - while (pos < str_l && maxSplit != 1) - { - auto nextPos = s.find(splitter, pos); - if (nextPos == std::string::npos) - nextPos = str_l; - if (nextPos != pos) - vec.push_back(s.substr(pos, nextPos - pos)); - pos = nextPos + split_l; - if (maxSplit != std::string::npos && vec.size() >= maxSplit - 1) - break; - } - - if (pos < str_l) - vec.push_back(s.substr(pos)); - - return vec; -} -template -inline void transform(std::basic_string& s, Fn f) -{ - (void) std::transform(s.begin(), s.end(), s.begin(), f); -} -void lower(std::string& s) -{ - transform(s, tolowerCheck); -} -void upper(std::string& s) -{ - transform(s, toupperCheck); -} - -void escapeForXML(std::string& str) -{ - // & needs to be first or else it'll mess up the other characters that we - // replace - replaceAll(str, "&", "&"); - replaceAll(str, "<", "<"); - replaceAll(str, ">", ">"); - replaceAll(str, "\"", """); - replaceAll(str, "'", "'"); - replaceAll(str, "\n", " "); - replaceAll(str, "\r", " "); -} - -// https://en.cppreference.com/w/cpp/string/char_traits -class ci_char_traits final : public std::char_traits -{ - static auto to_upper(char ch) noexcept - { - return toupperCheck(ch); - } - - static int compare(const char* s1, const char* s2, std::size_t n) noexcept - { - while (n-- != 0) - { - if (to_upper(*s1) < to_upper(*s2)) - return -1; - if (to_upper(*s1) > to_upper(*s2)) - return 1; - ++s1; - ++s2; - } - return 0; - } - - public: - static int compare(const std::string& s1, const std::string& s2) noexcept - { - if (s1.length() < s2.length()) - { - return -1; - } - if (s1.length() > s2.length()) - { - return 1; - } - assert(s1.length() == s2.length()); - return compare(s1.c_str(), s2.c_str(), s1.length()); - } -}; - -bool eq(const std::string& lhs, const std::string& rhs) noexcept -{ - return ci_char_traits::compare(lhs, rhs) == 0; -} -bool ne(const std::string& lhs, const std::string& rhs) noexcept -{ - return ci_char_traits::compare(lhs, rhs) != 0; -} - -} diff --git a/externals/nitro/externals/coda-oss/modules/c++/str/unittests/test_str.cpp b/externals/nitro/externals/coda-oss/modules/c++/str/unittests/test_str.cpp deleted file mode 100644 index 49e4a4894..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/str/unittests/test_str.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* ========================================================================= - * This file is part of str-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * str-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include // std::ignore - -#include -#include -#include "TestCase.h" - -inline std::string to_string(const std::string& value) -{ - return value; -} - -TEST_CASE(testTrim) -{ - std::string s = " test "; - str::trim( s); - TEST_ASSERT_EQ(s, "test"); -} - -TEST_CASE(testData) -{ - std::string s; - // https://en.cppreference.com/w/cpp/string/basic_string/resize - s.resize(3); // "Resizes the string to contain count characters." - - CODA_OSS_disable_warning_push - #if _MSC_VER - #pragma warning(disable : 4996) // '...': This function or variable may be unsafe. ... - #endif - - // https://en.cppreference.com/w/cpp/string/basic_string/data - // "Modifying the past-the-end null terminator stored at data()+size() to any value other than CharT() has undefined behavior." - std::ignore = strcpy(str::data(s), "abc"); - - CODA_OSS_disable_warning_pop - TEST_ASSERT_EQ(s, "abc"); -} - -TEST_CASE(testUpper) -{ - std::string s = "test-something1"; - str::upper( s); - TEST_ASSERT_EQ(s, "TEST-SOMETHING1"); -} - -TEST_CASE(testLower) -{ - std::string s = "TEST1"; - str::lower( s); - TEST_ASSERT_EQ(s, "test1"); -} - -TEST_CASE(test_eq_ne) -{ - const auto s1 = "TEST1"; - const auto s2 = "test1"; - const auto s3 = "T2"; - - TEST_ASSERT_TRUE(str::eq(s1, s1)); - TEST_ASSERT_FALSE(str::ne(s1, s1)); - - TEST_ASSERT_TRUE(str::eq(s1, s2)); - TEST_ASSERT_FALSE(str::ne(s1, s2)); - TEST_ASSERT_TRUE(str::eq(s2, s1)); - TEST_ASSERT_FALSE(str::ne(s2, s1)); - - TEST_ASSERT_FALSE(str::eq(s1, s3)); - TEST_ASSERT_TRUE(str::ne(s1, s3)); - TEST_ASSERT_FALSE(str::eq(s3, s1)); - TEST_ASSERT_TRUE(str::ne(s3, s1)); -} - -TEST_CASE(testReplace) -{ - std::string s = "helo world"; - str::replace(s, "l", "ll"); - TEST_ASSERT_EQ(s, "hello world"); -} - -TEST_CASE(testReplaceAllInfinite) -{ - std::string s = "helo hello"; - str::replaceAll(s, "l", "ll"); - TEST_ASSERT_EQ(s, "hello hellllo"); -} - -TEST_CASE(testReplaceAllRecurse) -{ - std::string s = "Mississippi"; - str::replaceAll(s, "i", " "); - TEST_ASSERT_EQ(s, "M ss ss pp "); -} - -TEST_CASE(testContains) -{ - std::string s = "Mississippi"; - TEST_ASSERT_TRUE(str::contains(s, "ssiss")); -} - -TEST_CASE(testNotContains) -{ - std::string s = "Mississippi"; - TEST_ASSERT_FALSE(str::contains(s, "miss")); -} - -TEST_CASE(testSplit) -{ - std::string s = "space delimited values are the best!"; - std::vector parts = str::split(s, " "); - TEST_ASSERT_EQ(parts.size(), static_cast(6)); - parts = str::split(s, " ", 3); - TEST_ASSERT_EQ(parts.size(), static_cast(3)); - TEST_ASSERT_EQ(parts[2], "values are the best!"); -} - -TEST_CASE(testIsAlpha) -{ - TEST_ASSERT(str::isAlpha("abcdefghijklmnopqrstuvwxyz")); - TEST_ASSERT_FALSE(str::isAlpha("abc123")); - TEST_ASSERT_FALSE(str::isAlpha("abcs with spaces")); -} -TEST_CASE(testIsAlphaSpace) -{ - TEST_ASSERT(str::isAlphaSpace("abcdefghijklmnopqrstuvwxyz")); - TEST_ASSERT_FALSE(str::isAlphaSpace("abc123")); - TEST_ASSERT(str::isAlphaSpace("abcs with spaces")); -} -TEST_CASE(testIsNumeric) -{ - TEST_ASSERT_FALSE(str::isNumeric("abcdefghijklmnopqrstuvwxyz")); - TEST_ASSERT_FALSE(str::isNumeric("abc123")); - TEST_ASSERT_FALSE(str::isNumeric("abcs with spaces")); - TEST_ASSERT(str::isNumeric("42")); -} -TEST_CASE(testIsNumericSpace) -{ - TEST_ASSERT_FALSE(str::isNumericSpace("lotto47")); - TEST_ASSERT(str::isNumericSpace("42")); - TEST_ASSERT(str::isNumericSpace("42 15 23 5 12")); -} -TEST_CASE(testIsAlphanumeric) -{ - TEST_ASSERT(str::isAlphanumeric("lotto47")); - TEST_ASSERT(str::isAlphanumeric("42")); - TEST_ASSERT_FALSE(str::isAlphanumeric("42 15 23 5 12")); - TEST_ASSERT(str::isAlphanumeric("justtext")); -} -TEST_CASE(testIsWhitespace) -{ - TEST_ASSERT_FALSE(str::isWhitespace("lotto47")); - TEST_ASSERT(str::isWhitespace("")); - TEST_ASSERT(str::isWhitespace(" ")); - TEST_ASSERT(str::isWhitespace(" ")); - TEST_ASSERT(str::isWhitespace("\t")); - TEST_ASSERT(str::isWhitespace("\t \n")); -} -TEST_CASE(testContainsOnly) -{ - TEST_ASSERT(str::containsOnly("abc", "abcdefghijklmnopqrstuvwxyz")); - TEST_ASSERT_FALSE(str::containsOnly("abc!", "abcdefghijklmnopqrstuvwxyz")); - TEST_ASSERT(str::containsOnly("some-cool-id", "-abcdefghijklmnopqrstuvwxyz")); - TEST_ASSERT(str::containsOnly("\n\r\t ", " \t\n\r0123456789")); - TEST_ASSERT(str::containsOnly("1-2-3", " \t\n\r0123456789-")); -} -TEST_CASE(testRoundDouble) -{ - double eps = std::numeric_limits::epsilon(); - double numerator = 10005.0; - double denom = 10007.0; - double v = numerator / denom; - std::string s = str::toString(v); - std::cout << s << std::endl; - - double nv = str::toType(s); - TEST_ASSERT_ALMOST_EQ_EPS(nv, v, eps); - nv *= denom; - TEST_ASSERT_ALMOST_EQ_EPS(nv, numerator, eps); - std::cout << nv << std::endl; - std::cout << (nv - (int)nv) << std::endl; - std::cout << std::numeric_limits::epsilon() << std::endl; - TEST_ASSERT_EQ((int)std::ceil(nv), (int)numerator); -} - -TEST_CASE(testEscapeForXMLNoReplace) -{ - const std::string origMessage("This is a perfectly fine string"); - std::string message(origMessage); - str::escapeForXML(message); - TEST_ASSERT_EQ(message, origMessage); -} - -TEST_CASE(testEscapeForXMLKitchenSink) -{ - std::string message( - "This & that with and \"quotes\" & single 'quotes' & " - "why not a\nnewline & \rcarriage return at the end?"); - - const std::string expectedMessage( - "This & that with <angles> and "quotes" & " - "single 'quotes' & why not a newline & " - " carriage return at the end?"); - - str::escapeForXML(message); - TEST_ASSERT_EQ(message, expectedMessage); -} - -TEST_MAIN( - TEST_CHECK(testTrim); - TEST_CHECK(testData); - TEST_CHECK(testUpper); - TEST_CHECK(testLower); - TEST_CHECK(test_eq_ne); - TEST_CHECK(testReplace); - TEST_CHECK(testReplaceAllInfinite); - TEST_CHECK(testReplaceAllRecurse); - TEST_CHECK(testContains); - TEST_CHECK(testNotContains); - TEST_CHECK(testSplit); - TEST_CHECK(testIsAlpha); - TEST_CHECK(testIsAlphaSpace); - TEST_CHECK(testIsNumeric); - TEST_CHECK(testIsNumericSpace); - TEST_CHECK(testIsAlphanumeric); - TEST_CHECK(testIsWhitespace); - TEST_CHECK(testContainsOnly); - TEST_CHECK(testRoundDouble); - TEST_CHECK(testEscapeForXMLNoReplace); - TEST_CHECK(testEscapeForXMLKitchenSink); - ) \ No newline at end of file diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/AtomicCounterCpp11.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/AtomicCounterCpp11.h deleted file mode 100644 index ce785869f..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/AtomicCounterCpp11.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2021, Maxar Technologies, Inc. - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#ifndef CODA_OSS_sys_AtomicCounterCpp11_h_INCLUDED_ -#define CODA_OSS_sys_AtomicCounterCpp11_h_INCLUDED_ -#pragma once - -#include - -#include // C++11: https://en.cppreference.com/w/cpp/atomic/atomic - -namespace sys -{ -/*! - * \class AtomicCounter - * \brief This class provides atomic incrementing, decrementing, and setting - * of an unsigned integer. All operations are thread-safe. - */ -struct AtomicCounterImplCpp11 final -{ - using ValueType = size_t ; - - explicit AtomicCounterImplCpp11(ValueType initialValue) noexcept : - mValue(initialValue) - { - } - - ValueType getThenIncrement() noexcept - { - // https://en.cppreference.com/w/cpp/atomic/atomic/fetch_add - return mValue.fetch_add(1); - } - - ValueType getThenDecrement() noexcept - { - // https://en.cppreference.com/w/cpp/atomic/atomic/fetch_sub - return mValue.fetch_sub(1); - } - - ValueType get() const noexcept - { - // https://en.cppreference.com/w/cpp/atomic/atomic/load - return mValue.load(); - } - - AtomicCounterImplCpp11(const AtomicCounterImplCpp11&) = delete; - AtomicCounterImplCpp11& operator=(const AtomicCounterImplCpp11&) = delete; - -private: - std::atomic mValue; -}; -} - -#endif // CODA_OSS_sys_AtomicCounterCpp11_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h deleted file mode 100644 index 6b135288d..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwap.h +++ /dev/null @@ -1,298 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * (C) Copyright 2023, Maxar Technologies, Inc. - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#pragma once -#ifndef CODA_OSS_sys_ByteSwap_h_INCLUDED_ -#define CODA_OSS_sys_ByteSwap_h_INCLUDED_ - -#include -#include - -#include -#include -#include -#include -#include - -#include "config/Exports.h" - -#include "ByteSwapValue.h" -#include "Runnable.h" -#include "SysInt.h" - -namespace sys -{ -/*! - * Swap bytes in-place. Note that a complex pixel - * is equivalent to two floats so elemSize and numElems - * must be adjusted accordingly. - * - * \param [inout] buffer to transform - * \param elemSize - * \param numElems - */ -coda_oss::span CODA_OSS_API byteSwap(coda_oss::spanbuffer, size_t elemSize); -void CODA_OSS_API byteSwap(void* buffer, size_t elemSize, size_t numElems); - -// If the caller has given us bytes, assume she knows what she's doing; i.e., don't check sizeof(T) -template -inline void byteSwap_(TByte* buffer, size_t elemSize, size_t numElems) -{ - void* const buffer_ = buffer; - byteSwap(buffer_, elemSize, numElems); -} -inline void byteSwap(coda_oss::byte* buffer, size_t elemSize, size_t numElems) -{ - return byteSwap_(buffer, elemSize, numElems); -} -inline void byteSwap(byte* buffer, size_t elemSize, size_t numElems) -{ - return byteSwap_(buffer, elemSize, numElems); -} -inline void byteSwap(ubyte* buffer, size_t elemSize, size_t numElems) -{ - return byteSwap_(buffer, elemSize, numElems); -} - -namespace details -{ -template -inline void check_elemSize(size_t elemSize) -{ - static_assert(is_byte_swappable(), "T should not be a 'struct'"); - if (sizeof(T) != elemSize) - { - throw std::invalid_argument("'elemSize' != sizeof(T)"); - } -} - -// Repackage into a span; the size is 2* because for byte-swapping -// we want to look at this as an array of `T`, not `std::complex`. -template -inline auto make_span(coda_oss::span> s) -{ - const void* const p_ = s.data(); - auto const p = static_cast(p_); - const auto sz = s.size() * 2; // real and imag - return sys::make_span(p, sz); -} -template -inline auto make_span(coda_oss::span> s) -{ - void* const p_ = s.data(); - auto const p = static_cast(p_); - const auto sz = s.size() * 2; // real and imag - return sys::make_span(p, sz); -} - -} - -// Otherwise, we can sanity-check the `elemSize` parameter -template -inline void byteSwap(T* buffer, size_t elemSize, size_t numElems) -{ - details::check_elemSize(elemSize); - void* const buffer_ = buffer; - byteSwap(buffer_, elemSize, numElems); -} -template -inline void byteSwap(std::complex* buffer, size_t elemSize, size_t numElems) // dont't want `T` as `std::complex<...>` -{ - details::check_elemSize(elemSize); - void* const buffer_ = buffer; - byteSwap(buffer_, elemSize, numElems); -} - -template -inline auto byteSwap(coda_oss::span buffer) -{ - static_assert(!std::is_const::value, "T cannot be 'const'"); - static_assert(details::is_byte_swappable(), "T should not be a 'struct'"); - return byteSwap(as_writable_bytes(buffer), sizeof(T)); -} - -// Take care of treating std::complex as T[] -template -inline auto byteSwap(coda_oss::span> buffer) -{ - return byteSwap(details::make_span(buffer)); -} - -/*! - * Swap bytes into output buffer. Note that a complex pixel - * is equivalent to two floats so elemSize and numElems - * must be adjusted accordingly. - * - * \param buffer to transform - * \param elemSize - * \param numElems - * \param[out] outputBuffer buffer to write swapped elements to - */ -coda_oss::span CODA_OSS_API byteSwap(coda_oss::span buffer, - size_t elemSize, coda_oss::span outputBuffer); -void CODA_OSS_API byteSwap(const void* buffer, size_t elemSize, size_t numElems, void* outputBuffer); - -// If the caller has given us bytes, assume she knows what she's doing; i.e., don't check sizeof(T) -template -inline void byteSwap_(const TByte* buffer, size_t elemSize, size_t numElems, U* outputBuffer) -{ - const void* const buffer_ = buffer; - void* const outputBuffer_ = outputBuffer; - byteSwap(buffer_, elemSize, numElems, outputBuffer_); -} -template -inline void byteSwap(const coda_oss::byte* buffer, size_t elemSize, size_t numElems, U* outputBuffer) -{ - byteSwap_(buffer, elemSize, numElems, outputBuffer); -} -template -inline void byteSwap(const byte* buffer, size_t elemSize, size_t numElems, U* outputBuffer) -{ - byteSwap_(buffer, elemSize, numElems, outputBuffer); -} -template -inline void byteSwap(const ubyte* buffer, size_t elemSize, size_t numElems, U* outputBuffer) -{ - byteSwap_(buffer, elemSize, numElems, outputBuffer); -} - -// Otherwise, we can sanity-check the `elemSize` parameter -template -inline void byteSwap(const T* buffer, size_t elemSize, size_t numElems, U* outputBuffer) -{ - details::check_elemSize(elemSize); - const void* const buffer_ = buffer; - void* const outputBuffer_ = outputBuffer; - byteSwap(buffer_, elemSize, numElems, outputBuffer_); -} -template -inline void byteSwap(const std::complex* buffer, size_t elemSize, size_t numElems, U* outputBuffer) // dont't want `T` as `std::complex<...>` -{ - details::check_elemSize(elemSize); - const void* const buffer_ = buffer; - void* const outputBuffer_ = outputBuffer; - byteSwap(buffer_, elemSize, numElems, outputBuffer_); -} - -template -inline auto byteSwap(coda_oss::span buffer, coda_oss::span outputBuffer) -{ - static_assert(details::is_byte_swappable(), "T should not be a 'struct'"); - return byteSwap(as_bytes(buffer), sizeof(T), outputBuffer); -} -// Take care of treating std::complex as T[] -template -inline auto byteSwap(coda_oss::span> buffer, coda_oss::span outputBuffer) -{ - return byteSwap(details::make_span(buffer), outputBuffer); -} - -template -inline auto byteSwap(coda_oss::span buffer) -{ - std::vector retval(buffer.size_bytes()); - std::ignore = byteSwap(buffer, make_span(retval)); - return retval; -} -// Take care of treating std::complex as T[] -template -inline auto byteSwap(coda_oss::span> buffer) -{ - return byteSwap(details::make_span(buffer)); -} - -// With buffer byte-swap now in place, we can safely byte-swap std::complex. -// This signature is from ByteSwapValue.h -template -inline auto byteSwapValue(std::complex z) -{ - // C++ mandates that `std::complex` be the same as `T cx[2]`; that is - // the structure is contiguous. https://en.cppreference.com/w/cpp/numeric/complex - const auto& z_ = reinterpret_cast(z); - return byteSwap(make_span(z_)); -} -template -inline auto byteSwap(std::complex val) -{ - const auto bytes = byteSwapValue(val); - assert(bytes.size() == sizeof(val)); - - const void* const pBytes = bytes.data(); - auto const pRetVal = static_cast*>(pBytes); - return *pRetVal; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -struct ByteSwapRunnable final : public sys::Runnable -{ - ByteSwapRunnable(void* buffer, size_t elemSize, size_t startElement, size_t numElements) noexcept : - mBuffer(static_cast(buffer) + startElement * elemSize), - mElemSize(elemSize), mNumElements(numElements) - { - } - void run() override - { - byteSwap(mBuffer, mElemSize, mNumElements); - } - - virtual ~ByteSwapRunnable() = default; - ByteSwapRunnable(const ByteSwapRunnable&) = delete; - ByteSwapRunnable& operator=(const ByteSwapRunnable&) = delete; - ByteSwapRunnable(ByteSwapRunnable&&) = delete; - ByteSwapRunnable& operator=(ByteSwapRunnable&&) = delete; - -private: - void* const mBuffer; - const size_t mElemSize; - const size_t mNumElements; -}; - -struct ByteSwapCopyRunnable final : public sys::Runnable -{ - ByteSwapCopyRunnable(const void* buffer, size_t elemSize, size_t startElement, size_t numElements, void* outputBuffer) noexcept : - mBuffer(static_cast(buffer) + startElement * elemSize), - mElemSize(elemSize), mNumElements(numElements), - mOutputBuffer(static_cast(outputBuffer) + startElement * elemSize) - { - } - void run() override - { - byteSwap(mBuffer, mElemSize, mNumElements, mOutputBuffer); - } - - virtual ~ByteSwapCopyRunnable() = default; - ByteSwapCopyRunnable(const ByteSwapCopyRunnable&) = delete; - ByteSwapCopyRunnable& operator=(const ByteSwapCopyRunnable&) = delete; - ByteSwapCopyRunnable(ByteSwapCopyRunnable&&) = delete; - ByteSwapCopyRunnable& operator=(ByteSwapCopyRunnable&&) = delete; - -private: - const void* const mBuffer; - const size_t mElemSize; - const size_t mNumElements; - void* const mOutputBuffer; -}; - -} -#endif // CODA_OSS_sys_ByteSwap_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h deleted file mode 100644 index c36c4428e..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ByteSwapValue.h +++ /dev/null @@ -1,202 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * (C) Copyright 2021, Maxar Technologies, Inc. - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#pragma once -#ifndef CODA_OSS_sys_ByteSwapValue_h_INCLUDED_ -#define CODA_OSS_sys_ByteSwapValue_h_INCLUDED_ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config/Exports.h" - -#include "Span.h" - -namespace sys -{ - /*! - * Swap bytes for a single value into output buffer. API is `span` rather than `void*` since - * for a single value we know the size. These "low level" routines may be less efficient than - * the templates since it's not possible to specialize on a specific size. - * - * \param buffer to transform - * \param[out] outputBuffer buffer to write swapped elements to - */ - coda_oss::span CODA_OSS_API byteSwap( - coda_oss::span pIn, coda_oss::span outPtr); - - namespace details - { - // "cast" a single value to bytes - template - inline auto as_bytes(const T& v) noexcept - { - static_assert(!std::is_compound::value, "T cannot be a 'struct'"); - return sys::as_bytes(&v, 1); - } - template - inline auto as_writable_bytes(T& v) noexcept - { - static_assert(!std::is_compound::value, "T cannot be a 'struct'"); - return sys::as_writable_bytes(&v, 1); - } - - template - inline auto swapUIntBytes(coda_oss::span inBytes, coda_oss::span outBytes, - std::nothrow_t) noexcept - { - static_assert(std::is_unsigned::value, "TUInt must be 'unsigned'"); - assert(sizeof(TUInt) == inBytes.size()); - assert(inBytes.size() == outBytes.size()); - - const void* const pIn_ = inBytes.data(); - auto const pIn = static_cast(pIn_); - void* const pOut_ = outBytes.data(); - auto const pOut = static_cast(pOut_); - - *pOut = coda_oss::byteswap(*pIn); // at long last, swap the bytes - - // Give the raw byte-swapped bytes back to the caller for easy serialization - return as_bytes(*pOut); - } - template - inline auto swapUIntBytes(coda_oss::span inBytes, coda_oss::span outBytes) - { - if (sizeof(TUInt) != inBytes.size()) - { - throw std::invalid_argument("'inBytes.size() != sizeof(TUInt)"); - } - if (inBytes.size() != outBytes.size()) - { - throw std::invalid_argument("'inBytes.size() != outBytes.size()"); - } - return swapUIntBytes(inBytes, outBytes, std::nothrow); - } - - // This is a template so that we can have specializations for different sizes. - // By specializing on `size_t`, a `float` can be "cast" to `uint32_t` (via - // `std::byte`) for byte-swapping. - template - inline auto swapBytes(coda_oss::span inBytes, coda_oss::span outBytes) - { - if (elemSize != inBytes.size()) - { - throw std::invalid_argument("'inBytes.size() != elemSize"); - } - return sys::byteSwap(inBytes, outBytes); // size that wasn't specialized - } - - // avoid copy-paste errors - #define CODA_OSS_define_swapBytes_specialization_(T) template <> inline auto swapBytes \ - (coda_oss::span inBytes, coda_oss::span outBytes) { return swapUIntBytes(inBytes, outBytes); } - CODA_OSS_define_swapBytes_specialization_(uint8_t) // no `;`, it's not needed and generates a -Wpedantic warning - CODA_OSS_define_swapBytes_specialization_(uint16_t) - CODA_OSS_define_swapBytes_specialization_(uint32_t) - CODA_OSS_define_swapBytes_specialization_(uint64_t) - #undef CODA_OSS_define_swapBytes_specialization_ - - template - inline constexpr bool is_byte_swappable() noexcept - { - // Trying to byte-swap anything other than integers is likely to cause - // problems (or at least confusion): - // * `struct`s have padding that should be ignored. - // * each individual member of a `struct` should be byte-swaped - // * byte-swaped `float` or `double` bits are nonsense - return (std::is_integral::value || std::is_enum::value) || !std::is_compound::value; - } - } - - /*! - * Function to swap one element irrespective of size. - * Returns the raw byte-swapped bytes for easy serialization. - */ - template - inline auto byteSwapValue(coda_oss::span inBytes, coda_oss::span outBytes) - { - static_assert(details::is_byte_swappable(), "T should not be a 'struct'"); - return details::swapBytes(inBytes, outBytes); - } - template - inline auto byteSwapValue(T in, coda_oss::span outBytes) - { - return byteSwapValue(details::as_bytes(in), outBytes); - } - template - inline auto byteSwapValue(T in) - { - std::vector retval(sizeof(T)); - std::ignore = byteSwapValue(in, make_span(retval)); - return retval; - } - - // Reverse the above: turn `span` back to T after byte-swapping - template - inline auto byteSwapValue(coda_oss::span in) - { - // Don't want to cast the swapped bytes in `in` to T* as they might not be valid; - // e.g., a byte-swapped `float` could be garbage. - T retval; - byteSwapValue(in, details::as_writable_bytes(retval)); - return retval; - } - - /*! - * Function to swap one element irrespective of size. The inplace - * buffer function should be preferred. - * - * To specialize complex float, first include the complex library - * \code - #include - * \endcode - * - * Then put an overload in as specified below: - * \code - template std::complex byteSwap(std::complex val) - { - std::complex out(byteSwap(val.real()), - byteSwap(val.imag())); - return out; - } - * \endcode - * - */ - template inline T byteSwap(T val) - { - T out; - std::ignore = byteSwapValue(val, details::as_writable_bytes(out)); - return out; - } -} -#endif // CODA_OSS_sys_ByteSwapValue_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ConditionVarInterface.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ConditionVarInterface.h deleted file mode 100644 index 8d6f762f5..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/ConditionVarInterface.h +++ /dev/null @@ -1,125 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef CODA_OSS_sys_ConditionVarInterface_h_INCLUDED_ -#define CODA_OSS_sys_ConditionVarInterface_h_INCLUDED_ -#pragma once - -#include - -#include "config/Exports.h" - -#include "sys/SystemException.h" -#include "sys/Mutex.h" -namespace sys -{ -/*! - * \class ConditionVarInterface - * \brief Interface for any condition variable implementation - * - * Provide the API for condition variables in this thread wrapper - */ - -struct CODA_OSS_API ConditionVarInterface -{ - /*! - * This constructor means that you are creating the lock - * that you will use inside of the condition variable. - * This means that we should delete this ourselves, - * so the mIsOwner flag is set to true. Its up to the derived - * class to implement this default constructor. Really, this - * option is only necessary for CASPR condition variables. It - * is not the recommended behavior but it may be useful. - */ - ConditionVarInterface() = default; - - /*! - * This constructor is the preferred method for creating a new - * condition variable. It shares a global lock, which must be - * deleted externally, by default. - * - * \param theLock This is an existing lock that you wish to - * use for synchronization purposes - * - * \param isOwner This defaults to false, which means that your - * condition variable is not responsible for the deletion of the - * mutex (in other words, you must delete the mutex explicitly. - * If you set this parameter to true, you may actually be sharing - * a lock, but this class will STILL delete it. - * - */ - explicit ConditionVarInterface(Mutex *, bool = false) noexcept {} - explicit ConditionVarInterface(Mutex&) noexcept { } - - virtual ~ConditionVarInterface() = default; - - /*! - * Acquire the lock - */ - virtual void acquireLock() = 0; - - /*! - * Drop (release) the lock - */ - virtual void dropLock() = 0; - - /*! - * Wait for on a signal for a time interval. - * This should eventually have - * a class TimeInterval as the second argument, which takes - * any time interval as a right-hand-side - * \param timeout How long to wait. This is only temporarily - * a double - * \todo Create a TimeInterval class, and use it as parameter - * - * WARNING: The user is responsible for locking the mutex prior - * to using this method. There will be no check and on - * certain systems, undefined/unfavorable behavior may - * result. - */ - virtual void wait(double timeout) = 0; - - /*! - * Wait on a signal - * - * WARNING: The user is responsible for locking the mutex prior - * to using this method. There will be no check and on - * certain systems, undefined/unfavorable behavior may - * result. - */ - virtual void wait() = 0; - - /*! - * Signal (notify) - */ - virtual void signal() = 0; - - /*! - * Broadcast (notify all) - */ - virtual void broadcast() = 0; - -}; - -} -#endif // CODA_OSS_sys_ConditionVarInterface_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Conf.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Conf.h deleted file mode 100644 index 111e5f9c8..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Conf.h +++ /dev/null @@ -1,251 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * (C) Copyright 2021, Maxar Technologies, Inc. - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#ifndef CODA_OSS_sys_Conf_h_INCLUDED_ -#define CODA_OSS_sys_Conf_h_INCLUDED_ -#pragma once - -// In case there is still a WIN32 (should be "_WIN32" with a leading '_') someplace. -#if defined(_WIN32) && !defined(WIN32) -#define WIN32 _WIN32 -#endif - -// POSIX is more-or-less "Unix" -// https://linux.die.net/man/7/feature_test_macros -// "If no feature test macros are explicitly defined, then the following feature test macros -// are defined by default: ... _POSIX_SOURCE, and _POSIX_C_SOURCE=200809L. [...] -// _POSIX_SOURCE Defining this obsolete macro ... is equivalent to defining _POSIX_C_SOURCE ..." -#ifndef _WIN32 -#include -#endif - -#undef CODA_OSS_POSIX_SOURCE -#if defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 1) -#define CODA_OSS_POSIX_SOURCE _POSIX_C_SOURCE -#endif - -#undef CODA_OSS_POSIX2001_SOURCE -#if defined(CODA_OSS_POSIX_SOURCE) && (_POSIX_C_SOURCE >= 200112L) -#define CODA_OSS_POSIX2001_SOURCE _POSIX_C_SOURCE -#endif - -#undef CODA_OSS_POSIX2008_SOURCE -#if defined(CODA_OSS_POSIX2001_SOURCE) && (_POSIX_C_SOURCE >= 200809L) -#define CODA_OSS_POSIX2008_SOURCE _POSIX_C_SOURCE -#endif - -#include -#include -#include -#include - -#if defined (__APPLE_CC__) -# include -#endif - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "str/Format.h" -#include "sys/TimeStamp.h" -#include "sys/ByteSwap.h" -#include "sys/SysInt.h" - -/* Dance around the compiler to figure out */ -/* if we have access to function macro... */ - -/* If we have gnu -- Yes!! */ -#if defined(__GNUC__) - /* We get a really nice function macro */ -# define NativeLayer_func__ __PRETTY_FUNCTION__ -#elif defined(_WIN32) && (_MSC_VER >= 1300) -# define NativeLayer_func__ __FUNCSIG__ -/* Otherwise, lets look for C99 compatibility */ -#elif defined (__STDC_VERSION__) - /* The above line may not be necessary but */ - /* Im not about to find out... */ - /* Check to see if the compiler is doing C99 */ -# if __STDC_VERSION__ < 199901 - /* If not, define an empty function signature */ -# define NativeLayer_func__ "" -# else - /* If so -- Yes!! Use it! */ -# define NativeLayer_func__ __func__ -# endif -#else -/* If STDC stuff isnt defined, that would be lame, but */ -/* lets make sure its still okay */ -# define NativeLayer_func__ "" -#endif - -#ifdef _WIN32 -# include -# include -# include - - -namespace sys -{ - typedef HANDLE Handle_T; - typedef Int64_T Off_T; - typedef DWORD Pid_T; -# if _WIN64 // SIZEOF_SIZE_T == 8 - static_assert(sizeof(size_t) == 8, "wrong sizeof(size_t)"); - typedef Int64_T SSize_T; -# else // SIZEOF_SIZE_T == 4 - static_assert(sizeof(size_t) == 4, "wrong sizeof(size_t)"); - typedef Int32_T SSize_T; -# endif - static_assert(sizeof(size_t) == sizeof(SSize_T), "size_t and SSize_T should be the same size"); -} -#else // !windows -# include -# include -# include -# include -# include -# include -# include -# include -# include -//# include - -namespace sys -{ - typedef ssize_t SSize_T; - typedef off_t Off_T; - typedef int Handle_T; - // Should we remove this? - typedef pid_t Pid_T; -} -#endif // *nix - -// For strerror -#include - -#ifdef signal // Apache defines this -# undef signal -#endif - -#include "except/Exception.h" - -#define FmtX str::format - -#define SYS_FUNC NativeLayer_func__ - -#define Ctxt(MESSAGE) except::Context(__FILE__, __LINE__, SYS_FUNC, \ - sys::TimeStamp().local(), MESSAGE) - -namespace sys -{ - /*! - * 32 byte alignment is safe for now. Most SSE instruction sets - * require 16 byte alignment, but newer Intel chipsets require - * 32 byte. All 32 byte alignments inherently confirm 16 byte - * alignment, so we default to 32 here to be safe. - * - * NOTE: This should be updated as architectures require greater - * intervals. Alignments require base 2 increments. - */ - static constexpr size_t SSE_INSTRUCTION_ALIGNMENT = 32; - - /*! - * Returns true if the system is big-endian, otherwise false. - * On Intel systems, we are usually small-endian, and on - * RISC architectures we are big-endian. - */ - bool CODA_OSS_API isBigEndianSystem(); - bool CODA_OSS_API isLittleEndianSystem(); - - - /*! - * Method to create a block of memory on an alignment - * boundary specified by the user. - * This typically reduces the amount of moves that the - * OS has to do to get the data in the form that it needs - * to be in. Since this method is non-standard, we present - * OS-specific alternatives. - * - * \param sz The size (in bytes) of the buffer we wish to create - * \throw Exception if a bad allocation occurs - * \return a pointer to the data (this method never returns NULL) - */ - inline void* alignedAlloc(size_t size, - size_t alignment = SSE_INSTRUCTION_ALIGNMENT) - { - void* p = nullptr; -#ifdef _WIN32 - p = _aligned_malloc(size, alignment); -#elif defined(CODA_OSS_POSIX2001_SOURCE) - // https://linux.die.net/man/3/posix_memalign - if (posix_memalign(&p, alignment, size) != 0) - { - p = nullptr; - } -#elif defined(CODA_OSS_POSIX_SOURCE) - // https://linux.die.net/man/3/posix_memalign - // "The functions memalign(), ... have been available in all Linux libc libraries." - p = memalign(alignment, size); -#else - //! this is a basic unaligned allocation - p = malloc(size); - #error "Don't know how to implement alignedAlloc()." -#endif - if (!p) - throw except::Exception(Ctxt( - "Aligned allocation failure of size [" + - str::toString(size) + "] bytes")); - return p; - } - - /*! - * Free memory that was allocated with alignedAlloc - * This method behaves like free - * - * \param p A pointer to the data allocated using alignedAlloc - */ - inline void alignedFree(void* p) noexcept - { -#ifdef _WIN32 - _aligned_free(p); -#else - free(p); -#endif - } - -} - -// https://en.wikipedia.org/wiki/Year_2038_problem -// "Most operating systems designed to run on 64-bit hardware already use signed 64-bit `time_t` integers. ..." -#include -#include -static_assert(sizeof(time_t) >= sizeof(int64_t), "Should have at least a 64-bit time_t."); - -#endif // CODA_OSS_sys_Conf_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/DateTime.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/DateTime.h deleted file mode 100644 index d238eda6d..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/DateTime.h +++ /dev/null @@ -1,191 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef CODA_OSS_sys_DateTime_h_INCLUDED_ -#define CODA_OSS_sys_DateTime_h_INCLUDED_ -#pragma once - -#include -#include - -#include - -#include "config/Exports.h" -#include "config/disable_compiler_warnings.h" - -namespace sys -{ - -/*! - * Representation of a date/time structure. - */ -class CODA_OSS_API DateTime -{ -protected: - int mYear = 0; - int mMonth = 0; - int mDayOfMonth = 0; - int mDayOfWeek = 0; - int mDayOfYear = 0; - int mHour = 0; - int mMinute = 0; - double mSecond = 0.0; - double mTimeInMillis = 0.0; - - // Turn a tm struct into a double - double toMillis(tm t) const; - - /*! - * Set the time to right now. - * Uses time() or if HAVE_SYS_TIME_H is defined, - * gettimeofday() for usec precision. - */ - void setNow(); - - //! @brief Set members from the millis value. - void fromMillis(); - - //! @brief Set members from the tm struct value. - virtual void fromMillis(const tm& t); - - //! @brief Set the millis value from the members - virtual void toMillis() = 0; - - //! @brief Provides the time as a 'tm' - void getTime(tm& t) const; - - //! @brief Given seconds since the epoch, provides the time - virtual void getTime(time_t numSecondsSinceEpoch, tm& t) const = 0; - -public: // for unit-testing - static void localtime(time_t numSecondsSinceEpoch, tm& t); - static void gmtime(time_t numSecondsSinceEpoch, tm& t); - -public: - DateTime() = default; - virtual ~DateTime() = default; - - //! Return month {1,12} - int getMonth() const noexcept { return mMonth; } - //! Return day of month {1,31} - int getDayOfMonth() const noexcept { return mDayOfMonth; } - //! Return day of week {1,7} - int getDayOfWeek() const noexcept { return mDayOfWeek; } - //! Return day of year {1,366} - int getDayOfYear() const noexcept { return mDayOfYear; } - //! Return hour {0,23} - int getHour() const noexcept { return mHour; } - //! Return minute {0,59} - int getMinute() const noexcept { return mMinute; } - //! Return second {0,59} - double getSecond() const noexcept { return mSecond; } - //! Return millis since 1 Jan 1970 - double getTimeInMillis() const noexcept { return mTimeInMillis; } - //! Return the current year - int getYear() const noexcept { return mYear; } - //! Return the number of seconds since the time epoch - static int64_t getEpochSeconds() noexcept; - - // ! Given the {1,12} month return the alphabetic equivalent - static std::string monthToString(int month); - // ! Given the {1,7} day of the week return the alphabetic equivalent - static std::string dayOfWeekToString(int dayOfWeek); - - // ! Given the {1,12} month return the abbreviated alphabetic equivalent - static std::string monthToStringAbbr(int month); - // ! Given the {1,7} day, return the abbreviated alphabetic equivalent - static std::string dayOfWeekToStringAbbr(int dayOfWeek); - - // ! Given the alphabetic or abbreviated version return {1,12} equivalent - // Acceptable input "August" or "Aug" would return 8 - static int monthToValue(const std::string& month); - // ! Given the alphabetic or abbreviated version return {1,7} equivalent - // Acceptable input "Wednesday" or "Wed" would return 4 - static int dayOfWeekToValue(const std::string& dayOfWeek); - - // Setters - void setMonth(int month); - void setDayOfMonth(int dayOfMonth); - void setHour(int hour); - void setMinute(int minute); - void setSecond(double second); - void setTimeInMillis(double time); - void setYear(int year); - - //! @brief Set members from a string/format. - void setTime(const std::string& time, const std::string& format); - - /*! - * format the DateTime string - * y = year (YYYY) - * m = month (MM) - * d = day (DD) - * H = hour (hh) - * M = minute (mm) - * S = second (ss) - */ - std::string format(const std::string& formatStr) const; - - /** - * @name Logical Operators. - * @brief Logical comparison operators. - * - * @param rhs The object to compare against. - * - * @return true if comparison holds, false otherwise. - */ - //@{ - bool operator<(const DateTime& rhs) const noexcept - { - return (mTimeInMillis < rhs.mTimeInMillis); - } - - bool operator<=(const DateTime& rhs) const noexcept - { - return (mTimeInMillis <= rhs.mTimeInMillis); - } - - bool operator>(const DateTime& rhs) const noexcept - { - return (mTimeInMillis > rhs.mTimeInMillis); - } - - bool operator>=(const DateTime& rhs) const noexcept - { - return (mTimeInMillis >= rhs.mTimeInMillis); - } - - bool operator==(const DateTime& rhs) const noexcept - { - return (mTimeInMillis == rhs.mTimeInMillis); - } - - bool operator!=(const DateTime& rhs) const noexcept - { - return !operator==(rhs); - } - //@} -}; -} - -#endif//CODA_OSS_sys_DateTime_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Err.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Err.h deleted file mode 100644 index 4c3b37c50..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Err.h +++ /dev/null @@ -1,177 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef __SYS_ERR_H__ -#define __SYS_ERR_H__ - -/*! - * \file Err.h - * \brief Errno like object - * - * This object is very much like errno or the GetLastError() function - * in Win32. It doesnt do anything dazzling. It just reports the - * last error. This class is sometimes useful, because it understands - * that its error id maps to a system string error, and it knows how - * to obtain the error - */ - -#include "sys/Conf.h" -#include - -#include "config/Exports.h" - -namespace sys -{ -//! The default value for the Err object. Maps to errno or GetLastError() -constexpr static int __last_err__ = 0; -/*! - * \class Err - * \brief Errno like object - * - * This object is very much like errno or the GetLastError() function - * in Win32. It doesnt do anything dazzling. It just reports the - * last error. This class is sometimes useful, because it understands - * that its error id maps to a system string error, and it knows how - * to obtain the error. - * - */ - -struct CODA_OSS_API Err -{ - /*! - * Copy constructor - * \param err The err to take - */ - Err(const Err& err) noexcept - { - mErrId = err.getErrID(); - } - - /*! - * Constructor from int error id - * \param errNum The error to initialize with. Defaults to last - */ - Err() = default; - Err(int errNum) - { - setThis(errNum); - } - virtual ~Err() = default; - - /*! - * Assignment operator - * \param err The err to take - */ - Err& operator=(const Err& err) noexcept - { - if (&err != this) - { - mErrId = err.getErrID(); - } - return *this; - } - - /*! - * This is the equivalent of strerror, done in a cross-platform - * manner, wrapped in this class. Prints this object to - * its error string - * \return a string representation of this error - * - */ - virtual std::string toString() const; - - /*! - * Set method - * \param i An int to initialize from - */ - void setThis(int i = __last_err__) - { - if (i == __last_err__) - { - mErrId = getLast(); - } - } - - //! Return the last error - virtual int getLast() const; - - int getErrID() const noexcept { return mErrId; } - -protected: - - int mErrId = __last_err__; -}; - -/*! - * \class SocketErr - * \brief Specialization to handle those weird winsock/bsd errors - * - * The same operations as in Err for sockets - * - */ -struct SocketErr : public Err -{ - /*! - * Copy constructor. Takes a right-hand-side - * \param err An error to initialize from - * - */ - SocketErr(const SocketErr& err) : - Err(err.getErrID()) - { - } - - /*! - * Constructor - * \param errNum An int to initialize from - * - */ - SocketErr() = default; - SocketErr(int errNum) - { - setThis(errNum); - } - virtual ~SocketErr() = default; - - /*! - * Assignment operator - * \param err The err to take - * - */ - SocketErr& operator=(const SocketErr& err) noexcept - { - if (&err != this) - { - mErrId = err.getErrID(); - } - return *this; - } - - //! Redefined for socket errors - virtual int getLast() const override; - -}; - -} - -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/LocalDateTime.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/LocalDateTime.h deleted file mode 100644 index a264d9273..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/LocalDateTime.h +++ /dev/null @@ -1,101 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef __SYS_LOCAL_DATE_TIME_H__ -#define __SYS_LOCAL_DATE_TIME_H__ - -#include "config/Exports.h" -#include - -namespace sys -{ - -/*! - * Representation of a local date/time structure. - */ -class CODA_OSS_API LocalDateTime : public DateTime -{ -protected: - int mDST; - - //! @brief Set members from the tm struct value. - virtual void fromMillis(const tm& t) override; - - /** - * @brief Set the millis value from the members - */ - virtual void toMillis() override; - - // ! Given seconds since the epoch, provides the local time - virtual void getTime(time_t numSecondsSinceEpoch, tm& t) const override; - -public: - /*! - * Construct as current date and time (localtime). - */ - LocalDateTime(); - /*! - * Construct with time values. Date will be today. - */ - LocalDateTime(int hour, int minute, double second); - /*! - * Construct with date values. Time will be 00:00:00. - */ - LocalDateTime(int year, int month, int day); - /*! - * Construct with date and time values. - */ - LocalDateTime(int year, int month, int day, - int hour, int minute, double second); - /*! - * Construct with time in milliseconds. - */ - LocalDateTime(double timeInMillis); - /*! - * Construct with string/format. - */ - LocalDateTime(const std::string& time); - LocalDateTime(const std::string& time, const std::string& format); - - //! Return the Daylight Savings Time flag (true = on, false = off) - bool getDST() const noexcept { return mDST == 1; } - - //! Set the Daylight Savings Time flag (true = on, false = off) - void setDST(bool isDST); - - // unhide in the base class format method - using DateTime::format; - - /*! - * The default formatting looks like this: - * %y%-M%-d_%H:%m:%s - * 2011-10-19_11:59:46 - */ - std::string format() const; -}; - -std::ostream& operator<<(std::ostream& os, const LocalDateTime& dateTime); -std::istream& operator>>(std::istream& is, LocalDateTime& dateTime); -} - -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexCpp11.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexCpp11.h deleted file mode 100644 index e10ff5420..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexCpp11.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#ifndef CODA_OSS_sys_MutexCpp11_h_INCLUDED_ -#define CODA_OSS_sys_MutexCpp11_h_INCLUDED_ - -#include - -#include "sys/MutexInterface.h" - -namespace sys -{ -/*! - * \class MutexPosix - * \brief The pthreads implementation of a mutex - * - * Implements a pthread mutex and wraps the outcome - * - */ -struct MutexCpp11 final : public MutexInterface -{ - //! Constructor - MutexCpp11(); - - //! Destructor - virtual ~MutexCpp11(); - - MutexCpp11(const MutexCpp11&) = delete; - MutexCpp11& operator=(const MutexCpp11&) = delete; - - /*! - * Lock the mutex. - */ - virtual void lock() override; - - /*! - * Unlock the mutex. - */ - virtual void unlock() override; - - /*! - * Returns the native type. - */ - std::mutex& getNative(); - - /*! - * Return the type name. This function is essentially free, - * because it is static RTTI. - */ - const char* getNativeType() const noexcept - { - return typeid(mNative).name(); - } - -private: - std::mutex mNative; -}; -} - -#endif // CODA_OSS_sys_MutexCpp11_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexWin32.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexWin32.h deleted file mode 100644 index aa6b4906a..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/MutexWin32.h +++ /dev/null @@ -1,78 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef __SYS_MUTEX_WIN32_H__ -#define __SYS_MUTEX_WIN32_H__ - -#include "config/Exports.h" - -#ifdef _WIN32 -#if !defined(USE_NSPR_THREADS) - -#include "sys/MutexInterface.h" - -namespace sys -{ -class CODA_OSS_API MutexWin32 : public MutexInterface -{ -public: - //! \todo Add string name option - MutexWin32(); - virtual ~MutexWin32(); - - MutexWin32(const MutexWin32&) = delete; - MutexWin32& operator = (const MutexWin32&) = delete; - MutexWin32(MutexWin32&&) = delete; - MutexWin32& operator=(MutexWin32&&) = delete; - - /*! - * Lock the mutex. - */ - virtual void lock(); - - /*! - * Unlock the mutex. - */ - virtual void unlock(); - - /*! - * Returns the native type. - */ - HANDLE& getNative(); - - /*! - * Return the type name. This function is essentially free, - * because it is static RTTI. - */ - const char* getNativeType() const noexcept - { - return typeid(mNative).name(); - } - -private: - HANDLE mNative; -}; -} -#endif -#endif -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/OSWin32.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/OSWin32.h deleted file mode 100644 index 7fc5fdf97..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/OSWin32.h +++ /dev/null @@ -1,284 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef __SYS_WIN32_OS_H__ -#define __SYS_WIN32_OS_H__ - -#include "sys/AbstractOS.h" - -#ifdef _WIN32 - -/*! - * \file OSWin32.h - * \brief This file provides definitions for the windows layer - * - * This file provides the definitions for the windows layer of - * file manipulation abstraction, etc. - */ - -namespace sys -{ - -/*! - * \class OSWin32 - * \brief The abstraction definition layer for windows - * - * This class is the abstraction layer as defined for - * the windows operating system. - */ -struct CODA_OSS_API OSWin32 final : public AbstractOS -{ - OSWin32() = default; - virtual ~OSWin32() = default; - virtual std::string getPlatformName() const; - - virtual std::string getNodeName() const; - /*! - * Get the path delimiter for this operating system. - * For windows, this will be two slashes \\ - * For unix it will be one slash / - * \return The path delimiter - */ - const char* getDelimiter() const noexcept override - { - return "\\"; - } - - /*! - * Determine the username - * \return The username - */ - //virtual std::string getUsername() const; - - - /*! - * Does this path exist? - * NOTE: On Windows a path specifying a directory should not - * end in '\\' or '/' or it will always fail this check - * \param path The path to check for - * \return True if it does, false otherwise - */ - virtual bool exists(const std::string& path) const; - - /*! - * Move file with this path name to the newPath - * Note: this will move (rename) either a file or a directory - * (including its children) either in the same directory or across - * directories. The one caveat is that it will fail on directory - * moves when the destination is on a different volume. - * - * \return True upon success, false if failure - */ - virtual bool move(const std::string& path, - const std::string& newPath) const; - - /*! - * Does this path resolve to a file? - * \param path The path - * \return True if it does, false if not - */ - virtual bool isFile(const std::string& path) const; - - /*! - * Does this path resolve to a directory? - * \param path The path - * \return True if it does, false if not - * \todo Throw if nothing exists?? - */ - virtual bool isDirectory(const std::string& path) const; - - /*! - * Create a directory with for the path specified - * \param path The path to create - * \return True on success, false on failure (since - * you may only create if no such exists) - */ - virtual bool makeDirectory(const std::string& path) const; - - /*! - * Retrieve the current working directory. - * \return The current working directory - */ - virtual std::string getCurrentWorkingDirectory() const; - - /*! - * Change the current working directory. - * \return true if the directory was changed, otherwise false. - */ - virtual bool changeDirectory(const std::string& path) const; - - - virtual Pid_T getProcessId() const; - - /*! - * Get a suitable temporary file name - * \return The file name - * - */ - virtual std::string getTempName(const std::string& path = ".", - const std::string& prefix = "TMP") const; - /*! - * Return the size in bytes of a file - * \return The file size - */ - virtual sys::Off_T getSize(const std::string& path) const; - - virtual sys::Off_T getLastModifiedTime(const std::string& path) const; - - virtual std::string getDSOSuffix() const; - - /*! - * This is a system independent sleep function. - * Be careful using timing calls with threads - * \param milliseconds The params - */ - virtual void millisleep(int milliseconds) const; - - virtual std::string operator[](const std::string& s) const; - - /*! - * Get an environment variable - */ - virtual std::string getEnv(const std::string& s) const; - - /*! - * Returns true if environment variable is set, false otherwise - */ - virtual bool isEnvSet(const std::string& s) const; - - /*! - * Set an environment variable - */ - virtual void setEnv(const std::string& var, - const std::string& val, - bool overwrite); - - /*! - * Unset an environment variable - */ - virtual void unsetEnv(const std::string& var); - - /*! - * \return the number of logical CPUs present on the machine - * (includes hyperthreading) - */ - virtual size_t getNumCPUs() const; - - /*! - * \todo Not yet implemented - * \return the number of logical CPUs available. This will be - * affected by pinning (e.g. start/affinity), and will - * always be <= getNumCPUs. - */ - virtual size_t getNumCPUsAvailable() const; - - /*! - * \todo Not yet implemented - * \return the number of physical CPUs present on the machine - * (excludes hyperthreading) - */ - virtual size_t getNumPhysicalCPUs() const; - - /*! - * \todo Not yet implemented - * \return the number of physical CPUs available. This will be - * affected by pinning (e.g. start/affinity), and will - * always be <= getNumPhysicalCPUs. - */ - virtual size_t getNumPhysicalCPUsAvailable() const; - - /*! - * Divide the available CPUs (pinned with start/affinity) into - * a set of physical CPUs and a set of hyperthreaded CPUs. Note - * that there is no real distinction between CPUs that share a core, - * and the separation here is not unique. However, there will only ever - * be 1 entry per core in the physical CPUs list, while the remainder - * of CPUs present in the core will be assigned to the htCPU list. - * - * \todo Not yet implemented - * - * \param[out] physicalCPUs List of physical CPUs. Size of - * getNumPhysicalCPUsAvailable(). - * \param[out] htCPUs List of CPUs that share a core with a CPU in - * 'physicalCPUs'. Size of - * getNumCPUsAvailable() - getNumPhysicalCPUsAvailable(). - */ - virtual void getAvailableCPUs(std::vector& physicalCPUs, - std::vector& htCPUs) const; - - /*! - * Create a symlink, pathnames can be either absolute or relative - */ - virtual void createSymlink(const std::string& origPathname, - const std::string& symlinkPathname) const; - - /*! - * Remove a symlink, pathname can be absolute or relative - */ - virtual void removeSymlink(const std::string& symlinkPathname) const; - - /*! - * Get the total RAM and available RAM on the system in megabytes - */ - virtual void getMemInfo(size_t& totalPhysMem, size_t& freePhysMem) const; - - /*! - * Get the absolute path to the current executable - */ - virtual std::string getCurrentExecutable( - const std::string& argvPathname = "") const; - -protected: - /*! - * Remove file with this pathname - */ - virtual void removeFile(const std::string& pathname) const; - - /*! - * Remove directory with this pathname - * NOTE: This will throw if the directory is not empty - */ - virtual void removeDirectory(const std::string& pathname) const; -}; - -struct DirectoryWin32 final : public AbstractDirectory -{ - DirectoryWin32() = default; - virtual ~DirectoryWin32() - { - close(); - } - void close() override; - - std::string findFirstFile(const std::string& dir) override; - - std::string findNextFile() override; - - HANDLE mHandle = INVALID_HANDLE_VALUE; - WIN32_FIND_DATA mFileData{}; -}; - -} - -#endif -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Span.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Span.h deleted file mode 100644 index bf24e81c7..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/Span.h +++ /dev/null @@ -1,194 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * (C) Copyright 2023, Maxar Technologies, Inc. - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#pragma once -#ifndef CODA_OSS_sys_Span_h_INCLUDED_ -#define CODA_OSS_sys_Span_h_INCLUDED_ - -#include -#include -#include -#include -#include - -namespace sys // not "mem", it depends on sys. -{ - -// Creating a `span` is verbose w/o deduction guidelines in C++17. -// Some overloads to ease the pain. -template -inline coda_oss::span make_span(const T* ptr, size_t sz) noexcept -{ - return coda_oss::span(ptr, sz); -} -template -inline coda_oss::span make_const_span(T* ptr, size_t sz) noexcept -{ - return coda_oss::span(ptr, sz); -} -template -inline coda_oss::span make_writable_span(T* ptr, size_t sz) noexcept // c.f., as_writable_bytes() -{ - return coda_oss::span(ptr, sz); -} -template -inline coda_oss::span make_span(T* ptr, size_t sz) noexcept -{ - return make_writable_span(ptr, sz); -} - -template -inline auto make_span(const void* ptr, size_t sz) noexcept -{ - return make_span(static_cast(ptr), sz); -} -template -inline auto make_const_span(void* ptr, size_t sz) noexcept -{ - return make_const_span(static_cast(ptr), sz); -} -template -inline auto make_span(void* ptr, size_t sz) noexcept -{ - return make_writable_span(static_cast(ptr), sz); -} - -template -inline auto make_const_span(coda_oss::span v) noexcept // turn span into span -{ - return make_const_span(v.data(), v.size()); -} - -template -inline auto make_span(const std::vector& v) noexcept -{ - return make_span(v.data(), v.size()); -} -template -inline auto make_const_span(std::vector& v) noexcept -{ - return make_const_span(v.data(), v.size()); -} -template -inline auto make_span(std::vector& v) noexcept -{ - return make_writable_span(v.data(), v.size()); -} - -template -inline auto make_span(const std::array& v) noexcept -{ - return make_span(v.data(), v.size()); -} -template -inline auto make_const_span(std::array& v) noexcept -{ - return make_const_span(v.data(), v.size()); -} -template -inline auto make_span(std::array& v) noexcept -{ - return make_writable_span(v.data(), v.size()); -} - -template -inline auto make_span(const T (&a)[N]) noexcept -{ - return make_span(a, N); -} -template -inline auto make_const_span(T (&a)[N]) noexcept -{ - return make_const_span(a, N); -} -template -inline auto make_span(T (&a)[N]) noexcept -{ - return make_writable_span(a, N); -} - -// Calling as_bytes() or as_writable_bytes() requires a span, which as -// noted above is a nuisance to create w/o C++17 -template -inline auto as_bytes(coda_oss::span s) noexcept -{ - return coda_oss::as_bytes(s); -} -template -inline auto as_bytes(coda_oss::span s) noexcept -{ - return coda_oss::as_bytes(s); -} -template -inline auto as_writable_bytes(coda_oss::span s) noexcept -{ - return coda_oss::as_writable_bytes(s); -} - -template -inline auto as_bytes(const T* ptr, size_t sz) noexcept -{ - return coda_oss::as_bytes(make_span(ptr, sz)); -} -template -inline auto as_writable_bytes(T* ptr, size_t sz) noexcept -{ - static_assert(!std::is_const::value, "T cannot be 'const'"); - return coda_oss::as_writable_bytes(make_writable_span(ptr, sz)); -} - -template -inline auto as_bytes(const std::vector& v) noexcept -{ - return as_bytes(v.data(), v.size()); -} -template -inline auto as_writable_bytes(std::vector& v) noexcept -{ - return as_writable_bytes(v.data(), v.size()); -} - -template -inline auto as_bytes(const std::array& v) noexcept -{ - return as_bytes(v.data(), v.size()); -} -template -inline auto as_writable_bytes(std::array& v) noexcept -{ - return as_writable_bytes(v.data(), v.size()); -} - -template -inline auto as_bytes(const T (&a)[N]) noexcept -{ - return as_bytes(a, N); -} -template -inline auto as_writable_bytes(T (&a)[N]) noexcept -{ - return as_writable_bytes(a, N); -} - -} -#endif // CODA_OSS_sys_Span_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/SysInt.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/SysInt.h deleted file mode 100644 index a25f76d1f..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/SysInt.h +++ /dev/null @@ -1,45 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * (C) Copyright 2023, Maxar Technologies, Inc. - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#pragma once -#ifndef CODA_OSS_sys_SysInt_h_INCLUDED_ -#define CODA_OSS_sys_SysInt_h_INCLUDED_ - -#include - -namespace sys -{ - typedef char byte; - typedef unsigned char ubyte; - typedef uint8_t Uint8_T; - typedef uint16_t Uint16_T; - typedef uint32_t Uint32_T; - typedef uint64_t Uint64_T; - typedef size_t Size_T; - typedef int8_t Int8_T; - typedef int16_t Int16_T; - typedef int32_t Int32_T; - typedef int64_t Int64_T; -} - -#endif // CODA_OSS_sys_SysInt_h_INCLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/TimeStamp.h b/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/TimeStamp.h deleted file mode 100644 index a04207938..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/include/sys/TimeStamp.h +++ /dev/null @@ -1,102 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - - -#ifndef __SYS_TIME_STAMP_H__ -#define __SYS_TIME_STAMP_H__ - -#include -#include "str/Format.h" -#include "sys/Conf.h" -#include "sys/LocalDateTime.h" -#include "sys/UTCDateTime.h" - -/*! - * \file TimeStamp.h - * \brief Get a timestamp in a system-independent manner - * - * Provide the API for timestamps - */ - -namespace sys -{ -/*! - * \class TimeStamp - * \brief Class for timestamping - * - */ -struct TimeStamp final -{ - //! The maximum length of a timestamp - enum { MAX_TIME_STAMP = 64 }; - - /*! - * Default constructor. - * \param is24HourTime Optional specifier for military time - */ - TimeStamp() = default; - TimeStamp(bool is24HourTime) noexcept : m24HourTime(is24HourTime) - { - } - ~TimeStamp() = default; - - /*! - * Produces a local-time string timestamp - * \return local-time - */ - std::string local() const - { - sys::LocalDateTime dt; - return dt.format(getFormat()); - } - - /*! - * Produces a gmt string timestamp - * \return gmt - */ - std::string gmt() const - { - sys::UTCDateTime dt; - return dt.format(getFormat()); - } - -private: - /*! - * Sets up string in desired format - * \return The string format for printing - */ - const char* getFormat() const noexcept - { - if (m24HourTime) - { - return "%m/%d/%Y, %H:%M:%S"; - } - return "%m/%d/%Y, %I:%M:%S%p"; - } - - //! Military time??? - bool m24HourTime = false; -}; - -} - -#endif diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/source/Conf.cpp b/externals/nitro/externals/coda-oss/modules/c++/sys/source/Conf.cpp deleted file mode 100644 index 326b3cac7..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/source/Conf.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ -#include "sys/Conf.h" - -#include - -#include -#include -#include -#include -#include "coda_oss/bit.h" -#include "coda_oss/cstddef.h" -#include "coda_oss/span.h" - -#include "sys/Span.h" - -// https://en.cppreference.com/w/cpp/types/endian -using endian = coda_oss::endian; -template -inline bool is_big_endian_() -{ - throw std::logic_error("Mixed-endian not supported."); -} -template<> -inline constexpr bool is_big_endian_() -{ - return true; -} -template <> -inline constexpr bool is_big_endian_() -{ - return false; -} -constexpr inline bool is_big_endian() -{ - return is_big_endian_(); -} - -// Want to explicitly test against both endian::bit and endian::little; i.e., -// because of "mixed" endianness, little may not the same as !big -template -inline bool is_little_endian_() -{ - throw std::logic_error("Mixed-endian not supported."); -} -template <> -inline constexpr bool is_little_endian_() -{ - return false; -} -template <> -inline constexpr bool is_little_endian_() -{ - return true; -} -constexpr inline bool is_little_endian() -{ - return is_little_endian_(); -} - -constexpr inline bool is_big_or_little_endian() -{ - return is_big_endian() || is_little_endian(); -} - -inline bool testIsBigEndianSystem() -{ - // This is an endian test - int intVal = 1; - unsigned char* endianTest = (unsigned char*)&intVal; - return endianTest[0] != 1; -} -inline auto isBigEndianSystem_() -{ - static_assert(is_big_or_little_endian(), "Mixed-endian not supported."); - const auto retval = testIsBigEndianSystem(); - if (retval != is_big_endian()) - { - throw std::logic_error("endian values don't agree!"); - } - return retval; -} -inline auto isLittleEndianSystem_() -{ - static_assert(is_big_or_little_endian(), "Mixed-endian not supported."); - const auto retval = !testIsBigEndianSystem(); - if (retval != is_little_endian()) - { - throw std::logic_error("endian values don't agree!"); - } - return retval; -} -bool sys::isBigEndianSystem() -{ - auto const retval = isBigEndianSystem_(); - assert(!retval == isLittleEndianSystem_()); - return retval; -} -bool sys::isLittleEndianSystem() -{ - auto const retval = isLittleEndianSystem_(); - assert(!retval == isBigEndianSystem_()); - return retval; -} - - /*! - * Swap bytes in-place. Note that a complex pixel - * is equivalent to two floats so elemSize and numElems - * must be adjusted accordingly. - * - * \param [inout] buffer to transform - * \param elemSize - * \param numElems - */ -template -inline auto byteSwap(coda_oss::span buffer) -{ - static_assert(std::is_unsigned::value, "TUInt must be 'unsigned'"); - for (auto& v : buffer) - { - v = sys::byteSwap(v); - } - return sys::as_bytes(buffer); -} -template -inline auto byteSwap_n_(coda_oss::span buffer_) -{ - const auto buffer = sys::make_span(buffer_.data(), buffer_.size_bytes() / sizeof(TUInt)); - assert(buffer.size_bytes() == buffer_.size_bytes()); - return byteSwap(buffer); -} -template -inline auto byteSwap_n(coda_oss::span buffer, size_t elemSize) -{ - if (sizeof(TUInt) != elemSize) - { - throw std::invalid_argument("'elemSize' != sizeof(TUInt)"); - } - return byteSwap_n_(buffer); -} -static coda_oss::span byteSwap(coda_oss::span buffer, size_t elemSize, size_t numElems) -{ - switch (elemSize) - { - case sizeof(uint16_t): return byteSwap_n(buffer, elemSize); - case sizeof(uint32_t): return byteSwap_n(buffer, elemSize); - case sizeof(uint64_t): return byteSwap_n(buffer, elemSize); - default: break; - } - - auto const bufferPtr = buffer.data(); - const auto half = elemSize >> 1; - size_t offset = 0, innerOff = 0, innerSwap = 0; - for (size_t i = 0; i < numElems; ++i, offset += elemSize) - { - for (size_t j = 0; j < half; ++j) - { - innerOff = offset + j; - innerSwap = offset + elemSize - 1 - j; - - std::swap(bufferPtr[innerOff], bufferPtr[innerSwap]); - } - } - - return sys::make_const_span(buffer); -} -void sys::byteSwap(void* buffer_, size_t elemSize, size_t numElems) -{ - if ((buffer_ == nullptr) || (elemSize < 2) || (numElems == 0)) - return; - - auto const pBytes = static_cast(buffer_); - const coda_oss::span buffer(pBytes, elemSize * numElems); - std::ignore = ::byteSwap(buffer, elemSize, numElems); -} -coda_oss::span sys::byteSwap(coda_oss::span buffer, size_t elemSize) -{ - if ((buffer.empty()) || (elemSize < 2)) - return sys::make_const_span(buffer); - - size_t const numElems = buffer.size() / elemSize; - if ((numElems * elemSize) != buffer.size()) - { - throw std::invalid_argument("'buffer' is not a multiple of 'elemSize'"); - } - - return ::byteSwap(buffer, elemSize, numElems); -} - - /*! - * Swap bytes into output buffer. Note that a complex pixel - * is equivalent to two floats so elemSize and numElems - * must be adjusted accordingly. - * - * \param buffer to transform - * \param elemSize - * \param numElems - * \param[out] outputBuffer buffer to write swapped elements to - */ -template -inline auto byteSwap_n_(coda_oss::span buffer, coda_oss::span outputBuffer_) -{ - static_assert(std::is_unsigned::value, "TUInt must be 'unsigned'"); - - assert(buffer.size_bytes() == outputBuffer_.size()); - void* pOutputBuffer = outputBuffer_.data(); - const auto outputBuffer = sys::make_span(pOutputBuffer, buffer.size()); - assert(buffer.size_bytes() == outputBuffer.size_bytes()); - - const auto byteSwap = [](const auto& v) { return sys::byteSwap(v); }; - std::transform(buffer.begin(), buffer.end(), outputBuffer.begin(), byteSwap); - - return sys::as_bytes(outputBuffer); -} -template -inline auto byteSwap_n(coda_oss::span buffer_, size_t elemSize, coda_oss::span outputBuffer) -{ - if (sizeof(TUInt) != elemSize) - { - throw std::invalid_argument("'elemSize' != sizeof(TUInt)"); - } - - const auto buffer = sys::make_span(buffer_.data(), buffer_.size_bytes() / sizeof(TUInt)); - assert(buffer.size_bytes() == buffer_.size_bytes()); - return byteSwap_n_(buffer, outputBuffer); -} - -static auto byteSwap(coda_oss::span buffer, - size_t elemSize, size_t numElems, - coda_oss::span outputBuffer) -{ - auto const bufferPtr = buffer.data(); - auto const outputBufferPtr = outputBuffer.data(); - switch (elemSize) - { - case 1: - { - std::ignore = memcpy(outputBufferPtr, bufferPtr, elemSize * numElems); - return sys::make_const_span(outputBuffer); - } - case 2: return byteSwap_n(buffer, elemSize, outputBuffer); - case 4: return byteSwap_n(buffer, elemSize, outputBuffer); - case 8: return byteSwap_n(buffer, elemSize, outputBuffer); - default: break; - } - - const auto half = elemSize >> 1; - size_t offset = 0; - for (size_t ii = 0; ii < numElems; ++ii, offset += elemSize) - { - for (size_t jj = 0; jj < half; ++jj) - { - const size_t innerOff = offset + jj; - const size_t innerSwap = offset + elemSize - 1 - jj; - - outputBufferPtr[innerOff] = bufferPtr[innerSwap]; - outputBufferPtr[innerSwap] = bufferPtr[innerOff]; - } - } - - return sys::make_const_span(outputBuffer); -} - -void sys::byteSwap(const void* buffer_, size_t elemSize, size_t numElems, void* outputBuffer_) -{ - if ((numElems == 0) || (buffer_ == nullptr) || (outputBuffer_ == nullptr)) - { - return; - } - - auto const pBytes = static_cast(buffer_); - const coda_oss::span buffer(pBytes, elemSize * numElems); - - auto const pOutputBytes = static_cast(outputBuffer_); - const coda_oss::span outputBuffer(pOutputBytes, elemSize * numElems); - - std::ignore = ::byteSwap(buffer, elemSize, numElems, outputBuffer); -} -coda_oss::span sys::byteSwap(coda_oss::span buffer, - size_t elemSize, coda_oss::span outputBuffer) -{ - if ((buffer.empty()) || (outputBuffer.empty())) - { - return sys::make_const_span(outputBuffer); - } - - size_t const numElems = buffer.size() / elemSize; - if ((numElems * elemSize) != buffer.size()) - { - throw std::invalid_argument("'buffer' is not a multiple of 'elemSize'"); - } - if (buffer.size() != outputBuffer.size()) - { - const auto s = "'buffer' and 'outputBuffer' are different sizes: " + - std::to_string(buffer.size()) + " != " + std::to_string(outputBuffer.size()); - throw std::invalid_argument(s); - } - - return ::byteSwap(buffer, elemSize, numElems, outputBuffer); - } - -// byte-swap a single value -coda_oss::span sys::byteSwap( - coda_oss::span inPtr, - coda_oss::span outPtr) -{ - if (inPtr.size() != outPtr.size()) - { - throw std::invalid_argument("'size of byte buffers must match"); - } - - const auto elemSize = inPtr.size(); - switch (elemSize) - { - case sizeof(uint8_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); - case sizeof(uint16_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); - case sizeof(uint32_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); - case sizeof(uint64_t): return details::swapUIntBytes(inPtr, outPtr, std::nothrow); - default: break; - } - - for (size_t ii = 0, jj = elemSize - 1; ii < jj; ++ii, --jj) - { - outPtr[ii] = inPtr[jj]; - outPtr[jj] = inPtr[ii]; - } - - // Give the raw byte-swapped bytes back to the caller for easy serialization - return make_const_span(outPtr); -} diff --git a/externals/nitro/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp b/externals/nitro/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp deleted file mode 100644 index 2d784428b..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/sys/unittests/test_byte_swap.cpp +++ /dev/null @@ -1,320 +0,0 @@ -/* ========================================================================= - * This file is part of sys-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2017, MDA Information Systems LLC - * - * sys-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include "TestCase.h" - -#include -#include -#include // std::endian -#include -#include -#include - -#include -#include - -TEST_CASE(testEndianness) -{ - /*const*/ auto native = std::endian::native; // "const" causes "conditional expression is constant." - - if (native == std::endian::big) { } - else if (native == std::endian::little) { } - else - { - TEST_FAIL_MSG("Mixed-endian not supported!"); - } - - const bool isBigEndianSystem = sys::isBigEndianSystem(); - - if (native == std::endian::big) - { - TEST_ASSERT(isBigEndianSystem); - } - else - { - TEST_ASSERT(!isBigEndianSystem); - } - if (native == std::endian::little) - { - TEST_ASSERT(!isBigEndianSystem); - } - else - { - TEST_ASSERT(isBigEndianSystem); - } - - - if (isBigEndianSystem) - { - TEST_ASSERT(native == std::endian::big); - } - else - { - TEST_ASSERT(native == std::endian::little); - } -} - -template -static std::vector make_origValues(size_t NUM_PIXELS) -{ - ::srand(334); - - std::vector retval(NUM_PIXELS); - for (size_t ii = 0; ii < NUM_PIXELS; ++ii) - { - const auto value = static_cast(::rand()) / RAND_MAX * - std::numeric_limits::max(); - retval[ii] = static_cast(value); - } - return retval; -} - -TEST_CASE(testByteSwapV) -{ - constexpr size_t NUM_PIXELS = 10000; - const auto origValues = make_origValues (NUM_PIXELS); - - // Byte swap the old-fashioned way - auto values1(origValues); - sys::byteSwap(values1.data(), sizeof(uint64_t), NUM_PIXELS); - - // Byte swap into output buffer - std::vector swappedValues2(origValues.size()); - sys::byteSwap(origValues.data(), sizeof(uint64_t), NUM_PIXELS, swappedValues2.data()); - - // Everything should match - for (size_t ii = 0; ii < NUM_PIXELS; ++ii) - { - TEST_ASSERT_EQ(values1[ii], swappedValues2[ii]); - } -} - -TEST_CASE(testByteSwapCxV) -{ - constexpr size_t NUM_PIXELS = 10000; - using value_type = std::complex; - const auto origValues = make_origValues(NUM_PIXELS); - - constexpr auto elemSize = sizeof(value_type) / 2; - constexpr auto numElems = NUM_PIXELS * 2; - - // Byte swap the old-fashioned way - auto values1(origValues); - sys::byteSwap(values1.data(), elemSize, numElems); - - // Byte swap into output buffer - std::vector swappedValues2(origValues.size()); - sys::byteSwap(origValues.data(), elemSize, numElems, swappedValues2.data()); - - // Everything should match - for (size_t ii = 0; ii < NUM_PIXELS; ++ii) - { - using int_type = uint64_t; - static_assert(sizeof(int_type) == sizeof(value_type), "Unknown sizeof(std::complex)"); - - // If these values are byte-swapped, they could be bogus. - const void* const pValue1_ = &(values1[ii]); - const void* const pSwappedValue2_ = &(swappedValues2[ii]); - - auto const pValue1 = static_cast(pValue1_); - auto const pSwappedValue2 = static_cast(pSwappedValue2_); - - TEST_ASSERT_EQ(*pValue1, *pSwappedValue2); - } -} - -template -inline std::span as_span(const std::vector& bytes) -{ - const void* const pBytes_ = bytes.data(); - auto const p = static_cast(pBytes_); - const auto sz = bytes.size() / sizeof(T); - return sys::make_span(p, sz); -} - -TEST_CASE(testByteSwap) -{ - constexpr size_t NUM_PIXELS = 10000; - const auto origValues = make_origValues(NUM_PIXELS); - const auto origValues_ = sys::make_span(origValues); - - auto values1(origValues); - sys::byteSwap(sys::make_span(values1)); - - // Byte swap into output buffer - std::vector swappedValues2(origValues.size()); - sys::byteSwap(origValues_, sys::as_writable_bytes(swappedValues2)); - - // std::vector returned - const auto swappedValues3_ = sys::byteSwap(origValues_); - const auto swappedValues3 = as_span(swappedValues3_); - - // Everything should match - for (size_t ii = 0; ii < NUM_PIXELS; ++ii) - { - TEST_ASSERT_EQ(values1[ii], swappedValues2[ii]); - TEST_ASSERT_EQ(values1[ii], swappedValues3[ii]); - } -} - -// 0xnn is an `int` which can't be used to initialize std::byte w/o a cast -#define CODA_OSS_define_byte(v) constexpr static std::byte v = static_cast(0 ## v) -CODA_OSS_define_byte(x00); -CODA_OSS_define_byte(x11); -CODA_OSS_define_byte(x22); -CODA_OSS_define_byte(x33); -CODA_OSS_define_byte(x44); -CODA_OSS_define_byte(x55); -CODA_OSS_define_byte(x66); -CODA_OSS_define_byte(x77); -CODA_OSS_define_byte(x88); -CODA_OSS_define_byte(x99); -CODA_OSS_define_byte(xAA); -CODA_OSS_define_byte(xBB); -CODA_OSS_define_byte(xCC); -CODA_OSS_define_byte(xDD); -CODA_OSS_define_byte(xEE); -CODA_OSS_define_byte(xFF); -#undef CODA_OSS_define_byte - -static constexpr std::byte two_bytes[]{x00, xFF}; -static constexpr std::byte four_bytes[]{x00, x11, xEE, xFF}; -static constexpr std::byte eight_bytes[]{x00, x11, x22, x33, xCC, xDD, xEE, xFF}; -static constexpr std::byte sixteen_bytes[]{x00, x11, x22, x33, x44, x55, x66, x77, x88, x99, xAA, xBB, xCC, xDD, xEE, xFF}; - -template -static void test_assert_eq_swapped(const std::string& testName, size_t sz, - const TByteSpanLike1& pValueBytes, const TByteSpanLike2& pResultBytes) -{ - for (size_t i = 0, j = sz; i < sz && j > 0; i++, j--) - { - TEST_ASSERT(pResultBytes[i] == pValueBytes[j - 1]); - } -} - -template -static void testByteSwapValues_(const std::string& testName, const void* pBytes) -{ - auto pUInt = static_cast(pBytes); - auto swap = sys::byteSwap(*pUInt); - TEST_ASSERT_NOT_EQ(*pUInt, swap); - - const void* pResult_ = &swap; - auto const pResultBytes = static_cast(pResult_); - auto const pValueBytes = static_cast(pBytes); - test_assert_eq_swapped(testName, sizeof(TUInt), pResultBytes, pValueBytes); - - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pUInt, swap); - - // swap as an "array" of one value - sys::byteSwap(pUInt, sizeof(TUInt), 1, &swap); - TEST_ASSERT_NOT_EQ(*pUInt, swap); - sys::byteSwap(&swap, sizeof(TUInt), 1); // swap back - TEST_ASSERT_EQ(*pUInt, swap); - - const auto resultBytes = sys::byteSwapValue(*pUInt); - TEST_ASSERT_EQ(resultBytes.size(), sizeof(TUInt)); - test_assert_eq_swapped(testName, sizeof(TUInt), resultBytes.data(), pValueBytes); -} -TEST_CASE(testByteSwapValues) -{ - testByteSwapValues_(testName, two_bytes); - testByteSwapValues_(testName, four_bytes); - testByteSwapValues_(testName, eight_bytes); -} - -TEST_CASE(testByteSwapCxValue) -{ - using value_type = std::complex; - const value_type cx{3.14f, -31.4f}; // using raw bytes can lean to `nan`s - auto const pValue = &cx; - - auto swap = sys::byteSwap(*pValue); - TEST_ASSERT_NOT_EQ(*pValue, swap); // technically a bit goofy as the bits may not represent `T`s - - swap = sys::byteSwap(swap); // swap back - TEST_ASSERT_EQ(*pValue, swap); -} - -TEST_CASE(testByteSwap12) -{ - // test a goofy element size - constexpr std::byte twelve_bytes[]{ - x00, x11, x22, x33, x44, x55, - x99, xAA, xBB, xDD, xEE, xFF}; - const auto pValueBytes = sys::as_bytes(twelve_bytes); - constexpr auto extent_twelve_bytes = std::extent::value; - - std::vector swappedValues(extent_twelve_bytes); - auto pResultBytes = sys::make_span(swappedValues); - - auto elemSize = 12; - auto numElements = swappedValues.size() / elemSize; - sys::byteSwap(twelve_bytes, elemSize, numElements, pResultBytes.data()); - test_assert_eq_swapped(testName, elemSize, pResultBytes, pValueBytes); - - // swap as a SINGLE 12-byte value - const auto result = sys::details::swapBytes(pValueBytes, pResultBytes); - test_assert_eq_swapped(testName, elemSize, result, pValueBytes); - - elemSize = 6; // note that an ODD size doesn't work correctly - numElements = swappedValues.size() / elemSize; - sys::byteSwap(twelve_bytes, elemSize, numElements, swappedValues.data()); - test_assert_eq_swapped(testName, elemSize, &(pResultBytes[0]), &(pValueBytes[0])); - test_assert_eq_swapped(testName, elemSize, &(pResultBytes[6]), &(pValueBytes[6])); - - sys::byteSwap(swappedValues.data(), elemSize, numElements); // swap back - for (size_t i = 0; i < swappedValues.size(); i++) - { - TEST_ASSERT(pResultBytes[i] == pValueBytes[i]); - } -} - -template -static inline void six_byteSwap(const void* in, T& out) -{ - auto const inBytes = sys::make_span(in, sizeof(T)); - out = sys::byteSwapValue(inBytes); -} -TEST_CASE(testSixByteSwap) -{ - const int i = 123; - int i_swapped; - six_byteSwap(&i, i_swapped); - TEST_ASSERT_NOT_EQ(i, i_swapped); - - int result; - six_byteSwap(&i_swapped, result); - TEST_ASSERT_EQ(i, result); -} - -TEST_MAIN( - TEST_CHECK(testEndianness); - TEST_CHECK(testByteSwapV); - TEST_CHECK(testByteSwapCxV); - TEST_CHECK(testByteSwap); - TEST_CHECK(testByteSwapValues); - TEST_CHECK(testByteSwapCxValue); - TEST_CHECK(testByteSwap12); - TEST_CHECK(testSixByteSwap); - ) diff --git a/externals/nitro/externals/coda-oss/modules/c++/tiff/include/tiff/GenericType.h b/externals/nitro/externals/coda-oss/modules/c++/tiff/include/tiff/GenericType.h deleted file mode 100644 index 5e9787f00..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/tiff/include/tiff/GenericType.h +++ /dev/null @@ -1,183 +0,0 @@ -/* ========================================================================= - * This file is part of tiff-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * tiff-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#ifndef __TIFF_GENERIC_TYPE_H__ -#define __TIFF_GENERIC_TYPE_H__ - -#include -#include - -#include "tiff/Common.h" - -namespace tiff -{ - -/** - ********************************************************************* - * @class TypeInterface - * @brief The interface class that all TIFF types inherit from. - *********************************************************************/ -class TypeInterface : public io::Serializable -{ -public: - //! Default constructor - TypeInterface() - { - } - - //! Deconstructor - virtual ~TypeInterface() - { - } - - /** - ***************************************************************** - * Returns the data of the TIFF type in byte format. - * - * @return - * the data in byte format - *****************************************************************/ - virtual unsigned char *data() const = 0; - - /** - ***************************************************************** - * Returns the size of the TIFF type. - * - * @return - * the size of the TIFF type - *****************************************************************/ - virtual unsigned short size() const = 0; - - /** - ***************************************************************** - * Converts the data to a string representation of it. - * - * @return - * the string representation of the data - *****************************************************************/ - virtual std::string toString() const = 0; -}; - -/** - ********************************************************************* - * @class GenericType - * @brief A templated TIFF type for abstracting data types. - * - * Stores data as the templatized type. All TIFF types can then - * be treated as a single type with a different data member. Contains - * functions for reading and writing the data to a stream, converting - * the data to a string for printing, and retrieving the data in - * byte form. - *********************************************************************/ -template class GenericType : - public TypeInterface -{ -public: - //! Default constructor - GenericType() : - mData(0) - { - } - - explicit GenericType(std::string s) : - mData(str::toType(s)) - { - } - - /** - ***************************************************************** - * Constructor, initializes the object with the specified data. - * - * @param data - * the data to initialize the object with - *****************************************************************/ - GenericType(const unsigned char *data) - { - const void* const pData = data; - mData = *(static_cast(pData)); - } - - //! Deconstructor - virtual ~GenericType() - { - } - - /** - ***************************************************************** - * Writes the data member to the specified stream. - * - * @param output - * the output stream to write the member to - *****************************************************************/ - virtual void serialize(io::OutputStream& output) override - { - output.write((char *)&mData, sizeof(Data_T)); - } - - /** - ***************************************************************** - * Reads the data member from the specified stream. - * - * @param input - * the input stream to read the member from - *****************************************************************/ - virtual void deserialize(io::InputStream& input) override - { - input.read((char *)&mData, sizeof(Data_T)); - } - - virtual unsigned char *data() const override - { - return (unsigned char *)&mData; - } - - virtual unsigned short size() const override - { - return sizeof(mData); - } - - virtual std::string toString() const override - { - return Strategy_T::toString(mData); - } - - /** - ***************************************************************** - * Casting operator. Returns the data in its native type. - * - * @return - * the member data in the native type - *****************************************************************/ - operator Data_T() const - { - return mData; - } - -protected: - - //! The member data - Data_T mData; -}; - -} // End namespace. - -#endif // __TIFF_GENERIC_TYPE_H__ diff --git a/externals/nitro/externals/coda-oss/modules/c++/tiff/source/ImageWriter.cpp b/externals/nitro/externals/coda-oss/modules/c++/tiff/source/ImageWriter.cpp deleted file mode 100644 index 284ffd52f..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/tiff/source/ImageWriter.cpp +++ /dev/null @@ -1,485 +0,0 @@ -/* ========================================================================= - * This file is part of tiff-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * tiff-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include "tiff/ImageWriter.h" - -#include -#include -#include - -#include "tiff/Common.h" -#include "tiff/GenericType.h" -#include "tiff/IFDEntry.h" - -const unsigned short tiff::ImageWriter::CHUNK_SIZE = 8192; - -void tiff::ImageWriter::putData(const unsigned char *buffer, - sys::Uint32_T numElementsToWrite) -{ - validate(); - - if (mFormat == TILED) - { - putTileData(buffer, numElementsToWrite); - } - else - { - putStripData(buffer, numElementsToWrite); - } -} - -void tiff::ImageWriter::writeIFD() -{ - // Retain the current file offset. - const auto offset = mOutput->tell(); - - // Seek to the position to write the current offset to. - mOutput->seek(mIFDOffset, io::Seekable::START); - - // Write the current offset. - mOutput->write((sys::byte *)&offset, sizeof(offset)); - - // Reseek to the current offset and write out the IFD. - mOutput->seek(offset, io::Seekable::START); - mIFD.serialize(*mOutput); - - // Keep the position in the file that the offset to the next - // IFD can be written to, in case there is another IFD. - mIFDOffset = mIFD.getNextIFDOffsetPosition(); -} - -void tiff::ImageWriter::validate() -{ - if (mValidated) - return; - - // ImageWidth - tiff::IFDEntry *imageWidth = mIFD["ImageWidth"]; - if (!imageWidth) - throw except::Exception(Ctxt("ImageWidth must be defined")); - - // ImageLength - tiff::IFDEntry *imageLength = mIFD["ImageLength"]; - if (!imageLength) - throw except::Exception(Ctxt("ImageLength must be defined")); - - // Compression - tiff::IFDEntry *compression = mIFD["Compression"]; - if (!compression) - mIFD.addEntry("Compression", (unsigned short) 1); - else - { - if (*(tiff::GenericType *)(*compression)[0] != 1) - throw except::Exception(Ctxt("Unsupported compression type")); - } - - // XResolution - tiff::IFDEntry *xResolution = mIFD["XResolution"]; - if (!xResolution) - { - mIFD.addEntry("XResolution", tiff::combine( - (sys::Uint32_T) 72, (sys::Uint32_T) 1)); - } - - // YResolution - tiff::IFDEntry *yResolution = mIFD["YResolution"]; - if (!yResolution) - { - mIFD.addEntry("YResolution", tiff::combine( - (sys::Uint32_T) 72, (sys::Uint32_T) 1)); - } - - // ResolutionUnit - tiff::IFDEntry *resolutionUnit = mIFD["ResolutionUnit"]; - if (!resolutionUnit) - mIFD.addEntry("ResolutionUnit", (unsigned short) 2); - - // SamplesPerPixel - tiff::IFDEntry *samplesPerPixel = mIFD["SamplesPerPixel"]; - unsigned short spp = (!samplesPerPixel) ? 0 - : (unsigned short)*(tiff::GenericType *)(*samplesPerPixel)[0]; - - // PhotometricInterpretation - tiff::IFDEntry *photoInterp = mIFD["PhotometricInterpretation"]; - if (!photoInterp) - throw except::Exception(Ctxt("No default for PhotometricInterpretation; it must be defined")); - - switch (*(tiff::GenericType *)(*photoInterp)[0]) - { - case tiff::Const::PhotoInterpType::BLACK_IS_ZERO: - case tiff::Const::PhotoInterpType::WHITE_IS_ZERO: - break; - - case tiff::Const::PhotoInterpType::RGB: - - if (!samplesPerPixel) - { - spp = 3; - mIFD.addEntry("SamplesPerPixel", (unsigned short) spp); - samplesPerPixel = mIFD["SamplesPerPixel"]; - } - else - { - if (spp < 3) - throw except::Exception(Ctxt("SamplesPerPixel must be at least 3 for RGB files")); - } - - break; - - case tiff::Const::PhotoInterpType::COLORMAP: - - if (!mIFD["ColorMap"]) - throw except::Exception(Ctxt("Colormap must be defined for ColorMapped files")); - - if (samplesPerPixel && *(tiff::GenericType *)(*samplesPerPixel)[0] != 1) - throw except::Exception(Ctxt("SamplesPerPixel must be 1 for ColorMapped files")); - - break; - - default: - throw except::Exception(Ctxt("Unsupported PhotometricInterpretation")); - } - - tiff::IFDEntry *bitsPerSample = mIFD["BitsPerSample"]; - if (samplesPerPixel) - { - for (int i = 0; i < spp; ++i) - { - if (!bitsPerSample) - mIFD.addEntry("BitsPerSample", (unsigned short) 8); - else - { - unsigned short bps = *(tiff::GenericType *)(*bitsPerSample)[0]; - - if (!(*bitsPerSample)[i]) - mIFD.addEntryValue("BitsPerSample", (unsigned short) bps); - else - { - unsigned short value = - *(tiff::GenericType *)(*bitsPerSample)[i]; - if (value != 8 && i < 3) - throw except::Exception(Ctxt("BitsPerSample values must be 8 for RGB files")); - } - } - - tiff::IFDEntry *sampleFormat = mIFD["SampleFormat"]; - if (sampleFormat) - { - unsigned short format = *(tiff::GenericType *)(*sampleFormat)[0]; - if (!(*sampleFormat)[i]) - mIFD.addEntryValue("SampleFormat", (unsigned short) format); - else - { - unsigned short value = - *(tiff::GenericType *)(*sampleFormat)[i]; - if (value != 1 && i < 3) - throw except::Exception(Ctxt("SampleFormat values must be 1 for RGB files")); - } - } - } - } - - if (!bitsPerSample) - mIFD.addEntry("BitsPerSample", (unsigned short) 8); - - mElementSize = mIFD.getElementSize(); - - if (mFormat == TILED) - initTiles(); - else - initStrips(); - - // if (mGeoTIFFReader) - // { - // tiff::IFDEntry *entry = NULL; - // if ((entry = (*mGeoTIFFReader)["ModelPixelScaleTag"])) - // mIFD.addEntry(entry); - // if ((entry = (*mGeoTIFFReader)["ModelTiepointTag"])) - // mIFD.addEntry(entry); - // if ((entry = (*mGeoTIFFReader)["ModelTransformationTag"])) - // mIFD.addEntry(entry); - // if ((entry = (*mGeoTIFFReader)["GeoKeyDirectoryTag"])) - // mIFD.addEntry(entry); - // if ((entry = (*mGeoTIFFReader)["GeoDoubleParamsTag"])) - // mIFD.addEntry(entry); - // if ((entry = (*mGeoTIFFReader)["GeoAsciiParamsTag"])) - // mIFD.addEntry(entry); - // } - - mValidated = true; -} - -void tiff::ImageWriter::initTiles() -{ - const sys::Uint32_T root = (sys::Uint32_T)sqrt((double)mIdealChunkSize - / (double)mIFD.getElementSize()); - const sys::Uint32_T ceiling = (sys::Uint32_T)ceil(((double)root) / 16); - const sys::Uint32_T tileSize = ceiling * 16; - - mIFD.addEntry("TileWidth", (sys::Uint32_T) tileSize); - mIFD.addEntry("TileLength", (sys::Uint32_T) tileSize); - - auto fileOffset = mOutput->tell(); - const sys::Uint32_T tilesAcross = (mIFD.getImageWidth() + tileSize - 1) - / tileSize; - const sys::Uint32_T tilesDown = (mIFD.getImageLength() + tileSize - 1) / tileSize; - - const unsigned short elementSize = mIFD.getElementSize(); - - mIFD.addEntry("TileByteCounts"); - mIFD.addEntry("TileOffsets"); - for (sys::Uint32_T y = 0; y < tilesDown; ++y) - { - for (sys::Uint32_T x = 0; x < tilesAcross; ++x) - { - const sys::Uint32_T byteCount = tileSize * tileSize * elementSize; - mIFD.addEntryValue("TileOffsets", (sys::Uint32_T) fileOffset); - mIFD.addEntryValue("TileByteCounts", (sys::Uint32_T) byteCount); - fileOffset += byteCount; - } - } - - mTileOffsets = mIFD["TileOffsets"]; - mTileWidth = mIFD["TileWidth"]; - mTileLength = mIFD["TileLength"]; - mTileByteCounts = mIFD["TileByteCounts"]; -} - -void tiff::ImageWriter::initStrips() -{ - const sys::Uint32_T bytesPerLine = mIFD.getImageWidth() * mIFD.getElementSize(); - - sys::Uint32_T stripByteCount = 0; - sys::Uint32_T rowsPerStrip = 1; - if (bytesPerLine > mIdealChunkSize) - stripByteCount = bytesPerLine; - else - { - rowsPerStrip = (mIdealChunkSize + (mIdealChunkSize >> 1)) - / bytesPerLine; - stripByteCount = bytesPerLine * rowsPerStrip; - } - - mIFD.addEntry("RowsPerStrip", rowsPerStrip); - - const sys::Uint32_T length = mIFD.getImageLength(); - const sys::Uint32_T stripsPerImage = - (sys::Uint32_T)floor(static_cast(length + rowsPerStrip - 1) - / static_cast(rowsPerStrip)); - - auto offset = mOutput->tell(); - - // Add counts and offsets for all but the last strip. - mIFD.addEntry("StripOffsets"); - mIFD.addEntry("StripByteCounts"); - for (sys::Uint32_T i = 0; i < stripsPerImage - 1; ++i) - { - mIFD.addEntryValue("StripOffsets", (sys::Uint32_T) offset); - mIFD.addEntryValue("StripByteCounts", (sys::Uint32_T) stripByteCount); - offset += stripByteCount; - } - - // Add the last offset. - mIFD.addEntryValue("StripOffsets", (sys::Uint32_T) offset); - - // The last byte count can be less than the previous counts. This occurs - // (for example) if RowsPerStrip is even, and ImageLength is odd. - sys::Uint32_T remainingBytes = mIFD.getImageSize() - ((stripsPerImage - 1) - * stripByteCount); - - // Add the last byteCount. - mIFD.addEntryValue("StripByteCounts", remainingBytes); - mStripByteCounts = mIFD["StripByteCounts"]; -} - -void tiff::ImageWriter::putTileData(const unsigned char *buffer, - sys::Uint32_T numElementsToWrite) -{ - const sys::Uint32_T imageElemWidth = mIFD.getImageWidth(); - const sys::Uint32_T imageByteWidth = imageElemWidth * mElementSize; - - const sys::Uint32_T tileElemWidth = *(tiff::GenericType *)(*mTileWidth)[0]; - const sys::Uint32_T tileByteWidth = tileElemWidth * mElementSize; - - const auto tileElemLength = *(tiff::GenericType *)(*mTileLength)[0]; - - // Compute the number of tiles wide the image is. - const sys::Uint32_T tilesAcross = (imageElemWidth + tileElemWidth - 1) / tileElemWidth; - - // Determine how many bytes were used to pad the right edge. - const sys::Uint32_T widthPadding = (tileByteWidth * tilesAcross) - imageByteWidth; - sys::Uint32_T globalReadOffset = 0; - sys::Uint32_T tempBytePosition = mBytePosition; - const sys::Uint32_T numBytesToWrite = numElementsToWrite * mElementSize; - sys::Uint32_T currentNumBytesRead = 0; - sys::Uint32_T remainingElementsToWrite = numElementsToWrite; - while (remainingElementsToWrite) - { - if (((mBytePosition + currentNumBytesRead) / imageByteWidth) - / tileElemLength > (tempBytePosition / imageByteWidth) - / tileElemLength) - { - tempBytePosition = mBytePosition + currentNumBytesRead; - globalReadOffset = currentNumBytesRead; - } - - // Compute the row and tile row. - const sys::Uint32_T row = tempBytePosition / imageByteWidth; - const sys::Uint32_T tileRow = row / tileElemLength; - - // Compute the column and tile column. - const sys::Uint32_T column = tempBytePosition - (row * imageByteWidth); - const sys::Uint32_T tileColumn = column / tileByteWidth; - - // Compute the 1D tile index from the tile row and tile column. - const sys::Uint32_T tileIndex = (tileRow * tilesAcross) + tileColumn; - - const sys::Uint32_T tileByteCount = *(tiff::GenericType *)(*mTileByteCounts)[tileIndex]; - - const sys::Uint32_T rowInTile = row % tileElemLength; - sys::Uint32_T paddedBytes = ((tileColumn + 1) / tilesAcross) * widthPadding; - - sys::Uint32_T remainingBytesInTile = tileByteCount - (tileElemLength - * paddedBytes) - (rowInTile * (tileByteWidth - paddedBytes) - + (column % tileByteWidth)); - - tempBytePosition += tileByteWidth - (paddedBytes + (column - % tileByteWidth)); - - sys::byte *copyBuffer = new sys::byte[tileByteWidth * tileElemLength]; - memset(copyBuffer, 0, tileByteWidth * tileElemLength); - sys::Uint32_T copyOffset = 0; - sys::Uint32_T readOffset = 0; - sys::Uint32_T tempColumn = column; - unsigned short iteration = 0; - while (readOffset < numBytesToWrite) - { - sys::Uint32_T remainingBytesThisLine = tileByteWidth - (paddedBytes - + (tempColumn % tileByteWidth)); - - sys::Uint32_T numBytesToCopy = remainingBytesThisLine; - - if (!remainingBytesInTile) - break; - - if (iteration == 0) - { - iteration++; - readOffset = globalReadOffset; - globalReadOffset += numBytesToCopy; - } - - if (numBytesToCopy > numBytesToWrite - readOffset) - numBytesToCopy = numBytesToWrite - readOffset; - - if (paddedBytes) - { - if (((tempColumn % tileByteWidth) + numBytesToCopy) - / (tileByteWidth - paddedBytes) == 0) - paddedBytes = 0; - } - - memcpy(copyBuffer + copyOffset, buffer + readOffset, numBytesToCopy); - copyOffset += (numBytesToCopy + paddedBytes); - readOffset += (imageByteWidth - (tempColumn % tileByteWidth)); - tempColumn -= (tempColumn % tileByteWidth); - remainingBytesInTile -= numBytesToCopy; - remainingElementsToWrite -= (numBytesToCopy / mElementSize); - currentNumBytesRead += numBytesToCopy; - } - - sys::Uint32_T seekPos = *(tiff::GenericType *)(*mTileOffsets)[tileIndex]; - seekPos += (row % tileElemLength) * tileByteWidth; - seekPos += (column % tileByteWidth); - mOutput->seek(seekPos, io::Seekable::START); - mOutput->write(copyBuffer, copyOffset); - delete [] copyBuffer; - } - - mBytePosition += numBytesToWrite; - - // All of the real data is in, just have to pad the bottom of the file. - if (mBytePosition == mIFD.getImageSize()) - { - sys::Uint32_T imageElemLength = mIFD.getImageLength(); - sys::Uint32_T tilesDown = (imageElemLength + tileElemLength - 1) - / tileElemLength; - const sys::Uint32_T startIndex = (tilesDown - 1) * tilesAcross; - const sys::Uint32_T paddingStartLine = imageElemLength % tileElemLength; - if (paddingStartLine) - { - const sys::Uint32_T paddedLines = tileElemLength - paddingStartLine; - - sys::byte *padBuffer = new sys::byte[paddedLines * tileByteWidth]; - memset(padBuffer, 0, paddedLines * tileByteWidth); - - for (sys::Uint32_T i = 0; i < tilesAcross; ++i) - { - sys::Uint32_T seekPos = *(tiff::GenericType *)(*mTileOffsets)[startIndex + i]; - seekPos += paddingStartLine * tileByteWidth; - mOutput->seek(seekPos, io::Seekable::START); - mOutput->write(padBuffer, paddedLines * tileByteWidth); - } - - delete [] padBuffer; - } - - // If no padding, seek the end of the image. This is so that - // when the IFD is written, it doesn't try to write it into the - // middle of the file. This is a patch and a better solution - // should probably be found. - else - { - auto lastTileIndex = static_cast(mTileOffsets->getValues().size() - 1); - sys::Uint32_T seekPos = *(tiff::GenericType *)(*mTileOffsets)[lastTileIndex]; - seekPos += *(tiff::GenericType *)(*mTileByteCounts)[lastTileIndex]; - mOutput->seek(seekPos, io::Seekable::START); - } - } -} - -void tiff::ImageWriter::putStripData(const unsigned char *buffer, - sys::Uint32_T numElementsToWrite) -{ - sys::Uint32_T stripSize = *(tiff::GenericType *)(*mStripByteCounts)[0]; - sys::Uint32_T bufferIndex = 0; - - while (numElementsToWrite) - { - sys::Uint32_T bytesToWrite = mElementSize * numElementsToWrite; - sys::Uint32_T stripIndex = mBytePosition / stripSize; - sys::Uint32_T stripPosition = mBytePosition % stripSize; - - // Calculate what remains to be written in the current strip. - sys::Uint32_T remainingBytesInStrip = - (*(tiff::GenericType *)(*mStripByteCounts)[stripIndex]) - stripPosition; - - if (bytesToWrite > remainingBytesInStrip) - bytesToWrite = remainingBytesInStrip; - - mOutput->write((sys::byte *)buffer + bufferIndex, bytesToWrite); - bufferIndex += bytesToWrite; - - numElementsToWrite -= (bytesToWrite / mElementSize); - mBytePosition += bytesToWrite; - } -} diff --git a/externals/nitro/externals/coda-oss/modules/c++/tiff/source/Utils.cpp b/externals/nitro/externals/coda-oss/modules/c++/tiff/source/Utils.cpp deleted file mode 100644 index 59de597e3..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/tiff/source/Utils.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* ========================================================================= - * This file is part of tiff-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * tiff-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include "tiff/Utils.h" - -bool tiff::Utils::hasGeoTiffIFD(const tiff::IFD* ifd) -{ - return ifd->exists("GeoKeyDirectoryTag"); -} - -tiff::IFD* tiff::Utils::createGeoTiffIFD(tiff::IFD* ifd) -{ - if (!tiff::Utils::hasGeoTiffIFD(ifd)) - return NULL; - - std::map keyMap; - keyMap[1024] = "GTModelTypeGeoKey"; - keyMap[1025] = "GTRasterTypeGeoKey"; - keyMap[1026] = "GTCitationGeoKey"; - keyMap[2048] = "GeographicTypeGeoKey"; - keyMap[2049] = "GeogCitationGeoKey"; - keyMap[2050] = "GeogGeodeticDatumGeoKey"; - keyMap[2051] = "GeogPrimeMeridianGeoKey"; - keyMap[2061] = "GeogPrimeMeridianLongGeoKey"; - keyMap[2052] = "GeogLinearUnitsGeoKey"; - keyMap[2053] = "GeogLinearUnitSizeGeoKey"; - keyMap[2054] = "GeogAngularUnitsGeoKey"; - keyMap[2055] = "GeogAngularUnitSizeGeoKey"; - keyMap[2056] = "GeogEllipsoidGeoKey"; - keyMap[2057] = "GeogSemiMajorAxisGeoKey"; - keyMap[2058] = "GeogSemiMinorAxisGeoKey"; - keyMap[2059] = "GeogInvFlatteningGeoKey"; - keyMap[2060] = "GeogAzimuthUnitsGeoKey"; - keyMap[3072] = "ProjectedCSTypeGeoKey"; - keyMap[3073] = "PCSCitationGeoKey"; - keyMap[3074] = "ProjectionGeoKey"; - keyMap[3075] = "ProjCoordTransGeoKey"; - keyMap[3076] = "ProjLinearUnitsGeoKey"; - keyMap[3077] = "ProjLinearUnitSizeGeoKey"; - keyMap[3078] = "ProjStdParallel1GeoKey"; - keyMap[3079] = "ProjStdParallel2GeoKey"; - keyMap[3080] = "ProjNatOriginLongGeoKey"; - keyMap[3081] = "ProjNatOriginLatGeoKey"; - keyMap[3082] = "ProjFalseEastingGeoKey"; - keyMap[3083] = "ProjFalseNorthingGeoKey"; - keyMap[3084] = "ProjFalseOriginLongGeoKey"; - keyMap[3085] = "ProjFalseOriginLatGeoKey"; - keyMap[3086] = "ProjFalseOriginEastingGeoKey"; - keyMap[3087] = "ProjFalseOriginNorthingGeoKey"; - keyMap[3088] = "ProjCenterLongGeoKey"; - keyMap[3089] = "ProjCenterLatGeoKey"; - keyMap[3090] = "ProjCenterEastingGeoKey"; - keyMap[3091] = "ProjFalseOriginNorthingGeoKey"; - keyMap[3092] = "ProjScaleAtNatOriginGeoKey"; - keyMap[3093] = "ProjScaleAtCenterGeoKey"; - keyMap[3094] = "ProjAzimuthAngleGeoKey"; - keyMap[3095] = "ProjStraightVertPoleLongGeoKey"; - keyMap[2060] = "GeogAzimuthUnitsGeoKey"; - keyMap[4096] = "VerticalCSTypeGeoKey"; - keyMap[4097] = "VerticalCitationGeoKey"; - keyMap[4098] = "VerticalDatumGeoKey"; - keyMap[4099] = "VerticalUnitsGeoKey"; - - tiff::IFD* geoIFD = new tiff::IFD; - - tiff::IFDEntry *geoDir = (*ifd)["GeoKeyDirectoryTag"]; - tiff::IFDEntry* const doubleParams = - ifd->exists("GeoDoubleParamsTag") ? (*ifd)["GeoDoubleParamsTag"] - : NULL; - tiff::IFDEntry* const asciiParams = - ifd->exists("GeoAsciiParamsTag") ? (*ifd)["GeoAsciiParamsTag"] - : NULL; - - std::vector geoVals = geoDir->getValues(); - size_t idx = 0; - - - str::toType(geoVals[idx++]->toString()); // skipping keyDirVersion - str::toType(geoVals[idx++]->toString()); // skipping keyRevision - str::toType(geoVals[idx++]->toString()); // skipping keyRevisionMinor - const unsigned short numKeys = - str::toType(geoVals[idx++]->toString()); - - for (unsigned short i = 0; i < numKeys; ++i) - { - // Ensure idx is in range - if (idx + 3 >= geoVals.size()) - { - throw except::Exception(Ctxt( - "'GeoKeyDirectoryTag' specified " + - str::toString(numKeys) + " keys but the IFD entry only had " + - str::toString(geoVals.size()) + " values")); - } - - const unsigned short keyId = - str::toType(geoVals[idx++]->toString()); - const unsigned short tiffTagLoc = - str::toType(geoVals[idx++]->toString()); - const unsigned short count = - str::toType(geoVals[idx++]->toString()); - const std::string valueStr(geoVals[idx++]->toString()); - - unsigned short entryType = tiff::Const::Type::NOTYPE; - switch (tiffTagLoc) - { - case 34736: // GeoDoubleParamsTag - entryType = tiff::Const::Type::DOUBLE; - break; - case 34737: // GeoAsciiParamsTag - entryType = tiff::Const::Type::ASCII; - break; - default: - entryType = tiff::Const::Type::SHORT; - break; - } - - const std::map::const_iterator iter = - keyMap.find(keyId); - const std::string name = (iter == keyMap.end()) ? "" : iter->second; - - tiff::IFDEntry *entry = new tiff::IFDEntry(keyId, entryType, name); - - if (tiffTagLoc == 0) - { - if (count != 1) - { - throw except::Exception(Ctxt( - "Expected a count of 1 but got " + str::toString(count))); - } - - entry->addValue(new tiff::GenericType(valueStr)); - } - else if (tiffTagLoc == 34736 && doubleParams) - { - const unsigned short valueOffset = - str::toType(valueStr); - for (unsigned short j = 0; j < count; ++j) - { - entry->addValue( - new tiff::GenericType( - (*doubleParams)[valueOffset - + j]->toString())); - } - } - else if (tiffTagLoc == 34737 && asciiParams) - { - const unsigned short valueOffset = - str::toType(valueStr); - for (unsigned short j = 0; j < count; ++j) - { - entry->addValue( - new tiff::GenericType( - (*asciiParams)[valueOffset - + j]->toString())); - } - } - - geoIFD->addEntry(entry); - } - - return geoIFD; -} diff --git a/externals/nitro/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h b/externals/nitro/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h deleted file mode 100644 index 78fc2fb61..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h +++ /dev/null @@ -1,221 +0,0 @@ -/* ========================================================================= - * This file is part of xml.lite-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * xml.lite-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#ifndef CODA_OSS_xml_lite_QName_h_INCLLUDED_ -#define CODA_OSS_xml_lite_QName_h_INCLLUDED_ -#pragma once - -/*! - * \file QName.h - * \brief A Qualified name (includes the namespace stuff) - * - * When XML started, the notion of a namespace was rarely used (and - * many of us were happier that way). Namespaces add complexity, but - * the also allow for name resolution in a non-conflicting manner. - * Unfortunately, the XML SAX readers, the event-driven parsers people - * tend to use, at least as underlying structures have become more complex. - * At any rate, a qualified name consists of 1) the local part (that is - * the portion people used to use alone, without any namespace, and 2) - * the prefix for the namespace, which presumably maps to a namespace URI - * - */ - -#include -#include - -#include "sys/OS.h" -#include "str/Manip.h" - -namespace xml -{ - -namespace lite -{ -/*! - * \class QName - * \brief A Qualified name (includes the namespace stuff) - * - * When XML started, the notion of a namespace was rarely used (and - * many of us were happier that way). Namespaces add complexity, but - * the also allow for name resolution in a non-conflicting manner. - * Unfortunately, the XML SAX readers, the event-driven parsers people - * tend to use, at least as underlying structures have become more - * complex. At any rate, a qualified name consists of - * 1) the local part (that is the portion people used to use alone, - * without any namespace, and - * 2) the prefix for the namespace, which presumably maps - * to a namespace URI - */ - -struct Uri final // help prevent mixups with std::string -{ - Uri(); - explicit Uri(const std::string& v); // validate=false - Uri(const std::string& v, bool validate); - std::string value; - bool empty() const - { - return value.empty(); - } -}; -inline bool operator==(const Uri& lhs, const Uri& rhs) -{ - // URIs are "supposed to be" case-insenstive - return str::eq(lhs.value, rhs.value); -} -inline bool operator!=(const Uri& lhs, const Uri& rhs) -{ - // URIs are "supposed to be" case-insenstive - return str::ne(lhs.value, rhs.value); -} -inline std::ostream& operator<<(std::ostream& os, const Uri& uri) -{ - os << uri.value; - return os; -} - -class QName final -{ - //! Prefix (Qualified) - std::string mPrefix; - //! Local Part (Unqualified) - std::string mLocalName; - //! Associated URI for Prefix - Uri mAssocUri; - -public: - QName() = default; - - /*! - * Constructor taking the namespace prefix and the local name - * \param uri The uri of the object - * \param qname The qname of the object - */ - QName(const xml::lite::Uri& uri, const std::string& qname) - { - setQName(qname); - setAssociatedUri(uri); - } - QName(const std::string& qname, const xml::lite::Uri& uri) : QName(uri, qname) { } - QName(const std::string& uri, const std::string& qname) : QName(Uri(uri), qname) { } - - /*! - * Constructor taking just the local name (no namespace). - * \param lName Just the local name of the object. - */ - explicit QName(const std::string& lName) - { - setName(lName); - } - - QName(const xml::lite::Uri& uri) - { - setAssociatedUri(uri); - } - - //! Destructor - ~QName() = default; - - QName(const QName&) = default; - QName& operator=(const QName&) = default; - QName(QName&&) = default; - QName& operator=(QName&&) = default; - - /*! - * Set the local part (unqualified) - * \param str The local name to set - * - */ - void setName(const std::string& str); - std::string getName() const; - /*! - * If this is a fully-qualified name, set it, - * otherwise, set the local name. - * \param str - */ - void setQName(const std::string& str); - - /*! - * Set the prefix (name preceding colon) - * \param prefix A new prefix - * - */ - void setPrefix(const std::string& prefix); - - /*! - * Get the prefix - * \return The prefix - * - */ - std::string getPrefix() const; - - /*! - * Retrieve the qname as a string. If you have no prefix/uri - * this returns just the local name - * \return The fully qualifed qname (e.g., soap-env:SOAP-BODY) - */ - std::string toString() const; - - /*! - * A QName is nothing without its associated URI. - * Here you specify that URI. - * \param uri The URI to associate with this QName - */ - void setAssociatedUri(const xml::lite::Uri&); - void setAssociatedUri(const std::string& str) - { - setAssociatedUri(Uri(str)); - } - - /*! - * Get the URI associated with the QName - * \return The Associated URI - * - */ - std::string getAssociatedUri() const; - void getAssociatedUri(xml::lite::Uri&) const; - const xml::lite::Uri& getUri() const; -}; - -namespace literals // c.f. std::literals -{ - // This might be overkill, in part because we don't deal with a lot of literal QNames or URLs. - // But it's interesting example code, and hidden in a "literals" namespace; be cautious - // about extensive use outside of test code. - - // https://en.cppreference.com/w/cpp/language/user_literal - inline xml::lite::Uri operator"" _u(const char* str, std::size_t len) - { - // https://en.cppreference.com/w/cpp/string/basic_string/operator%22%22s - return xml::lite::Uri(std::string(str, len)); - } - // https://en.cppreference.com/w/cpp/language/user_literal - inline xml::lite::QName operator"" _q(const char* str, std::size_t len) - { - // https://en.cppreference.com/w/cpp/string/basic_string/operator%22%22s - return xml::lite::QName(std::string(str, len)); - } -} - -} -} -#endif // CODA_OSS_xml_lite_QName_h_INCLLUDED_ diff --git a/externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp b/externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp deleted file mode 100644 index ddb7177d8..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp +++ /dev/null @@ -1,564 +0,0 @@ -/* ========================================================================= - * This file is part of xml.lite-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * xml.lite-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include - -#include -#include -#include - -#include "xml/lite/Element.h" -#include -#include -#include -#include -#include -#include "xml/lite/Attributes.h" - -std::unique_ptr xml::lite::Element::create(const std::string& qname, const std::string& uri, const std::string& characterData) -{ - return std::make_unique(qname, uri, characterData); -} -std::unique_ptr xml::lite::Element::create(const QName& qname, const std::string& characterData) -{ - return create(qname.getName(), qname.getUri().value, characterData); -} -std::unique_ptr xml::lite::Element::create(const QName& qname, const coda_oss::u8string& characterData) -{ - return std::make_unique(qname, characterData); -} - -xml::lite::Element::Element(const xml::lite::Element& node) -{ - *this = node; -} -xml::lite::Element& xml::lite::Element::operator=(const xml::lite::Element& node) -{ - if (this != &node) - { - mName = node.mName; - mCharacterData = node.mCharacterData; - mAttributes = node.mAttributes; - mChildren = node.mChildren; - mParent = node.mParent; - } - return *this; -} - -void xml::lite::Element::clone(const xml::lite::Element& node) -{ - *this = node; - - clearChildren(); - mParent = NULL; - - std::vector::const_iterator iter; - iter = node.getChildren().begin(); - for (; iter != node.getChildren().end(); ++iter) - { - xml::lite::Element *child = new xml::lite::Element(); - child->clone(**iter); - this->addChild(child); - } -} - -bool xml::lite::Element::hasElement(const QName& qname) const -{ - const auto uri = qname.getUri().value; - const auto localName = qname.getName(); - - for (unsigned int i = 0; i < mChildren.size(); i++) - { - if (mChildren[i]->getUri() == uri&& mChildren[i]->getLocalName() - == localName) - return true; - } - return false; -} - -bool xml::lite::Element::hasElement(const std::string& localName) const -{ - - for (unsigned int i = 0; i < mChildren.size(); i++) - { - if (mChildren[i]->getLocalName() == localName) - return true; - } - return false; -} - -void xml::lite::Element::getElementsByTagName(const QName& n, std::vector& elements, bool recurse) const -{ - const auto uri = n.getUri().value; - const auto localName = n.getName(); - - elements.reserve(mChildren.size()); - for (unsigned int i = 0; i < mChildren.size(); i++) - { - if (mChildren[i]->getUri() == uri && mChildren[i]->getLocalName() - == localName) - elements.push_back(mChildren[i]); - if (recurse) - mChildren[i]->getElementsByTagName(uri, localName, elements, recurse); - } -} - -template -std::tuple getElement(TGetElements getElements) -{ - auto elements = getElements(); - if (elements.size() == 1) - { - return std::make_tuple(elements[0], ""); - } - return std::make_tuple(nullptr, str::toString(elements.size())); -} -template -xml::lite::Element& getElement(TGetElements getElements, TMakeContext makeContext) -{ - auto result = getElement(getElements); - auto pElement = std::get<0>(result); - if (pElement == nullptr) - { - const auto ctxt = makeContext(std::get<1>(result)); - throw xml::lite::XMLException(ctxt); - } - return *pElement; -} - -xml::lite::Element* xml::lite::Element::getElementByTagName(std::nothrow_t, const QName& n, bool recurse) const -{ - auto getElements = [&]() { return getElementsByTagName(n, recurse); }; - return std::get<0>(getElement(getElements)); -} -xml::lite::Element& xml::lite::Element::getElementByTagName(const QName& n, bool recurse) const -{ - auto getElements = [&]() { return getElementsByTagName(n, recurse); }; - auto makeContext = [&](const std::string& sz) { - const auto uri = n.getUri().value; - const auto localName = n.getName(); - return Ctxt("Expected exactly one '" + localName + "' (uri=" + uri + "); but got " + sz); }; - return getElement(getElements, makeContext); -} - -void xml::lite::Element::getElementsByTagName(const std::string& localName, - std::vector& elements, - bool recurse) const -{ - elements.reserve(mChildren.size()); - for (unsigned int i = 0; i < mChildren.size(); i++) - { - if (mChildren[i]->getLocalName() == localName) - elements.push_back(mChildren[i]); - if (recurse) - mChildren[i]->getElementsByTagName(localName, elements, recurse); - } -} - -xml::lite::Element* xml::lite::Element::getElementByTagName(std::nothrow_t, - const std::string& localName, bool recurse) const -{ - auto getElements = [&]() { return getElementsByTagName(localName, recurse); }; - return std::get<0>(getElement(getElements)); -} -xml::lite::Element& xml::lite::Element::getElementByTagName( - const std::string& localName, bool recurse) const -{ - auto getElements = [&]() { return getElementsByTagName(localName, recurse); }; - auto makeContext = [&](const std::string& sz) { - return Ctxt("Expected exactly one '" + localName + "'; but got " + sz); }; - return getElement(getElements, makeContext); -} - - -void xml::lite::Element::getElementsByTagNameNS(const std::string& qname, - std::vector& elements, - bool recurse) const -{ - elements.reserve(mChildren.size()); - for (unsigned int i = 0; i < mChildren.size(); i++) - { - if (mChildren[i]->mName.toString() == qname) - elements.push_back(mChildren[i]); - if (recurse) - mChildren[i]->getElementsByTagNameNS(qname, elements, recurse); - } -} - -xml::lite::Element* xml::lite::Element::getElementByTagNameNS(std::nothrow_t, - const std::string& qname, bool recurse) const -{ - auto getElements = [&]() { return getElementsByTagNameNS(qname, recurse); }; - return std::get<0>(getElement(getElements)); -} -xml::lite::Element& xml::lite::Element::getElementByTagNameNS( - const std::string& qname, bool recurse) const -{ - auto getElements = [&]() { return getElementsByTagNameNS(qname, recurse); }; - auto makeContext = [&](const std::string& sz) { - return Ctxt("Expected exactly one '" + qname + "'; but got " + sz); }; - return getElement(getElements, makeContext); -} - - -void xml::lite::Element::destroyChildren() -{ - // While something is in vector - while (mChildren.size()) - { - // Get the last thing out - xml::lite::Element * childAtBack = mChildren.back(); - // Pop it off - mChildren.pop_back(); - // Delete it - delete childAtBack; - } -} - -void xml::lite::Element::print(io::OutputStream& stream) const -{ - depthPrint(stream, 0, ""); -} - -void xml::lite::Element::prettyPrint(io::OutputStream& stream, - const std::string& formatter) const -{ - depthPrint(stream, 0, formatter); - stream.writeln(""); -} - -void xml::lite::Element::consoleOutput_(io::OutputStream& stream) const -{ - depthPrint(stream, 0, "", true /*isConsoleOutput*/); -} -void xml::lite::Element::prettyConsoleOutput_(io::OutputStream& stream, - const std::string& formatter) const -{ - depthPrint(stream, 0, formatter, true /*isConsoleOutput*/); - stream.writeln(""); -} - - -std::string xml::lite::Element::getCharacterData() const -{ - return str::EncodedStringView(mCharacterData).native(); -} -coda_oss::u8string& xml::lite::Element::getCharacterData(coda_oss::u8string& result) const -{ - result = mCharacterData; - return result; -} -coda_oss::u8string xml::lite::getCharacterData(const Element& e) -{ - coda_oss::u8string retval; - return e.getCharacterData(retval); -} - -static void writeCharacterData_utf8(io::OutputStream& stream, const std::u8string& characterData) -{ - stream.write(characterData); // call UTF-8 overload -} -static void writeCharacterData_native(io::OutputStream& stream, const std::u8string& characterData) -{ - stream.write(str::EncodedStringView(characterData).native()); -} - -static void depthPrint_(const xml::lite::Element& element, - io::OutputStream& stream, int depth, const std::string& formatter, - void(*writeCharacterData)(io::OutputStream&, const std::u8string&)) -{ - // XML must be stored in UTF-8 (or UTF-16/32), in particular, not Windows-1252. - // - // Except for a special exception for writing to the console: UTF-8 won't display well on Windows - // and Windows-1252 won't display nicely on Linux. Of course, "console output" is a bit - // iffy since both Windows and Linux support redirection ... so the user could still generate - // a bad XML file. - - std::string prefix = ""; - for (int i = 0; i < depth; ++i) - prefix += formatter; - - // Printing in XML form, recursively - std::string lBrack = "<"; - static const std::string rBrack = ">"; - - const auto name = element.getQName(); - std::string acc = prefix + lBrack + name; - - auto&& attributes = element.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) - { - acc += std::string(" "); - acc += attributes.getQName(i); - acc += std::string("=\""); - acc += attributes.getValue(i); - acc += std::string("\""); - } - - const auto characterData = getCharacterData(element); - auto&& children = element.getChildren(); - if (characterData.empty() && children.empty()) - { - //simple type - just end it here - stream.write(acc + "/" + rBrack); - } - else - { - stream.write(acc + rBrack); - writeCharacterData(stream, characterData); - - for (auto&& child: children) - { - if (!formatter.empty()) - stream.write("\n"); - depthPrint_(*child, stream, depth + 1, formatter, writeCharacterData); - } - - if (!children.empty() && !formatter.empty()) - { - stream.write("\n" + prefix); - } - - lBrack += "/"; - stream.write(lBrack + name + rBrack); - } -} -void xml::lite::Element::depthPrint(io::OutputStream& stream, int depth, const std::string& formatter, bool isConsoleOutput) const -{ - const auto f = isConsoleOutput ? writeCharacterData_native // write to the console using the platform native encoding - : writeCharacterData_utf8; - depthPrint_(*this, stream, depth, formatter, f); -} - -void xml::lite::Element::addChild(xml::lite::Element * node) -{ - mChildren.push_back(node); - node->setParent(this); -} - -xml::lite::Element& xml::lite::Element::addChild(std::unique_ptr&& node) -{ - auto retval = node.get(); - addChild(node.release()); - return *retval; -} - -void xml::lite::Element::changePrefix(Element* element, - const std::string& prefix, const std::string& uri) -{ - if (element->mName.getAssociatedUri() == uri) - { - element->mName.setPrefix(prefix); - } - - // Traverse backward to support removing nodes - for (int i = element->mAttributes.getLength() - 1; i >= 0; i--) - { - if (element->mAttributes[i].getPrefix() == "xmlns" && - element->mAttributes[i].getValue() == uri) - { - // Remove all definitions of namespace - element->mAttributes.remove(i); - } - else if (element->mAttributes[i].getUri() == uri) - { - element->mAttributes[i].setPrefix(prefix); - } - } - - for (size_t i = 0, s = element->mChildren.size(); i < s; i++) - { - changePrefix(element->mChildren[i], prefix, uri); - } -} - -#if _MSC_VER -#pragma warning(push) -#pragma warning(disable: 4702) // unreachable code -#endif -void xml::lite::Element::changeURI(Element* element, - const std::string& prefix, const std::string& uri) -{ - if (element->mName.getPrefix() == prefix) - { - element->mName.setAssociatedUri(uri); - } - - // Traverse backward to support removing nodes - for (int i = element->mAttributes.getLength() - 1; i >= 0; i--) - { - if (element->mAttributes[i].getPrefix() == "xmlns" && - element->mAttributes[i].getLocalName() == prefix) - { - // Remove all definitions of namespace - element->mAttributes.remove(i); - } - else if (element->mAttributes[i].getPrefix() == prefix) - { - element->mAttributes[i].setUri(uri); - } - } - - // the "i++" is unreachable because of the "break" - const auto s = element->mChildren.size(); - for (size_t i = 0; i < s; i++) - { - changeURI(element->mChildren[i], prefix, uri); - break; - } -} -#if _MSC_VER -#pragma warning(pop) -#endif - -void xml::lite::Element::setNamespacePrefix( - std::string prefix, const Uri& uri_) -{ - str::trim(prefix); - auto uri = uri_.value; - changePrefix(this, prefix, uri); - - // Add namespace definition - ::xml::lite::Attributes& attr = getAttributes(); - - std::string p("xmlns"); - if (!prefix.empty()) - p += std::string(":") + prefix; - attr[p] = uri; -} - -void xml::lite::Element::setNamespaceURI( - std::string prefix, const Uri& uri_) -{ - str::trim(prefix); - auto uri = uri_.value; - changeURI(this, prefix, uri); - - // Add namespace definition - ::xml::lite::Attributes& attr = getAttributes(); - - std::string p("xmlns"); - if (!prefix.empty()) - p += std::string(":") + prefix; - attr[p] = uri; - - attr[std::string("xmlns:") + prefix] = uri; -} - -void xml::lite::Element::setCharacterData(const std::string& characters) -{ - mCharacterData = str::EncodedStringView(characters).u8string(); -} -xml::lite::Element& xml::lite::Element::operator=(const std::string& characterData) -{ - setCharacterData(characterData); - return *this; -} -xml::lite::Element& xml::lite::Element::operator=(const char* characterData) -{ - *this = std::string(characterData); - return *this; -} - -xml::lite::Element& xml::lite::add(const QName& qname, - const std::string& value, - Element& parent) -{ - auto elem = Element::create(qname, value); - return parent.addChild(std::move(elem)); -} - -void xml::lite::operator+=(Element& e, std::unique_ptr&& child) -{ - std::ignore = e.addChild(std::move(child)); -} - -xml::lite::Element& xml::lite::addChild(Element& e, const std::string& qname, const Uri& uri, const coda_oss::u8string& characterData) -{ - return e.addChild(Element::create(QName(qname, uri), characterData)); -} -xml::lite::Element& xml::lite::addChild(Element& e, const std::string& qname, const Uri& uri) -{ - return e.addChild(Element::create(QName(qname, uri))); -} - -xml::lite::Element& xml::lite::addChild(Element& e, const QName& qname, const coda_oss::u8string& characterData) -{ - return e.addChild(Element::create(qname, characterData)); -} -xml::lite::Element& xml::lite::addChild(Element& e, const QName& qname, const std::string& characterData) -{ - return addChild(e, qname, str::EncodedStringView(characterData).u8string()); -} -xml::lite::Element& xml::lite::addChild(Element& e, const QName& qname) -{ - return e.addChild(Element::create(qname)); -} -void xml::lite::operator+=(Element& e, const QName& qname) -{ - std::ignore = addChild(e, qname); -} - -xml::lite::Element& xml::lite::addChild(Element& e, const std::string& qname, const coda_oss::u8string& characterData) -{ - return addChild(e, QName(qname), characterData); -} -xml::lite::Element& xml::lite::addChild(Element& e, const std::string& qname) -{ - return addChild(e, QName(qname)); -} -void xml::lite::operator+=(Element& e, const std::string& qname) -{ - std::ignore = addChild(e, qname); -} - -xml::lite::Element& xml::lite::setChild(Element& e, std::unique_ptr&& child) -{ - e.destroyChildren(); - return e.addChild(std::move(child)); -} -xml::lite::Element& xml::lite::Element::operator=(std::unique_ptr&& child) -{ - std::ignore = setChild(*this, std::move(child)); - return *this; -} - -xml::lite::AttributeNode& xml::lite::addAttribute(Element& e, const AttributeNode& a) -{ - return e.getAttributes().add(a); -} -void xml::lite::operator+=(Element& e, const AttributeNode& a) -{ - std::ignore = addAttribute(e, a); -} -xml::lite::AttributeNode& xml::lite::addAttribute(Element& e, const QName& name, const std::string& value) -{ - return addAttribute(e, AttributeNode(name, value)); -} -xml::lite::AttributeNode& xml::lite::addAttribute(Element& e, const QName& name) -{ - return addAttribute(e, AttributeNode(name)); -} -xml::lite::AttributeNode& xml::lite::addAttribute(Element& e, const std::string& name) -{ - return addAttribute(e, QName(name)); -} \ No newline at end of file diff --git a/externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp b/externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp deleted file mode 100644 index 998b41ba5..000000000 --- a/externals/nitro/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* ========================================================================= - * This file is part of xml.lite-c++ - * ========================================================================= - * - * (C) Copyright 2004 - 2014, MDA Information Systems LLC - * - * xml.lite-c++ is free software; you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this program; If not, - * see . - * - */ - -#include "xml/lite/NamespaceStack.h" - -void xml::lite::NamespaceStack::push() -{ - mRefStack.push(0); -} - -void xml::lite::NamespaceStack::pop() -{ - int numToRemove = mRefStack.top(); - - for (int i = 0; i < numToRemove; i++) - { - // Remove this namespace mapping - mMappingStack.pop_back(); - } - - mRefStack.pop(); -} - - -void xml::lite::NamespaceStack::newMapping(const std::string& prefix, - const Uri& uri) -{ - ++mRefStack.top(); - mMappingStack.push_back(xml::lite::NamespaceEntity(prefix, uri.value)); -} - -void xml::lite::NamespaceStack::getMapping(const std::string& prefix, Uri& result) const -{ - for (int i = (int)mMappingStack.size() - 1; i >= 0; --i) - { - if (mMappingStack[i].first == prefix) - { - result = Uri(mMappingStack[i].second); - return; - } - } - result = xml::lite::Uri(); -} - -void xml::lite::NamespaceStack:: -getAllPrefixes(std::vector& allPrefixes) const -{ - allPrefixes.reserve(mMappingStack.size()); - for (unsigned int i = 0; i < mMappingStack.size(); i++) - { - allPrefixes.push_back(mMappingStack[i].first); - } -}