Skip to content

Commit

Permalink
Merge branch 'main' into develop/sync_externals
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Nov 8, 2023
2 parents b46b11c + 86bd245 commit f174846
Show file tree
Hide file tree
Showing 52 changed files with 273 additions and 298 deletions.
16 changes: 8 additions & 8 deletions externals/coda-oss/modules/c++/except/include/except/Context.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
*
*/


#pragma once
#ifndef CODA_OSS_except_Context_h_INCLUDED_
#define CODA_OSS_except_Context_h_INCLUDED_
#pragma once

#include <string>
#include <ostream>
#include <sstream>

#include "config/Exports.h"
#include "config/disable_compiler_warnings.h"
Expand Down Expand Up @@ -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 = "",
Expand Down
13 changes: 13 additions & 0 deletions externals/coda-oss/modules/c++/logging/include/logging/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
// Logger.h
///////////////////////////////////////////////////////////

#pragma once
#ifndef CODA_OSS_logging_Logger_h_INCLUDED_
#define CODA_OSS_logging_Logger_h_INCLUDED_

#include <string>
#include <vector>
#include <memory>
#include <sstream>

#include "config/Exports.h"
#include "logging/Filterer.h"
Expand Down Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions externals/coda-oss/modules/c++/logging/source/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions six/modules/c++/cphd/source/CPHDWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions six/modules/c++/cphd/source/CPHDXMLControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <version, URI> entry to versionUriMap";
throw except::Exception(Ctxt(ostr.str()));
<< "Either input a valid URI or add a <version, URI> entry to versionUriMap";
throw except::Exception(Ctxt(ostr));
}

}
Expand Down
4 changes: 2 additions & 2 deletions six/modules/c++/cphd/source/CPHDXMLParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions six/modules/c++/cphd/source/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
15 changes: 7 additions & 8 deletions six/modules/c++/cphd/source/Data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand All @@ -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())
Expand All @@ -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));
}
}

Expand Down Expand Up @@ -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));
}
}

Expand Down
6 changes: 2 additions & 4 deletions six/modules/c++/cphd/source/ErrorParameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions six/modules/c++/cphd/source/PVPBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}
Expand Down
7 changes: 2 additions & 5 deletions six/modules/c++/cphd/source/ProductInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
7 changes: 3 additions & 4 deletions six/modules/c++/cphd/source/SupportArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ static SupportArrayParameter getSupportArray(const std::vector<SupportArrayParam
{
std::ostringstream oss;
oss << "SA_ID was not found " << (key);
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
return params[keyNum];
}
Expand All @@ -114,7 +114,7 @@ AdditionalSupportArray SupportArray::getAddedSupportArray(const std::string& key
{
std::ostringstream oss;
oss << "SA_ID was not found " << (key);
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
return addedSupportArray.find(key)->second;
}
Expand All @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/cphd/source/SupportBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void SupportBlock::read(const std::string& id, size_t numThreads, std::span<std:
{
std::ostringstream ostr;
ostr << "Need at least " << minSize << " bytes but only got " << data.size();
throw except::Exception(Ctxt(ostr.str()));
throw except::Exception(Ctxt(ostr));
}

// Perform the read
Expand Down
25 changes: 10 additions & 15 deletions six/modules/c++/cphd/source/Wideband.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,8 @@ void Wideband::read(size_t channel,
if (data.size < minSize)
{
std::ostringstream ostr;
ostr << "Need at least " << minSize << " bytes but only got "
<< data.size;
throw except::Exception(Ctxt(ostr.str()));
ostr << "Need at least " << minSize << " bytes but only got " << data.size;
throw except::Exception(Ctxt(ostr));
}

// Perform the read
Expand Down Expand Up @@ -525,9 +524,8 @@ void Wideband::read(size_t channel,
if (data.size < minSize)
{
std::ostringstream ostr;
ostr << "Need at least " << minSize << " bytes but only got "
<< data.size;
throw except::Exception(Ctxt(ostr.str()));
ostr << "Need at least " << minSize << " bytes but only got " << data.size;
throw except::Exception(Ctxt(ostr));
}

// Perform the read
Expand Down Expand Up @@ -613,9 +611,8 @@ void Wideband::read(size_t channel,
if (vectorScaleFactors.size() != dims.row)
{
std::ostringstream ostr;
ostr << "Expected " << dims.row << " vector scale factors but got "
<< vectorScaleFactors.size();
throw except::Exception(Ctxt(ostr.str()));
ostr << "Expected " << dims.row << " vector scale factors but got " << vectorScaleFactors.size();
throw except::Exception(Ctxt(ostr));
}

if (dims.row == 0)
Expand All @@ -632,9 +629,8 @@ void Wideband::read(size_t channel,
if (data.size < numPixels)
{
std::ostringstream ostr;
ostr << "Need at least " << numPixels << " pixels but only got "
<< data.size;
throw except::Exception(Ctxt(ostr.str()));
ostr << "Need at least " << numPixels << " pixels but only got " << data.size;
throw except::Exception(Ctxt(ostr));
}

if (needToScale)
Expand All @@ -643,9 +639,8 @@ void Wideband::read(size_t channel,
if (scratch.size < minScratchSize)
{
std::ostringstream ostr;
ostr << "Need at least " << minScratchSize << " bytes but only got "
<< scratch.size;
throw except::Exception(Ctxt(ostr.str()));
ostr << "Need at least " << minScratchSize << " bytes but only got " << scratch.size;
throw except::Exception(Ctxt(ostr));
}

// Perform the read into the scratch buffer
Expand Down
2 changes: 1 addition & 1 deletion six/modules/c++/cphd/tests/test_metadata_round.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ bool testEqual(const std::string& inPathname, const std::string& outPathname,

//Output XML file to temp file
io::FileOutputStream ofs(outPathname);
ofs.write(xmlMetadata.c_str(), xmlMetadata.size());
ofs.write(xmlMetadata);

// Read in second XML file from temp file
xml::lite::MinidomParser xmlParser2;
Expand Down
Loading

0 comments on commit f174846

Please sign in to comment.