diff --git a/externals/coda-oss/modules/c++/except/include/except/Context.h b/externals/coda-oss/modules/c++/except/include/except/Context.h index 83f80acee..27816dcce 100644 --- a/externals/coda-oss/modules/c++/except/include/except/Context.h +++ b/externals/coda-oss/modules/c++/except/include/except/Context.h @@ -20,13 +20,13 @@ * */ - +#pragma once #ifndef CODA_OSS_except_Context_h_INCLUDED_ #define CODA_OSS_except_Context_h_INCLUDED_ -#pragma once #include #include +#include #include "config/Exports.h" #include "config/disable_compiler_warnings.h" @@ -59,12 +59,12 @@ struct CODA_OSS_API Context final Context(const char* file /*__FILE__*/, int line /*__LINE__*/, const std::string& func, const std::string& time, - const std::string& message = "") : - mMessage(message), - mTime(time), - mFunc(func), - mFile(file), - mLine(line) { } + const std::string& message = "" /*for existing SWIG bindings*/) + : mMessage(message), mTime(time), mFunc(func), mFile(file), mLine(line) { } + Context(const char* file /*__FILE__*/, int line /*__LINE__*/, + const std::string& func, + const std::string& time, + const std::ostringstream& message) : Context(file, line, func, time, message.str()) { } Context(const std::string& message, const char* file /*__FILE__*/, int line /*__LINE__*/, const std::string& func = "", diff --git a/externals/coda-oss/modules/c++/logging/include/logging/Logger.h b/externals/coda-oss/modules/c++/logging/include/logging/Logger.h index df158fcfc..2b33c9065 100644 --- a/externals/coda-oss/modules/c++/logging/include/logging/Logger.h +++ b/externals/coda-oss/modules/c++/logging/include/logging/Logger.h @@ -24,12 +24,14 @@ // Logger.h /////////////////////////////////////////////////////////// +#pragma once #ifndef CODA_OSS_logging_Logger_h_INCLUDED_ #define CODA_OSS_logging_Logger_h_INCLUDED_ #include #include #include +#include #include "config/Exports.h" #include "logging/Filterer.h" @@ -79,6 +81,17 @@ struct CODA_OSS_API Logger : public Filterer //! Logs a message at the CRITICAL LogLevel void critical(const std::string& msg); + //! Logs a message at the DEBUG LogLevel + void debug(const std::ostringstream& msg); + //! Logs a message at the INFO LogLevel + void info(const std::ostringstream& msg); + //! Logs a message at the WARNING LogLevel + void warn(const std::ostringstream& msg); + //! Logs a message at the ERROR LogLevel + void error(const std::ostringstream& msg); + //! Logs a message at the CRITICAL LogLevel + void critical(const std::ostringstream& msg); + //! Logs an Exception Context at the DEBUG LogLevel void debug(const except::Context& ctxt); //! Logs an Exception Context at the INFO LogLevel diff --git a/externals/coda-oss/modules/c++/logging/source/Logger.cpp b/externals/coda-oss/modules/c++/logging/source/Logger.cpp index 9fa37642f..3f3837537 100644 --- a/externals/coda-oss/modules/c++/logging/source/Logger.cpp +++ b/externals/coda-oss/modules/c++/logging/source/Logger.cpp @@ -98,6 +98,30 @@ void logging::Logger::critical(const std::string& msg) log(LogLevel::LOG_CRITICAL, msg); } +void logging::Logger::debug(const std::ostringstream& msg) +{ + log(LogLevel::LOG_DEBUG, msg.str()); +} + +void logging::Logger::info(const std::ostringstream& msg) +{ + log(LogLevel::LOG_INFO, msg.str()); +} + +void logging::Logger::warn(const std::ostringstream& msg) +{ + log(LogLevel::LOG_WARNING, msg.str()); +} + +void logging::Logger::error(const std::ostringstream& msg) +{ + log(LogLevel::LOG_ERROR, msg.str()); +} + +void logging::Logger::critical(const std::ostringstream& msg) +{ + log(LogLevel::LOG_CRITICAL, msg.str()); +} void logging::Logger::debug(const except::Context& ctxt) { diff --git a/six/modules/c++/cphd/source/CPHDWriter.cpp b/six/modules/c++/cphd/source/CPHDWriter.cpp index 3f8469fcd..a3402a456 100644 --- a/six/modules/c++/cphd/source/CPHDWriter.cpp +++ b/six/modules/c++/cphd/source/CPHDWriter.cpp @@ -274,7 +274,7 @@ void CPHDWriter::getMetadata(const PVPBlock& pvpBlock, std::ostringstream ostr; ostr << "Number of pvp block bytes in metadata: " << data.numBytesPVP << " does not match calculated size of pvp block: " << pvpBlock.getNumBytesPVPSet(); - throw except::Exception(ostr.str()); + throw except::Exception(Ctxt(ostr)); } const size_t numChannels = data.getNumChannels(); @@ -324,7 +324,7 @@ void CPHDWriter::writePVPData(DataWriter& dataWriter, const cphd::Data& data, co { std::ostringstream ostr; ostr << "PVPBlock of channel " << ii << " is empty"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } const size_t size = (data.getNumVectors(ii) * data.getNumBytesPVPSet()) / 8; diff --git a/six/modules/c++/cphd/source/CPHDXMLControl.cpp b/six/modules/c++/cphd/source/CPHDXMLControl.cpp index 57dc869d1..f7902398d 100644 --- a/six/modules/c++/cphd/source/CPHDXMLControl.cpp +++ b/six/modules/c++/cphd/source/CPHDXMLControl.cpp @@ -192,9 +192,8 @@ Version CPHDXMLControl::uriToVersion(const xml::lite::Uri& uri) } std::ostringstream ostr; ostr << "The URI " << uri << " is invalid. " - << "Either input a valid URI or " - << "add a entry to versionUriMap"; - throw except::Exception(Ctxt(ostr.str())); + << "Either input a valid URI or add a entry to versionUriMap"; + throw except::Exception(Ctxt(ostr)); } } diff --git a/six/modules/c++/cphd/source/CPHDXMLParser.cpp b/six/modules/c++/cphd/source/CPHDXMLParser.cpp index ba02cbddd..8cd76a2e8 100644 --- a/six/modules/c++/cphd/source/CPHDXMLParser.cpp +++ b/six/modules/c++/cphd/source/CPHDXMLParser.cpp @@ -2297,13 +2297,13 @@ size_t CPHDXMLParser::parsePVPType(const xml::lite::Element& paramXML, PVPType& { std::ostringstream ostr; ostr << "Specified size: " << size << " does not match default size: " << param.getSize(); - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } if (param.getFormat() != format) { std::ostringstream ostr; ostr << "Specified format: " << format << " does not match default format: " << param.getFormat(); - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } return offset; } diff --git a/six/modules/c++/cphd/source/Channel.cpp b/six/modules/c++/cphd/source/Channel.cpp index 0fd49117f..52008225a 100644 --- a/six/modules/c++/cphd/source/Channel.cpp +++ b/six/modules/c++/cphd/source/Channel.cpp @@ -221,8 +221,7 @@ std::ostream& operator<< (std::ostream& os, const Channel& c) } for (size_t ii = 0; ii < c.addedParameters.size(); ++ii) { - os << " Parameter name : " << c.addedParameters[ii].getName() << "\n"; - os << " Parameter value : " << c.addedParameters[ii].str() << "\n"; + out(os, c.addedParameters[ii]); } return os; } diff --git a/six/modules/c++/cphd/source/Data.cpp b/six/modules/c++/cphd/source/Data.cpp index 79775ebd4..dcc605f81 100644 --- a/six/modules/c++/cphd/source/Data.cpp +++ b/six/modules/c++/cphd/source/Data.cpp @@ -93,7 +93,7 @@ Data::SupportArray Data::getSupportArrayById(const std::string& id) const { std::ostringstream ostr; ostr << "ID: " << id << " is not a valid identifier"; - throw except::Exception(ostr.str()); + throw except::Exception(Ctxt(ostr)); } return supportArrayMap.find(id)->second; } @@ -106,14 +106,14 @@ void Data::setSupportArray(const std::string& id, size_t numRows, { std::ostringstream ostr; ostr << "Identifier " << id << " is not unique"; - throw except::Exception(ostr.str()); + throw except::Exception(Ctxt(ostr)); } if (mOffsetMap.count(offset)) { std::ostringstream ostr; ostr << "Offset " << offset << " is not unique"; - throw except::Exception(ostr.str()); + throw except::Exception(Ctxt(ostr)); } // Add to ordered map @@ -126,7 +126,7 @@ void Data::setSupportArray(const std::string& id, size_t numRows, { std::ostringstream ostr; ostr << "Invalid size or offset of support array given for id: " << id; - throw except::Exception(ostr.str()); + throw except::Exception(Ctxt(ostr)); } } if (mOffsetMap.upper_bound(offset) != mOffsetMap.end()) @@ -135,7 +135,7 @@ void Data::setSupportArray(const std::string& id, size_t numRows, { std::ostringstream ostr; ostr << "Invalid size or offset of support array given for id: " << id; - throw except::Exception(ostr.str()); + throw except::Exception(Ctxt(ostr)); } } @@ -187,9 +187,8 @@ void Data::verifyChannelInRange(size_t channel) const { std::ostringstream ostr; ostr << "Channel provided is " << channel << "\n" - << "while only " << channels.size() - << " channels exist \n"; - throw except::Exception(ostr.str()); + << "while only " << channels.size() << " channels exist \n"; + throw except::Exception(Ctxt(ostr)); } } diff --git a/six/modules/c++/cphd/source/ErrorParameters.cpp b/six/modules/c++/cphd/source/ErrorParameters.cpp index 4dfe3550b..de061f614 100644 --- a/six/modules/c++/cphd/source/ErrorParameters.cpp +++ b/six/modules/c++/cphd/source/ErrorParameters.cpp @@ -161,8 +161,7 @@ std::ostream& operator<< (std::ostream& os, const ErrorParameters& e) } for (const auto& parameter : e.monostatic->parameter) { - os << " Parameter Name : " << parameter.getName() << "\n" - << " Parameter Value : " << parameter.str() << "\n"; + out(os, parameter); } } else if (e.bistatic.get()) @@ -177,8 +176,7 @@ std::ostream& operator<< (std::ostream& os, const ErrorParameters& e) << e.bistatic->rcvPlatform.radarSensor; for (const auto& parameter : e.bistatic->parameter) { - os << " Parameter Name : " << parameter.getName() << "\n" - << " Parameter Value : " << parameter.str() << "\n"; + out(os, parameter); } } else diff --git a/six/modules/c++/cphd/source/PVPBlock.cpp b/six/modules/c++/cphd/source/PVPBlock.cpp index fdae548e8..1d5bbfc40 100644 --- a/six/modules/c++/cphd/source/PVPBlock.cpp +++ b/six/modules/c++/cphd/source/PVPBlock.cpp @@ -471,7 +471,7 @@ PVPBlock::PVPBlock(const Pvp& p, const Data& d) : std::ostringstream oss; oss << "PVP size specified in metadata: " << mNumBytesPerVector << " does not match PVP size calculated: " << calculateBytesPerVector; - throw except::Exception(oss.str()); + throw except::Exception(Ctxt(oss)); } } PVPBlock::PVPBlock(const Metadata& metadata) @@ -525,7 +525,7 @@ PVPBlock::PVPBlock(size_t numChannels, std::ostringstream msg; msg << "<" << numChannels << "> channels specified, " << "but `data` argument has <" << data.size() << "> channels"; - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } for (size_t channel = 0; channel < numChannels; ++channel) @@ -610,7 +610,7 @@ int64_t PVPBlock::load(io::SeekableInputStream& inStream, std::ostringstream oss; oss << "PVPBlock::load: calculated PVP size(" << numBytesIn << ") != header PVP_DATA_SIZE(" << sizePVP << ")"; - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } const bool swapToLittleEndian = std::endian::native == std::endian::little; @@ -633,7 +633,7 @@ int64_t PVPBlock::load(io::SeekableInputStream& inStream, { std::ostringstream oss; oss << "EOF reached during PVP read for channel " << (ii); - throw except::Exception(Ctxt(oss.str())); + throw except::Exception(Ctxt(oss)); } totalBytesRead += bytesThisRead; @@ -1078,7 +1078,7 @@ std::ostream& operator<< (std::ostream& os, const PVPBlock::PVPSet& p) for (auto it = p.addedPVP.begin(); it != p.addedPVP.end(); ++it) { - os << " Additional Parameter : " << it->second.str() << "\n"; + os << " Additional Parameter : " << it->second << "\n"; } return os; } diff --git a/six/modules/c++/cphd/source/ProductInfo.cpp b/six/modules/c++/cphd/source/ProductInfo.cpp index caf266aaa..5a757274b 100644 --- a/six/modules/c++/cphd/source/ProductInfo.cpp +++ b/six/modules/c++/cphd/source/ProductInfo.cpp @@ -48,15 +48,12 @@ std::ostream& operator<< (std::ostream& os, const ProductInfo& p) << " Site : " << p.creationInfo[ii].site << "\n"; for (size_t jj = 0; jj < p.creationInfo[ii].parameter.size(); ++jj) { - os << " Parameter name : " - << p.creationInfo[ii].parameter[jj].getName() << "\n" - << " Parameter value : " << p.creationInfo[ii].parameter[jj].str() << "\n"; + out(os, p.creationInfo[ii].parameter[jj]); } } for (size_t ii = 0; ii < p.parameter.size(); ++ii) { - os << " Parameter name : " << p.parameter[ii].getName() << "\n" - << " Parameter value : " << p.parameter[ii].str() << "\n"; + out(os, p.parameter[ii]); } return os; } diff --git a/six/modules/c++/cphd/source/SupportArray.cpp b/six/modules/c++/cphd/source/SupportArray.cpp index 82cee42a0..aaa66eb63 100644 --- a/six/modules/c++/cphd/source/SupportArray.cpp +++ b/six/modules/c++/cphd/source/SupportArray.cpp @@ -88,7 +88,7 @@ static SupportArrayParameter getSupportArray(const std::vectorsecond; } @@ -141,8 +141,7 @@ std::ostream& operator<< (std::ostream& os, const AdditionalSupportArray& a) << " ZUnits : " << a.zUnits << "\n"; for (size_t ii = 0; ii < a.parameter.size(); ++ii) { - os << " Parameter Name : " << a.parameter[ii].getName() << "\n" - << " Parameter Value : " << a.parameter[ii].str() << "\n"; + out(os, a.parameter[ii]); } return os; } diff --git a/six/modules/c++/cphd/source/SupportBlock.cpp b/six/modules/c++/cphd/source/SupportBlock.cpp index 36d2e47bc..6825ca288 100644 --- a/six/modules/c++/cphd/source/SupportBlock.cpp +++ b/six/modules/c++/cphd/source/SupportBlock.cpp @@ -93,7 +93,7 @@ void SupportBlock::read(const std::string& id, size_t numThreads, std::spansize(); i < total; ++i) { const six::Data* data = container->getData(i); - const auto filename = FmtX("%s_DES_%d.xml", base.string(), i); + const auto filename = str::Format("%s_DES_%d.xml", base.string(), i); const auto xmlFile = fs::path(outputDir) / filename; io::FileOutputStream xmlStream(xmlFile.string()); diff --git a/six/modules/c++/samples/test_parse_xml.cpp b/six/modules/c++/samples/test_parse_xml.cpp index 582ab937d..0ca53cb53 100644 --- a/six/modules/c++/samples/test_parse_xml.cpp +++ b/six/modules/c++/samples/test_parse_xml.cpp @@ -95,7 +95,7 @@ std::vector extractXML(std::string inputFile, nitf::Off size = deReader.getSize(); const auto typeID = subheader.typeID(); - const auto outputFile = FmtX("%s-%s%d.xml", prefix, typeID, i); + const auto outputFile = str::Format("%s-%s%d.xml", prefix, typeID, i); const auto fileName = outputDir / outputFile; { std::vector xml(size); diff --git a/six/modules/c++/scene/source/LLAToECEFTransform.cpp b/six/modules/c++/scene/source/LLAToECEFTransform.cpp index 38cd4ed5b..6329de8f1 100644 --- a/six/modules/c++/scene/source/LLAToECEFTransform.cpp +++ b/six/modules/c++/scene/source/LLAToECEFTransform.cpp @@ -53,7 +53,7 @@ scene::Vector3 scene::LLAToECEFTransform::transform(const LatLonAlt& lla) const str << ", alt="; str << lla.getAlt(); - throw except::InvalidFormatException(str.str()); + throw except::InvalidFormatException(Ctxt(str)); } //do conversion here; store result in ecef struct diff --git a/six/modules/c++/scene/tests/test_scene.cpp b/six/modules/c++/scene/tests/test_scene.cpp index a38ea343b..3ad012a4e 100644 --- a/six/modules/c++/scene/tests/test_scene.cpp +++ b/six/modules/c++/scene/tests/test_scene.cpp @@ -37,7 +37,7 @@ class SceneInfo { std::map::const_iterator p = mVecs.find(k); if (p == mVecs.end()) - throw except::Exception(Ctxt(FmtX("Key not found: %s", k))); + throw except::Exception(Ctxt(str::Format("Key not found: %s", k))); return p->second; } @@ -68,7 +68,7 @@ SceneInfo loadSceneInfo(std::string infoProps) std::string v = d[k].str(); std::vector toks = str::Tokenizer(v, ","); if (toks.size() != 3) - throw except::Exception(Ctxt(FmtX("Expected triple, received: %s", v))); + throw except::Exception(Ctxt(str::Format("Expected triple, received: %s", v))); Vector3 vec; vec[0] = str::toType(toks[0]); diff --git a/six/modules/c++/six.sicd/source/ComplexData.cpp b/six/modules/c++/six.sicd/source/ComplexData.cpp index 3f54b3edf..7dbfee1ec 100644 --- a/six/modules/c++/six.sicd/source/ComplexData.cpp +++ b/six/modules/c++/six.sicd/source/ComplexData.cpp @@ -183,7 +183,7 @@ bool ComplexData::validate(logging::Logger& log) const messageBuilder << "RgAzComp specified in imageFormation.imageFormationAlgorithm," << " but member pointer is nullptr."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } break; @@ -200,7 +200,7 @@ bool ComplexData::validate(logging::Logger& log) const messageBuilder << "PFA specified in imageFormation.imageFormationAlgorithm," << " but member pointer is nullptr."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } break; @@ -218,7 +218,7 @@ bool ComplexData::validate(logging::Logger& log) const messageBuilder << "RMA specified in imageFormation.imageFormationAlgorithm," << " but member pointer is nullptr."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } break; @@ -227,7 +227,7 @@ bool ComplexData::validate(logging::Logger& log) const messageBuilder << "Image formation not fully defined." << std::endl << "SICD.ImageFormation.ImageFormAlgo = OTHER or is not set."; - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; break; } diff --git a/six/modules/c++/six.sicd/source/ComplexXMLParser.cpp b/six/modules/c++/six.sicd/source/ComplexXMLParser.cpp index 5b4777d3e..f3e336e0c 100644 --- a/six/modules/c++/six.sicd/source/ComplexXMLParser.cpp +++ b/six/modules/c++/six.sicd/source/ComplexXMLParser.cpp @@ -832,7 +832,7 @@ XMLElem ComplexXMLParser::convertRcvChanProcToXML( } else { - throw except::Exception(Ctxt(FmtX("[RcvChanProc] is a manditory field in ImageFormation in %s", strVersion))); + throw except::Exception(Ctxt(str::Format("[RcvChanProc] is a manditory field in ImageFormation in %s", strVersion))); } } @@ -876,7 +876,7 @@ XMLElem ComplexXMLParser::convertDistortionToXML( } else { - throw except::Exception(Ctxt(FmtX("[Distortion] is a maditory field of ImageFormation in %s", strVersion))); + throw except::Exception(Ctxt(str::Format("[Distortion] is a maditory field of ImageFormation in %s", strVersion))); } } diff --git a/six/modules/c++/six.sicd/source/ComplexXMLParser10x.cpp b/six/modules/c++/six.sicd/source/ComplexXMLParser10x.cpp index e228777e2..5f82854ca 100644 --- a/six/modules/c++/six.sicd/source/ComplexXMLParser10x.cpp +++ b/six/modules/c++/six.sicd/source/ComplexXMLParser10x.cpp @@ -283,7 +283,7 @@ XMLElem ComplexXMLParser10x::convertAntennaParamArrayToXML( } else { - throw except::Exception(Ctxt(FmtX("[Array] is a mandatory field in AntennaParams of [%s] in 1.0", name))); + throw except::Exception(Ctxt(str::Format("[Array] is a mandatory field in AntennaParams of [%s] in 1.0", name))); } } diff --git a/six/modules/c++/six.sicd/source/GeoData.cpp b/six/modules/c++/six.sicd/source/GeoData.cpp index b141eafbf..6396dbfed 100644 --- a/six/modules/c++/six.sicd/source/GeoData.cpp +++ b/six/modules/c++/six.sicd/source/GeoData.cpp @@ -110,7 +110,7 @@ bool GeoData::validate(logging::Logger& log) const messageBuilder.str(""); messageBuilder << "GeoData.SCP.ECF and GeoData.SCP.LLH not consistent.\n" << "SICD.GeoData.SCP.ECF - SICD.GeoData.SCP.LLH: " << ecfDiff << " (m)\n"; - log.error(messageBuilder.str()); + log.error(messageBuilder); return false; } diff --git a/six/modules/c++/six.sicd/source/Grid.cpp b/six/modules/c++/six.sicd/source/Grid.cpp index 7c9ce29df..9f5577018 100644 --- a/six/modules/c++/six.sicd/source/Grid.cpp +++ b/six/modules/c++/six.sicd/source/Grid.cpp @@ -235,7 +235,7 @@ bool DirectionParameters::validate(const ImageData& imageData, messageBuilder << BOUNDS_ERROR_MESSAGE << std::endl << "SICD.Grid.Row/Col.DeltaK1: " << deltaK1 << std::endl << "SICD.Grid.Row/Col.DetalK2: " << deltaK2 << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -249,7 +249,7 @@ bool DirectionParameters::validate(const ImageData& imageData, << "0.5/SICD.Grid.Row/Col.SampleSpacing: " << 0.5 / sampleSpacing << std::endl << "SICD.Grid.Row/Col.DetalK2: " << deltaK2 << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -261,7 +261,7 @@ bool DirectionParameters::validate(const ImageData& imageData, << "0.5/SICD.Grid.Row/Col.SampleSpacing: " << 0.5 / sampleSpacing << std::endl << "SICD.Grid.Row/Col.DetalK1: " << deltaK1 << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -274,7 +274,7 @@ bool DirectionParameters::validate(const ImageData& imageData, impulseResponseBandwidth << std::endl << "SICD.Grid.Row/Col.DeltaK2 - SICD.Grid.Row/COl.DeltaK1: " << deltaK2 - deltaK1 << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } @@ -294,7 +294,7 @@ bool DirectionParameters::validate(const ImageData& imageData, messageBuilder << BOUNDS_ERROR_MESSAGE << std::endl << "SICD.Grid.Row/Col.DeltaK1: " << deltaK1 << std::endl << "Derived DeltaK1: " << minDk << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } //2.3.9.2, 2.3.9.4 @@ -304,7 +304,7 @@ bool DirectionParameters::validate(const ImageData& imageData, messageBuilder << BOUNDS_ERROR_MESSAGE << std::endl << "SICD.Grid.Row/Col.DeltaK2: " << deltaK2 << std::endl << "Derived DeltaK2: " << maxDk << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -328,7 +328,7 @@ bool DirectionParameters::validate(const ImageData& imageData, messageBuilder << "Unrecognized weighting description" << std::endl << "WeightType.WindowName: " << weightType->windowName << std::endl; - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; } } @@ -343,7 +343,7 @@ bool DirectionParameters::validate(const ImageData& imageData, messageBuilder << "Non-uniform weighting, but no WgtFunct provided" << std::endl << "WgtType.WindowName: " << weightType->windowName << std::endl; - log.warn(messageBuilder.str()); + log.warn(messageBuilder); } return valid; @@ -388,7 +388,7 @@ bool DirectionParameters::validateWeights(const Functor& weightFunction, << "inconsistent with weightType" << std::endl << "WeightType.WindowName: " << weightType->windowName << std::endl; - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; } @@ -443,7 +443,7 @@ bool DirectionParameters::validate(const RgAzComp& rgAzComp, messageBuilder.str(""); messageBuilder << "KCenter: " << kCenter << std::endl << "DeltaKCOAPoly: " << deltaKCOAPoly[0][0]; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -452,7 +452,7 @@ bool DirectionParameters::validate(const RgAzComp& rgAzComp, { messageBuilder.str(""); messageBuilder << "DetlaKCOAPoly must be a single value for RGAZCOMP data"; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } return valid; @@ -528,7 +528,7 @@ bool Grid::validateFFTSigns(logging::Logger& log) const "FFT signs in row and column direction should be the same." << std::endl << "Grid.Row.Sign: " << row->sign << std::endl << "Grid.Col.Sign: " << col->sign << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } return valid; @@ -814,7 +814,7 @@ bool Grid::validate(const RMA& rma, const Vector3& scp, std::ostringstream messageBuilder; messageBuilder << "Given image formation algorithm expects " << defaultGridType(rma) << ".\nFound " << type; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -850,7 +850,7 @@ bool Grid::validate(const RMAT& rmat, const Vector3& scp, << "Grid.Row.UVectECF: " << row->unitVector << std::endl << "Derived grid.Row.UVectECT: " << derivedRowUnitVector(rmat, scp); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -862,7 +862,7 @@ bool Grid::validate(const RMAT& rmat, const Vector3& scp, << "Grid.Col.UVectECF: " << col->unitVector << std::endl << "Derived Grid.Col.UVectECF: " << derivedColUnitVector(rmat, scp); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -873,7 +873,7 @@ bool Grid::validate(const RMAT& rmat, const Vector3& scp, messageBuilder << WF_INCONSISTENT_STR << "Grid.Row.KCtr: " << row->kCenter << std::endl << "Derived KCtr: " << derivedRowKCenter(rmat, fc); - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; } @@ -884,7 +884,7 @@ bool Grid::validate(const RMAT& rmat, const Vector3& scp, messageBuilder << WF_INCONSISTENT_STR << "Grid.Col.KCtr: " << col->kCenter << std::endl << "Derived KCtr: " << derivedColKCenter(rmat, fc); - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; } @@ -905,7 +905,7 @@ bool Grid::validate(const RMCR& rmcr, const Vector3& scp, << "Grid.Row.UVectECF: " << row->unitVector << std::endl << "Derived Grid.Row.UVectECF: " << derivedRowUnitVector(rmcr, scp); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -917,7 +917,7 @@ bool Grid::validate(const RMCR& rmcr, const Vector3& scp, << "Grid.Col.UVectECF: " << col->unitVector << std::endl << "Derived Grid.Col.UVectECF: " << derivedColUnitVector(rmcr, scp); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -927,7 +927,7 @@ bool Grid::validate(const RMCR& rmcr, const Vector3& scp, messageBuilder.str(""); messageBuilder << "Grid.Col.KCtr must be zero for RMA/RMCR data." << std::endl << "Grid.Col.KCtr = " << col->kCenter; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -940,7 +940,7 @@ bool Grid::validate(const RMCR& rmcr, const Vector3& scp, messageBuilder << WF_INCONSISTENT_STR << std::endl << "Grid.Row.KCtr: " << row->kCenter << std::endl << "Center frequency * 2/c: " << derivedRowKCenter(rmcr, fc); - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; } } @@ -974,7 +974,7 @@ bool Grid::validate(const INCA& inca, const Vector3& scp, messageBuilder.str(""); messageBuilder << "Grid.Col.delaKCOAPoly and " << "RMA.INCA.dopplerCentroidPoly have diferent sizes."; - log.error(messageBuilder.str()); + log.error(messageBuilder); } else { @@ -996,7 +996,7 @@ bool Grid::validate(const INCA& inca, const Vector3& scp, messageBuilder << "RMA.INCA fields inconsistent." << std::endl << "Compare Grid.Col.KCOAPoly to RMA.INCA.DopCentroidPoly " << "* RMA.INCA.TimeCAPoly[1]."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } @@ -1011,7 +1011,7 @@ bool Grid::validate(const INCA& inca, const Vector3& scp, << "Grid.Row.UVectECF: " << row->unitVector << std::endl << "Derived Grid.Row.UVectECF: " << derivedRowUnitVector(inca, scp, arpPoly); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1024,7 +1024,7 @@ bool Grid::validate(const INCA& inca, const Vector3& scp, << "Grid.Col.UVectECF: " << col->unitVector << std::endl << "Derived Grid.Col.UVectECF: " << derivedRowUnitVector(inca, scp, arpPoly); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1035,7 +1035,7 @@ bool Grid::validate(const INCA& inca, const Vector3& scp, messageBuilder << "Grid.Col.KCtr must be zero " << "for RMA/INCA data." << std::endl << "Grid.Col.KCtr: " << col->kCenter; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1048,7 +1048,7 @@ bool Grid::validate(const INCA& inca, const Vector3& scp, messageBuilder << WF_INCONSISTENT_STR << std::endl << "RMA.INCA.FreqZero * 2 / c: " << derivedRowKCenter(inca) << std::endl << "Grid.Row.KCenter: " << row->kCenter; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } return valid; @@ -1067,7 +1067,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, messageBuilder.str(""); messageBuilder << "PFA image formation should result in a RGAZIM grid." << std::endl << "Grid.Type: " << type; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1092,7 +1092,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, messageBuilder << WF_INCONSISTENT_STR << "Grid.Row.KCtr: " << row->kCenter << std::endl << "Derived KapCtr: " << kapCtr; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } @@ -1112,7 +1112,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, << 0.5 / col->sampleSpacing << std::endl << "PFA.Kaz2 - Grid.Col.KCenter: " << pfa.kaz2 - col->kCenter << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } //2.3.11 @@ -1125,7 +1125,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, << 0.5 / col->sampleSpacing << std::endl << "PFA.Kaz1 - Grid.Col.KCenter: " << pfa.kaz1 - col->kCenter << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } @@ -1140,7 +1140,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, << 0.5 / row->sampleSpacing << std::endl << "PFA.Krg2 - Grid.Row.KCenter: " << pfa.krg2 - row->kCenter << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1154,7 +1154,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, << 0.5 / row->sampleSpacing << std::endl << "PFA.Krg1 - Grid.Row.KCenter: " << pfa.krg1 - row->kCenter << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1167,7 +1167,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, << col->impulseResponseBandwidth << std::endl << "SICD.PFA.Kaz2 - SICD.PFA.Kaz1: " << pfa.kaz2 - pfa.kaz1 << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } //2.3.15 @@ -1179,7 +1179,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, << row->impulseResponseBandwidth << std::endl << "SICD.PFA.Krg2 - SICD.PFA.Krg1: " << pfa.krg2 - pfa.krg1 << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } //2.3.16 @@ -1191,7 +1191,7 @@ bool Grid::validate(const PFA& pfa, const RadarCollection& radarCollection, << "Grid.Col.KCenter: " << col->kCenter << std::endl << "mean(SICD.PFA.Kaz1, SICD.PFA.Kaz2): " << (pfa.kaz1 + pfa.kaz2) / 2 << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1214,7 +1214,7 @@ bool Grid::validate(const RgAzComp& rgAzComp, messageBuilder << "RGAZCOMP image formation should result in a SLANT plane image." << std::endl << "Grid.ImagePlane: " << imagePlane; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1225,7 +1225,7 @@ bool Grid::validate(const RgAzComp& rgAzComp, messageBuilder << "RGAZCOMP image formation should result in a RGAZIM grid." << std::endl << "Grid.Type: " << type; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1244,7 +1244,7 @@ bool Grid::validate(const RgAzComp& rgAzComp, << "Grid.Row.UVectECEF: " << row->unitVector << std::endl << "Derived Grid.Row.UVectECEF: " << derivedRowUnitVector(scpcoa, scp); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -1257,7 +1257,7 @@ bool Grid::validate(const RgAzComp& rgAzComp, << "Grid.Col.UVectECF: " << col->unitVector << std::endl << "Derived Grid.Col.UVectECF: " << derivedColUnitVector(scpcoa, scp); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } diff --git a/six/modules/c++/six.sicd/source/ImageData.cpp b/six/modules/c++/six.sicd/source/ImageData.cpp index 4b7092608..c3c13a172 100644 --- a/six/modules/c++/six.sicd/source/ImageData.cpp +++ b/six/modules/c++/six.sicd/source/ImageData.cpp @@ -120,7 +120,7 @@ bool ImageData::validate(const GeoData& geoData, logging::Logger& log) const messageBuilder << "ImageData.ValidData/GeoData.ValidData " << "required together." << std::endl << "ImageData.ValidData exists, but GeoData.ValidData does not."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -130,7 +130,7 @@ bool ImageData::validate(const GeoData& geoData, logging::Logger& log) const messageBuilder << "ImageData.ValidData/GeoData.ValidData " << "required together." << std::endl << "GeoData.ValidData exists, but ImageData.ValidData does not."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -153,7 +153,7 @@ bool ImageData::validate(const GeoData& geoData, logging::Logger& log) const { messageBuilder << "ImageData.ValidData first row should have" << "minimum row index"; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } else @@ -173,14 +173,14 @@ bool ImageData::validate(const GeoData& geoData, logging::Logger& log) const { messageBuilder << "ImageData.ValidData first col of matching" << "minimum row index should have minimum col index"; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } if (!Utilities::isClockwise(validData)) { messageBuilder << "ImageData.ValidData should be arrange clockwise"; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } diff --git a/six/modules/c++/six.sicd/source/PFA.cpp b/six/modules/c++/six.sicd/source/PFA.cpp index 4e3d94d27..23f8ac505 100644 --- a/six/modules/c++/six.sicd/source/PFA.cpp +++ b/six/modules/c++/six.sicd/source/PFA.cpp @@ -124,7 +124,7 @@ bool PFA::validate(const SCPCOA& scpcoa, logging::Logger& log) << "time for center are usuallly the same." << std::endl << "PFA.PolarAngRefTime: " << polarAngleRefTime << std::endl << "SCPCOA.SCPTime: " << scpcoa.scpTime; - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; } diff --git a/six/modules/c++/six.sicd/source/RMA.cpp b/six/modules/c++/six.sicd/source/RMA.cpp index 8231d21c2..13485c234 100644 --- a/six/modules/c++/six.sicd/source/RMA.cpp +++ b/six/modules/c++/six.sicd/source/RMA.cpp @@ -96,7 +96,7 @@ bool RMAT::validate(const Vector3& scp, logging::Logger& log) messageBuilder << "RMA fields inconsistent." << std::endl << "RMA.RMAT.DopConeAngleRef: " << dopConeAngleRef << std::endl << "Derived RMA.RMAT.DopConeAngleRef: " << dcaRef; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } return valid; @@ -181,7 +181,7 @@ bool RMCR::validate(const Vector3& scp, logging::Logger& log) messageBuilder << "RMA fields inconsistent." << std::endl << "RMA.RMCR.DopConeAngleRef: " << dopConeAngleRef << std::endl << "Derived RMA.RMCR.DopConeAngleRef: " << dcaRef; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } return valid; @@ -264,7 +264,7 @@ bool INCA::validate(const CollectionInformation& collectionInformation, messageBuilder << "RMA.INCA fields inconsistent." << std::endl << "RMA.INCA.DopplerCentroidPoly/DopplerCentroidCOA " << "should not be included for SPOTLIGHT collection."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -277,7 +277,7 @@ bool INCA::validate(const CollectionInformation& collectionInformation, messageBuilder << "RMA.INCA fields inconsistent." << std::endl << "RMA.INCA.DopplerCentroidPoly/COA required " << "for non-SPOTLIGHT collection."; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -288,7 +288,7 @@ bool INCA::validate(const CollectionInformation& collectionInformation, messageBuilder << "RMA.INCA.FreqZero is typically the center transmit frequency" << std::endl << "RMA.INCA.FreqZero: " << freqZero << "Center transmit frequency: " << fc; - log.warn(messageBuilder.str()); + log.warn(messageBuilder); valid = false; } @@ -299,7 +299,7 @@ bool INCA::validate(const CollectionInformation& collectionInformation, messageBuilder << "RMA.INCA fields inconsistent." << std::endl << "RMA.INCA.rangeCA: " << rangeCA << "Derived RMA.INCA.rangeCA: " << derivedRangeCa(scp, arpPoly); - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -417,6 +417,6 @@ bool RMA::validate(const CollectionInformation& collectionInformation, std::ostringstream messageBuilder; messageBuilder << "Exactly one of RMA->RMAT, RMA->RMCR, RMA->INCA " << "must exist."; - log.error(messageBuilder.str()); + log.error(messageBuilder); return false; } diff --git a/six/modules/c++/six.sicd/source/RadarCollection.cpp b/six/modules/c++/six.sicd/source/RadarCollection.cpp index e90ea5b3b..dc131532a 100644 --- a/six/modules/c++/six.sicd/source/RadarCollection.cpp +++ b/six/modules/c++/six.sicd/source/RadarCollection.cpp @@ -147,7 +147,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, << txRFBandwidth << std::endl << "SICD.RadarCollection.TxFrequency.txFMRate * txPulseLength: " << txFMRate * txPulseLength << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -161,7 +161,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, << rcvDemodType << std::endl << "SICD.RadarCollection.Waveform.WFParameters.RcvFMRate: " << rcvFMRate << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -177,7 +177,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, << rcvFMRate << std::endl << "SICD.RadarCollection.Waveform.WFParameters.TxFMRate: " << txFMRate << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -190,7 +190,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, messageBuilder << WF_INCONSISTENT_STR << std::endl << "SICD.RadarCollection.txFreqStart: " << txFrequencyStart << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -203,7 +203,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, messageBuilder << WF_INCONSISTENT_STR << std::endl << "SICD.RadarCollection.rcvFreqStart: " << rcvFrequencyStart << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -216,7 +216,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, << txPulseLength << std::endl << "SICD.RadarCollection.Waveform.WFPArameters.RcvWindowLength: " << rcvWindowLength << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -229,7 +229,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, << rcvIFBandwidth << std::endl << "SICD.RadarCollection.Waveform.WFPArameters.ADCSampleRate: " << adcSampleRate << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -244,7 +244,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, << txRFBandwidth << std::endl << "SICD.RadarCollection.Waveform.WFPArameters.ADCSampleRate: " << adcSampleRate << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -259,7 +259,7 @@ bool WaveformParameters::validate(int refFrequencyIndex, messageBuilder << WF_INCONSISTENT_STR << std::endl << "SICD.RadarCollection.Waveform.WFParameters.RcvFreqStart: " << rcvFrequencyStart << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } @@ -557,7 +557,7 @@ bool RadarCollection::validate(logging::Logger& log) const << wfMin << std::endl << "SICD.RadarCollection.TxFrequency.Min: " << txFrequencyMin << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -571,7 +571,7 @@ bool RadarCollection::validate(logging::Logger& log) const << " + TxFRBandwidth: " << wfMax << std::endl << "SICD.RadarCollection.TxFrequency.Max: " << txFrequencyMax << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -583,7 +583,7 @@ bool RadarCollection::validate(logging::Logger& log) const messageBuilder << WF_INCONSISTENT_STR << std::endl << "SICD.RadarCollection.txFrequencyMin: " << txFrequencyMin << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } diff --git a/six/modules/c++/six.sicd/source/RgAzComp.cpp b/six/modules/c++/six.sicd/source/RgAzComp.cpp index aafc5a473..7745fee18 100644 --- a/six/modules/c++/six.sicd/source/RgAzComp.cpp +++ b/six/modules/c++/six.sicd/source/RgAzComp.cpp @@ -73,7 +73,7 @@ bool RgAzComp::validate(const GeoData& geoData, messageBuilder << "RGAZCOMP fields inconsistent." << std::endl << "RgAzComp.AzSF: " << azSF << std::endl << "Derived RgAzComp.AzSF: " << expectedAzSf; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -95,7 +95,7 @@ bool RgAzComp::validate(const GeoData& geoData, messageBuilder << "RGAZCOMP fields inconsistent." << std::endl << "RgAzComp.KazPoly: " << kazPoly << std::endl << "Derived RgAzComp.KazPoly: " << derivedPoly; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } } diff --git a/six/modules/c++/six.sicd/source/SCPCOA.cpp b/six/modules/c++/six.sicd/source/SCPCOA.cpp index 54990f66e..c4eed14da 100644 --- a/six/modules/c++/six.sicd/source/SCPCOA.cpp +++ b/six/modules/c++/six.sicd/source/SCPCOA.cpp @@ -220,7 +220,7 @@ bool SCPCOA::validate(const GeoData& geoData, messageBuilder << SCPCOA_INCONSISTENT_STR << "\n" << "SCPCOA.scpTime: " << scpTime << std::endl << "Derived scpTime: " << derivedSCPTime(grid) << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -243,7 +243,7 @@ bool SCPCOA::validate(const GeoData& geoData, "SCPCOA.SideOfTrack: " << sideOfTrack << std::endl << "Derived SideOfTrack: " << geometry.getSideOfTrack() << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); valid = false; } @@ -282,7 +282,7 @@ bool SCPCOA::compareFields(double given, double expected, messageBuilder << SCPCOA_INCONSISTENT_STR << "\n" << "SCPCOA." << name << ": " << given << std::endl << "Derived " << name << ": " << expected << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); return false; } @@ -298,6 +298,6 @@ bool SCPCOA::compareFields(Vector3 given, Vector3 expected, messageBuilder << SCPCOA_INCONSISTENT_STR << "\n" << "SCPCOA." << name << ": " << given << std::endl << "Derived " << name << ": " << expected << std::endl; - log.error(messageBuilder.str()); + log.error(messageBuilder); return false; } diff --git a/six/modules/c++/six.sicd/tests/test_sicd_schemata.cpp b/six/modules/c++/six.sicd/tests/test_sicd_schemata.cpp index d32e3811a..d275108fa 100644 --- a/six/modules/c++/six.sicd/tests/test_sicd_schemata.cpp +++ b/six/modules/c++/six.sicd/tests/test_sicd_schemata.cpp @@ -2422,7 +2422,7 @@ bool cmpRoundTripXMLs(std::string xmlText, std::string xmlPath = "", // parse the programetically generated SICD XML string xml::lite::MinidomParser parser; io::StringStream oss; - oss.write(xmlText.c_str(), xmlText.size()); + oss.write(xmlText); parser.parse(oss); // apply parsed XML to document, print its XML string and compare to original XML string diff --git a/six/modules/c++/six.sidd/source/DerivedClassification.cpp b/six/modules/c++/six.sidd/source/DerivedClassification.cpp index dfe850632..bb6647b29 100644 --- a/six/modules/c++/six.sidd/source/DerivedClassification.cpp +++ b/six/modules/c++/six.sidd/source/DerivedClassification.cpp @@ -48,7 +48,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, const std::string fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::REL, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, releasableToStr))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, releasableToStr))); } if (!classifiedBy.empty()) @@ -57,7 +57,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, std::string fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::CAUT, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, classifiedBy))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, classifiedBy))); // classifiedBy attribute represents the name of the original // classification authority @@ -66,7 +66,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::CATP, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, classAuthorityType))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, classAuthorityType))); } if (!classificationReason.empty()) @@ -75,7 +75,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, const std::string fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::CRSN, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, classificationReason))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, classificationReason))); } // By default, mark as exempt from automatic declassification @@ -90,7 +90,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, const std::string fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::DCDT, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, declassDateStr))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, declassDateStr))); // Declassify on a specific date declassType = "DD"; @@ -102,7 +102,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, const std::string fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::CLTX, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, declassEvent))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, declassEvent))); // Declassify upon occurrence of an event declassType = "DE"; @@ -123,7 +123,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, const std::string fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::DCXM, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, exemptedSourceType))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, exemptedSourceType))); // Exempt from automatic declassification declassType = "X"; @@ -159,7 +159,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, const std::string fieldKey = NITFImageInfo::generateFieldKey(NITFImageInfo::DCXM, prefix); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, declassExemption))); + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", fieldKey, declassExemption))); // Exempt from automatic declassification declassType = "X"; @@ -169,7 +169,7 @@ void DerivedClassification::setSecurity(const std::string& prefix, // Now that we've gone through all the things that could modify the // declassification type, set it security.getDeclassificationType().set(declassType); - log.debug(Ctxt(FmtX("Setting NITF [%s] from sicd/sidd: [%s]", + log.debug(Ctxt(str::Format("Setting NITF [%s] from sicd/sidd: [%s]", NITFImageInfo::generateFieldKey(NITFImageInfo::DCTP, prefix), declassType))); } } @@ -192,8 +192,7 @@ void DerivedClassification::putImpl(const std::string& name, os << name << ":\n"; for (size_t ii = 0; ii < params.size(); ++ii) { - os << " [" << params[ii].getName() << " = " - << params[ii].str() << "]\n"; + os << " [" << params[ii].getName() << " = " << params[ii] << "]\n"; } } diff --git a/six/modules/c++/six.sidd/source/DerivedXMLParser.cpp b/six/modules/c++/six.sidd/source/DerivedXMLParser.cpp index 88e01b510..397c1920c 100644 --- a/six/modules/c++/six.sidd/source/DerivedXMLParser.cpp +++ b/six/modules/c++/six.sidd/source/DerivedXMLParser.cpp @@ -1173,7 +1173,7 @@ XMLElem DerivedXMLParser::createLUTImpl(const LUT *lut, XMLElem lutElem) const { std::ostringstream ostr; ostr << "Invalid element size [" << lut->elementSize << "]"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } if ((lut->numEntries - 1) != i) oss << ' '; @@ -1236,7 +1236,7 @@ XMLElem DerivedXMLParser::convertProductProcessingToXML( // error checking if (productProcessing->processingModules.empty()) { - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "There must be at least [1] ProcessingModule in "\ "ProductProcessing, [%d] found", productProcessing->processingModules.size()))); @@ -1847,7 +1847,7 @@ XMLElem DerivedXMLParser::createSFALine( // error check the vertices if (l->vertices.size() < 2) - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "Must be at least two Vertices in LineString. Only [%d] " \ "found", l->vertices.size()))); @@ -1948,7 +1948,7 @@ XMLElem DerivedXMLParser::convertSFAGeometryToXML( // error check the vertices if (p->vertices.size() < 2) - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "Must be at least two Vertices in LineString. Only [%d] " \ "found", p->vertices.size()))); @@ -1960,7 +1960,7 @@ XMLElem DerivedXMLParser::convertSFAGeometryToXML( } else { - throw except::InvalidArgumentException(Ctxt(FmtX("Invalid geo type: [%s]", geoType))); + throw except::InvalidArgumentException(Ctxt(str::Format("Invalid geo type: [%s]", geoType))); } return geoElem; diff --git a/six/modules/c++/six.sidd/source/DerivedXMLParser100.cpp b/six/modules/c++/six.sidd/source/DerivedXMLParser100.cpp index afcd9aef9..ff84a9e13 100644 --- a/six/modules/c++/six.sidd/source/DerivedXMLParser100.cpp +++ b/six/modules/c++/six.sidd/source/DerivedXMLParser100.cpp @@ -566,7 +566,7 @@ XMLElem DerivedXMLParser100::convertExploitationFeaturesToXML( if (exploitationFeatures->collections.empty()) { - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "ExploitationFeatures must have at least [1] Collection, " \ "only [%d] found", exploitationFeatures->collections.size()))); } diff --git a/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp b/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp index e2b0fdc7e..3bdd6fc3d 100644 --- a/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp +++ b/six/modules/c++/six.sidd/source/DerivedXMLParser200.cpp @@ -1369,7 +1369,7 @@ xml::lite::Element& DerivedXMLParser200::convertKernelToXML(const DerivedXMLPars ostr << "Filter size is " << kernel.custom->size.row << " rows x " << kernel.custom->size.col << " cols but have " << kernel.custom->filterCoef.size() << " coefficients"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } auto& filterCoef = parser.newElement("FilterCoefficients", customElem); @@ -1422,7 +1422,7 @@ xml::lite::Element& DerivedXMLParser200::convertBankToXML(const DerivedXMLParser ostr << "Filter size is " << bank.custom->numPhasings << " x " << bank.custom->numPoints << " but have " << bank.custom->filterCoef.size() << " coefficients"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } auto& filterCoef = parser.newElement("FilterCoefficients", customElem); @@ -1582,7 +1582,7 @@ xml::lite::Element& DerivedXMLParser200::convertExploitationFeaturesToXML(const if (exploitationFeatures.collections.empty()) { - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "ExploitationFeatures must have at least [1] Collection, " \ "only [%d] found", exploitationFeatures.collections.size()))); } diff --git a/six/modules/c++/six.sidd/source/GeoTIFFWriteControl.cpp b/six/modules/c++/six.sidd/source/GeoTIFFWriteControl.cpp index 7d2c469c2..89c7c1127 100644 --- a/six/modules/c++/six.sidd/source/GeoTIFFWriteControl.cpp +++ b/six/modules/c++/six.sidd/source/GeoTIFFWriteControl.cpp @@ -77,7 +77,7 @@ void GeoTIFFWriteControl::initialize(std::shared_ptr container) mDerivedData.push_back(data); } else - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "Data element at position [%d] in container is undefined", ii))); } @@ -92,7 +92,7 @@ void GeoTIFFWriteControl::save(const SourceList& sources, tiffWriter.writeHeader(); if (sources.size() != mDerivedData.size()) - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "Meta-data count [%d] does not match source list [%d]", mDerivedData.size(), sources.size()))); @@ -177,7 +177,7 @@ void GeoTIFFWriteControl::setupIFD(const DerivedData* data, } ifd->addEntry(tiff::KnownTags::PHOTOMETRIC_INTERPRETATION, photoInterp); - addStringArray(ifd, "ImageDescription", FmtX("SIDD: %s", data->getName())); + addStringArray(ifd, "ImageDescription", str::Format("SIDD: %s", data->getName())); constexpr unsigned short orientation = 1; ifd->addEntry("Orientation", orientation); @@ -268,7 +268,7 @@ void GeoTIFFWriteControl::save(const TBufferList& sources, tiffWriter.writeHeader(); if (sources.size() != mDerivedData.size()) - throw except::Exception(Ctxt(FmtX( + throw except::Exception(Ctxt(str::Format( "Meta-data count [%d] does not match source list [%d]", mDerivedData.size(), sources.size()))); diff --git a/six/modules/c++/six.sidd/source/SIDDVersionUpdater.cpp b/six/modules/c++/six.sidd/source/SIDDVersionUpdater.cpp index 5161c22a0..9acb8b2ed 100644 --- a/six/modules/c++/six.sidd/source/SIDDVersionUpdater.cpp +++ b/six/modules/c++/six.sidd/source/SIDDVersionUpdater.cpp @@ -175,8 +175,7 @@ void SIDDVersionUpdater::updateSingleIncrement() emitWarning(msg.str()); msg.str(""); - msg << "ExploitationFeatures.Product[" << ii - << "].Polarization"; + msg << "ExploitationFeatures.Product[" << ii << "].Polarization"; emitWarning(msg.str()); } } diff --git a/six/modules/c++/six/include/six/Enum.h b/six/modules/c++/six/include/six/Enum.h index b35ca0fde..8ddae2324 100644 --- a/six/modules/c++/six/include/six/Enum.h +++ b/six/modules/c++/six/include/six/Enum.h @@ -67,14 +67,14 @@ namespace details inline T index(const std::map& map, const std::string& v) { const auto result = nitf::details::index(map, v); - const except::InvalidFormatException ex(Ctxt(FmtX("Invalid enum value: %s", v))); + const except::InvalidFormatException ex(Ctxt(str::Format("Invalid enum value: %s", v))); return nitf::details::value(result, ex); } template inline std::string index(const std::map& map, T v) { const auto result = nitf::details::index(map, v); - const except::InvalidFormatException ex(Ctxt(FmtX("Invalid enum value: %d", v))); + const except::InvalidFormatException ex(Ctxt(str::Format("Invalid enum value: %d", v))); return nitf::details::value(result, ex); } @@ -84,7 +84,7 @@ namespace details constexpr auto not_set_value = static_cast(NOT_SET_VALUE); if (throw_if_not_set && (value == not_set_value)) { - throw except::InvalidFormatException(Ctxt(FmtX("Invalid enum value: %d", value))); + throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %d", value))); } return index(map, value); } diff --git a/six/modules/c++/six/include/six/Parameter.h b/six/modules/c++/six/include/six/Parameter.h index 1251a3273..62b09c6f5 100644 --- a/six/modules/c++/six/include/six/Parameter.h +++ b/six/modules/c++/six/include/six/Parameter.h @@ -23,6 +23,8 @@ #ifndef SIX_six_Parameter_h_INCLUDED_ #define SIX_six_Parameter_h_INCLUDED_ +#include + #include #include "six/Types.h" @@ -164,6 +166,19 @@ struct Parameter final std::string mName; }; +inline std::ostream& operator<<(std::ostream& os, const Parameter& p) +{ + os << p.str(); + return os; +} + +inline std::ostream& out(std::ostream& os, const Parameter& p) +{ + os << " Parameter Name : " << p.getName() << "\n" + << " Parameter Value : " << p << "\n"; + return os; +} + } #endif // SIX_six_Parameter_h_INCLUDED_ \ No newline at end of file diff --git a/six/modules/c++/six/include/six/Types.h b/six/modules/c++/six/include/six/Types.h index 84cd4ab85..96f590f6c 100644 --- a/six/modules/c++/six/include/six/Types.h +++ b/six/modules/c++/six/include/six/Types.h @@ -215,7 +215,7 @@ struct Constants return 3; default: - throw except::Exception(Ctxt(FmtX("Unknown pixel type [%d]", (int) type))); + throw except::Exception(Ctxt(str::Format("Unknown pixel type [%d]", (int) type))); } } diff --git a/six/modules/c++/six/source/Classification.cpp b/six/modules/c++/six/source/Classification.cpp index 51b3b2e34..7ac4ce990 100644 --- a/six/modules/c++/six/source/Classification.cpp +++ b/six/modules/c++/six/source/Classification.cpp @@ -51,8 +51,7 @@ std::ostream& operator<<(std::ostream& os, const Classification& c) iter != c.fileOptions.end(); ++iter) { - os << " {" << iter->first << "} " << iter->second.str() - << std::endl; + os << " {" << iter->first << "} " << iter->second << "\n"; } return os; } diff --git a/six/modules/c++/six/source/CollectionInformation.cpp b/six/modules/c++/six/source/CollectionInformation.cpp index ac524f965..e2ed2197f 100644 --- a/six/modules/c++/six/source/CollectionInformation.cpp +++ b/six/modules/c++/six/source/CollectionInformation.cpp @@ -87,8 +87,7 @@ std::ostream& operator<< (std::ostream& os, const six::CollectionInformation& c) } for (size_t ii = 0; ii < c.parameters.size(); ++ii) { - os << " Parameter name : " << c.parameters[ii].getName() << "\n" - << " Parameter value : " << c.parameters[ii].str() << "\n"; + out(os, c.parameters[ii]); } return os; } diff --git a/six/modules/c++/six/source/GeoInfo.cpp b/six/modules/c++/six/source/GeoInfo.cpp index 51fa81044..b37076f3b 100644 --- a/six/modules/c++/six/source/GeoInfo.cpp +++ b/six/modules/c++/six/source/GeoInfo.cpp @@ -30,7 +30,7 @@ std::ostream& operator<< (std::ostream& os, const GeoInfo& g) << " Name : " << g.name << "\n"; for (size_t ii = 0; ii < g.desc.size(); ++ii) { - os << " Description : " << g.desc[ii].getName() << ": " << g.desc[ii].str() << "\n"; + os << " Description : " << g.desc[ii].getName() << ": " << g.desc[ii] << "\n"; } if (g.geometryLatLon.size() == 1) { diff --git a/six/modules/c++/six/source/MatchInformation.cpp b/six/modules/c++/six/source/MatchInformation.cpp index 515b94922..a5783e14d 100644 --- a/six/modules/c++/six/source/MatchInformation.cpp +++ b/six/modules/c++/six/source/MatchInformation.cpp @@ -75,7 +75,7 @@ std::ostream& operator<< (std::ostream& os, const MatchInformation& m) { os << " Parameter : " << m.types[ii].matchCollects[jj].parameters[kk].getName() - << ": " << m.types[ii].matchCollects[jj].parameters[kk].str() << "\n"; + << ": " << m.types[ii].matchCollects[jj].parameters[kk] << "\n"; } } } diff --git a/six/modules/c++/six/source/NITFHeaderCreator.cpp b/six/modules/c++/six/source/NITFHeaderCreator.cpp index 1b777950b..ede76474f 100644 --- a/six/modules/c++/six/source/NITFHeaderCreator.cpp +++ b/six/modules/c++/six/source/NITFHeaderCreator.cpp @@ -21,6 +21,9 @@ */ #include #include +#include +#include +#include #include #include @@ -50,10 +53,8 @@ void setField(const std::string& field, std::ostringstream ostr; ostr << "Tried to set field '" << field << "' to '" << value << "' but this is " << value.length() << " characters when the " - << "field can only contain " << treField.getLength() - << " characters"; - - throw except::Exception(Ctxt(ostr.str())); + << "field can only contain " << treField.getLength() << " characters"; + throw except::Exception(Ctxt(ostr)); } treField = value; @@ -243,103 +244,44 @@ void NITFHeaderCreator::setDESecurity(const six::Classification& classification, setSecurity(classification, subheader.getSecurityGroup(), "DES"); } +struct SecurityParameterSetter final +{ + const std::string& prefix; + const Options ops; + void operator()(const std::string& field, std::function getField) const + { + const auto k = NITFImageInfo::generateFieldKey(field, prefix); + if (ops.hasParameter(k)) + { + Parameter p = ops.getParameter(k); + getField().set(p.str()); + } + } + SecurityParameterSetter() = delete; + SecurityParameterSetter& operator=(const SecurityParameterSetter&) = delete; +}; + void NITFHeaderCreator::setSecurity(const six::Classification& classification, nitf::FileSecurity security, const std::string& prefix) { - std::string k; - const Options& ops = classification.fileOptions; - - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CLSY, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getClassificationSystem().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CODE, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getCodewords().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CTLH, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getControlAndHandling().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::REL, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getReleasingInstructions().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::DCTP, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getDeclassificationType().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::DCDT, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getDeclassificationDate().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::DCXM, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getDeclassificationExemption().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::DG, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getDowngrade().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::DGDT, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getDowngradeDateTime().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CLTX, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getClassificationText().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CATP, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getClassificationAuthorityType().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CAUT, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getClassificationAuthority().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CRSN, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getClassificationReason().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::SRDT, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getSecuritySourceDate().set(p.str()); - } - k = NITFImageInfo::generateFieldKey(NITFImageInfo::CTLN, prefix); - if (ops.hasParameter(k)) - { - Parameter p = ops.getParameter(k); - security.getSecurityControlNumber().set(p.str()); - } + const SecurityParameterSetter setSecurityParameter{ prefix, classification.fileOptions }; + setSecurityParameter(NITFImageInfo::CLSY, [&]() { return security.getClassificationSystem(); }); + setSecurityParameter(NITFImageInfo::CLSY, [&]() { return security.getClassificationSystem(); }); + setSecurityParameter(NITFImageInfo::CODE, [&]() { return security.getCodewords(); }); + setSecurityParameter(NITFImageInfo::CTLH, [&]() { return security.getControlAndHandling(); }); + setSecurityParameter(NITFImageInfo::REL, [&]() { return security.getReleasingInstructions(); }); + setSecurityParameter(NITFImageInfo::DCTP, [&]() { return security.getDeclassificationType(); }); + setSecurityParameter(NITFImageInfo::DCDT, [&]() { return security.getDeclassificationDate(); }); + setSecurityParameter(NITFImageInfo::DCXM, [&]() { return security.getDeclassificationExemption(); }); + setSecurityParameter(NITFImageInfo::DG, [&]() { return security.getDowngrade(); }); + setSecurityParameter(NITFImageInfo::DGDT, [&]() { return security.getDowngradeDateTime(); }); + setSecurityParameter(NITFImageInfo::CLTX, [&]() { return security.getClassificationText(); }); + setSecurityParameter(NITFImageInfo::CATP, [&]() { return security.getClassificationAuthorityType(); }); + setSecurityParameter(NITFImageInfo::CAUT, [&]() { return security.getClassificationAuthority(); }); + setSecurityParameter(NITFImageInfo::CRSN, [&]() { return security.getClassificationReason(); }); + setSecurityParameter(NITFImageInfo::SRDT, [&]() { return security.getSecuritySourceDate(); }); + setSecurityParameter(NITFImageInfo::CTLN, [&]() { return security.getSecurityControlNumber(); }); // Now, do some specific overrides if (security.getClassificationSystem().toString().empty()) @@ -793,9 +735,8 @@ void NITFHeaderCreator::initialize(std::shared_ptr container) { std::ostringstream ostr; ostr << "Row offset cannot exceed " << maxRows - << ", but for image segment " << jj << " it is " - << segmentInfo.getFirstRow(); - throw except::Exception(Ctxt(ostr.str())); + << ", but for image segment " << jj << " it is " << segmentInfo.getFirstRow(); + throw except::Exception(Ctxt(ostr)); } subheader.getImageLocation().set(generateILOC(segmentInfo.getRowOffset(), 0)); diff --git a/six/modules/c++/six/source/NITFReadControl.cpp b/six/modules/c++/six/source/NITFReadControl.cpp index d40e95cd3..6dfb7756c 100644 --- a/six/modules/c++/six/source/NITFReadControl.cpp +++ b/six/modules/c++/six/source/NITFReadControl.cpp @@ -237,7 +237,7 @@ void NITFReadControl::validateSegment(const nitf::ImageSubheader& subheader, { std::ostringstream ostr; ostr << "Expected [" << expectedBytesPerPixel << "] bytes per pixel, found [" << foundBytesPerPixel << "]"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } const auto numCols = info.getData()->getNumCols(); @@ -246,7 +246,7 @@ void NITFReadControl::validateSegment(const nitf::ImageSubheader& subheader, { std::ostringstream ostr; ostr << "Invalid column width: was expecting [" << numCols << "], got [" << numColsSubheader << "]"; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } } @@ -538,7 +538,7 @@ class AddSecurityOption final Parameter p = parameter.toString(); const auto k = NITFImageInfo::generateFieldKey(field, prefix_); options_.setParameter(k, p); - log_.debug(Ctxt(FmtX("Added NITF security option: [%s]->[%s]", k.c_str(), + log_.debug(Ctxt(str::Format("Added NITF security option: [%s]->[%s]", k, static_cast(p)))); } }; @@ -664,10 +664,10 @@ UByte* NITFReadControl::interleaved(Region& region, size_t imageNumber) const auto extentCols = startCol + numColsReq; if (extentRows > numRowsTotal || startRow > numRowsTotal) - throw except::Exception(Ctxt(FmtX("Too many rows requested [%d]", numRowsReq))); + throw except::Exception(Ctxt(str::Format("Too many rows requested [%d]", numRowsReq))); if (extentCols > numColsTotal || startCol > numColsTotal) - throw except::Exception(Ctxt(FmtX("Too many cols requested [%d]", numColsReq))); + throw except::Exception(Ctxt(str::Format("Too many cols requested [%d]", numColsReq))); // Allocate one band uint32_t bandList(0); diff --git a/six/modules/c++/six/source/NITFWriteControl.cpp b/six/modules/c++/six/source/NITFWriteControl.cpp index aa5906229..add7312eb 100644 --- a/six/modules/c++/six/source/NITFWriteControl.cpp +++ b/six/modules/c++/six/source/NITFWriteControl.cpp @@ -260,7 +260,7 @@ bool NITFWriteControl::do_prepareIO(size_t imageDataSize, nitf::IOInterface& out { std::ostringstream ostr; ostr << "Require " << infos.size() << " images, received " << imageDataSize; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } nitf::Record& record = getRecord(); diff --git a/six/modules/c++/six/source/Utilities.cpp b/six/modules/c++/six/source/Utilities.cpp index 5f5cc558f..857b01f5a 100644 --- a/six/modules/c++/six/source/Utilities.cpp +++ b/six/modules/c++/six/source/Utilities.cpp @@ -324,7 +324,7 @@ PixelType six::toType(const std::string& s) { auto p = PixelType::toType(s); if (p == PixelType::NOT_SET) - throw except::Exception(Ctxt(FmtX("Type not understood [%s]", s))); + throw except::Exception(Ctxt(str::Format("Type not understood [%s]", s))); return p; } diff --git a/six/modules/c++/six/source/VersionUpdater.cpp b/six/modules/c++/six/source/VersionUpdater.cpp index 9a672bd2e..42a66b7db 100644 --- a/six/modules/c++/six/source/VersionUpdater.cpp +++ b/six/modules/c++/six/source/VersionUpdater.cpp @@ -44,7 +44,7 @@ void VersionUpdater::validateTargetVersion() const { std::ostringstream msg; msg << "Unrecognized version: " << mTarget; - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } const auto currentIt = std::find(mVersions.begin(), mVersions.end(), @@ -54,7 +54,7 @@ void VersionUpdater::validateTargetVersion() const std::ostringstream msg; msg << "Target version <" << mTarget << "> must be later than " << "current version <" << mData.getVersion() << ">"; - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } } @@ -103,7 +103,7 @@ void VersionUpdater::emitWarning(const std::string& fieldName) } std::ostringstream msg; msg << " - " << fieldName; - mLog.warn(msg.str()); + mLog.warn(msg); addProcessingParameter(fieldName); } diff --git a/six/modules/c++/six/source/XMLControl.cpp b/six/modules/c++/six/source/XMLControl.cpp index 87f0120df..ca359a49e 100644 --- a/six/modules/c++/six/source/XMLControl.cpp +++ b/six/modules/c++/six/source/XMLControl.cpp @@ -137,7 +137,7 @@ static auto check_whether_paths_exist(const std::vector& { std::ostringstream msg; msg << does_not_exist_path << " does not exist!"; - throw except::Exception(Ctxt(msg.str())); + throw except::Exception(Ctxt(msg)); } return exist_paths; } @@ -251,7 +251,7 @@ void XMLControl::validate(const xml::lite::Document* doc, oss << "Coudn't validate XML - no schemas paths provided " << " and " << six::SCHEMA_PATH << " not set."; - log->warn(oss.str()); + log->warn(oss); } std::vector schemaPaths_; @@ -275,7 +275,7 @@ void XMLControl::validate(const xml::lite::Document& doc, oss << "Coudn't validate XML - no schemas paths provided " << " and " << six::SCHEMA_PATH << " not set."; - log->warn(oss.str()); + log->warn(oss); } // validate against any specified schemas @@ -447,5 +447,5 @@ std::string six::getSchemaPath(std::vector& schemaPaths, bool tryTo } } - throw except::IOException(Ctxt(FmtX("Directory does not exist: '%s'", schemaPath))); + throw except::IOException(Ctxt(str::Format("Directory does not exist: '%s'", schemaPath))); } diff --git a/six/modules/c++/six/tests/test_determine_data_type.cpp b/six/modules/c++/six/tests/test_determine_data_type.cpp index 244a621c1..b5c6027b3 100644 --- a/six/modules/c++/six/tests/test_determine_data_type.cpp +++ b/six/modules/c++/six/tests/test_determine_data_type.cpp @@ -46,7 +46,7 @@ void testDataType(const fs::path& pathname_, six::DataType expectedDataType) ostr << "Expected " << pathname << " to be " << expectedDataType << " but got " << dataType; - throw except::Exception(Ctxt(ostr.str())); + throw except::Exception(Ctxt(ostr)); } } }