Skip to content

Commit

Permalink
Squashed 'externals/nitro/' changes from 0357b1432..0342b596a
Browse files Browse the repository at this point in the history
0342b596a latest from CODA-OSS (#592)
0084f9bf7 reduce use of .str() (#591)
253f57b2b latest from CODA-OSS (#590)
d6bc1d83a disable code-analysis to fix Github builds
981e75116 Update main.yml
907bf91cd Update frequent_check.yml

git-subtree-dir: externals/nitro
git-subtree-split: 0342b596aa3b4e1809086e4676d3e49fd8ccd261
  • Loading branch information
Dan Smith committed Nov 8, 2023
1 parent 0d9d64f commit e8e1c07
Show file tree
Hide file tree
Showing 58 changed files with 8,390 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/frequent_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
cmake --build . --config ${{ matrix.configuration }} -j
cmake --build . --config ${{ matrix.configuration }} --target install
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild
uses: microsoft/setup-msbuild@v1.0.2 # https://github.com/marketplace/actions/setup-msbuild
with:
msbuild-architecture: x64
- name: msbuild
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
cd out
ctest -C ${{ matrix.configuration }} --output-on-failure
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild
uses: microsoft/setup-msbuild@v1.0.2 # https://github.com/marketplace/actions/setup-msbuild
with:
msbuild-architecture: x64
- name: msbuild
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/.github/workflows/build_unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
cmake --build . --config ${{ matrix.configuration }} -j
cmake --build . --config ${{ matrix.configuration }} --target install
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v1 # https://github.com/marketplace/actions/setup-msbuild
uses: microsoft/setup-msbuild@v1.0.2 # https://github.com/marketplace/actions/setup-msbuild
with:
msbuild-architecture: x64
- name: msbuild
Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/cli/source/ArgumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
case cli::SUB_OPTIONS:
{
if (optionsStr.empty())
parseError(str::Format("invalid sub option: [%s]", argVar.c_str()));
parseError(str::Format("invalid sub option: [%s]", argVar));

auto v_ = std::make_unique<cli::Value>();
auto v = currentResults->hasValue(optionsStr) ? currentResults->getValue(optionsStr) : v_.get();
Expand Down Expand Up @@ -706,7 +706,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
}
if (!isValid)
{
parseError(str::Format("invalid option for [%s]", argVar.c_str()));
parseError(str::Format("invalid option for [%s]", argVar));
}
}
}
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void BufferViewStream<T>::write(const void* buffer, size_t numBytes)
{
std::ostringstream msg;
msg << "Write of size " << numBytes << " runs out of bounds.";
throw except::Exception(Ctxt(msg.str()));
throw except::Exception(Ctxt(msg));
}

::memcpy(mBufferView.data + mPosition, buffer, numBytes);
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/io/include/io/FileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inline void move(const std::string& path,
oss << "Move Failed: Could not move source [" <<
path << "] to destination [" <<
newPath << "]";
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
}

Expand Down
5 changes: 2 additions & 3 deletions externals/coda-oss/modules/c++/io/source/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void io::copy(const std::string& path,
oss << "Copy Failed: Could not copy source [" <<
path << "] to destination [" <<
newFile << "]";
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
}
}
Expand All @@ -133,8 +133,7 @@ std::string io::FileUtils::createFile(std::string dirname,
sys::OS os;

if (!os.exists(dirname))
throw except::IOException(Ctxt(str::Format("Directory does not exist: %s",
dirname.c_str())));
throw except::IOException(Ctxt(str::Format("Directory does not exist: %s", dirname)));

str::trim(filename);

Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/io/source/InputStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ sys::SSize_T InputStream::read(void* buffer,
{
std::ostringstream ostr;
ostr << "Tried to read " << len << " bytes but read failed";
throw except::IOException(Ctxt(ostr.str()));
throw except::IOException(Ctxt(ostr));
}
else if (numBytes != static_cast<sys::SSize_T>(len))
{
std::ostringstream ostr;
ostr << "Tried to read " << len << " bytes but only read "
<< numBytes << " bytes";
throw except::IOException(Ctxt(ostr.str()));
throw except::IOException(Ctxt(ostr));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void io::MMapInputStream::open(const std::string& fname, char* flags)
// std::cout << mLength << std::endl;
mFile = fopen(fname.c_str(), "r");
if (!mFile)
throw sys::SystemException(str::Format("Failure while opening file: %s", fname.c_str()));
throw sys::SystemException(str::Format("Failure while opening file: %s", fname));

_map();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ StreamSplitter::StreamSplitter(io::InputStream& inputStream,
std::ostringstream os;
os << "bufferSize must be >= twice the delimiter size + 1 byte. "
<< "Normally it should be much larger for good performance.";
throw except::InvalidArgumentException(Ctxt(os.str()));
throw except::InvalidArgumentException(Ctxt(os));
}
}

Expand Down
6 changes: 3 additions & 3 deletions externals/coda-oss/modules/c++/io/tests/serializeTest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class A : public Serializable
string vec_2 = fillString(is);

assert(classType == "Class A");
dbg.writeln(str::Format("vec[0] = %s", vec_0.c_str()));
dbg.writeln(str::Format("vec[1] = %s", vec_1.c_str()));
dbg.writeln(str::Format("vec[2] = %s", vec_2.c_str()));
dbg.writeln(str::Format("vec[0] = %s", vec_0));
dbg.writeln(str::Format("vec[1] = %s", vec_1));
dbg.writeln(str::Format("vec[2] = %s", vec_2));

vec[0] = str::toType<float>(vec_0);
vec[1] = str::toType<float>(vec_1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct LogLevel final
else if (s == "SEVERE")
value = LOG_CRITICAL;
else
throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %s", s.c_str())));
throw except::InvalidFormatException(Ctxt(str::Format("Invalid enum value: %s", s)));
}

//! int constructor
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ template<typename Vector_T> OneD<double> fit(const Vector_T& x,
<< sizeX << " points for an order-" << order
<< "fit)! You should really have at least (order+1) = "
<< (order+1) << " points for this to do what you expect.";
throw except::Exception(Ctxt(excSS.str()));
throw except::Exception(Ctxt(excSS));
}

// Compute mean value
Expand Down Expand Up @@ -206,7 +206,7 @@ inline math::poly::TwoD<double> fit(const math::linear::Matrix2D<double>& x,
<< x.size() << " points for a " << acols << "-coefficient fit)!"
<< " You should really have at least (orderX+1)*(orderY+1) = "
<< acols << " points for this to do what you expect.";
throw except::Exception(Ctxt(excSS.str()));
throw except::Exception(Ctxt(excSS));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,9 @@ OneD<_T>::operator [] (size_t i)
}
else
{
std::stringstream str;
str << "index: " << i << " not within range [0..."
<< mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str.str()));
std::ostringstream str;
str << "index: " << i << " not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str));
}
}

Expand All @@ -196,9 +195,9 @@ OneD<_T>::operator [] (size_t i) const
}
else
{
std::stringstream str;
std::ostringstream str;
str << "idx(" << i << ") not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str.str()));
throw except::IndexOutOfRangeException(Ctxt(str));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,9 @@ TwoD<_T>::operator [] (size_t i) const
}
else
{
std::stringstream str;
str << "index:" << i << " not within range [0..."
<< mCoef.size() << ")";

throw except::IndexOutOfRangeException(Ctxt(str.str()));
std::ostringstream str;
str << "index:" << i << " not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str));
}
return ret;
}
Expand All @@ -206,10 +204,9 @@ TwoD<_T>::operator [] (size_t i)
}
else
{
std::stringstream str;
str << "index: " << i << " not within range [0..."
<< mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str.str()));
std::ostringstream str;
str << "index: " << i << " not within range [0..." << mCoef.size() << ")";
throw except::IndexOutOfRangeException(Ctxt(str));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct BufferView
oss << "BufferView::section() called with sectionSize: " << sectionSize << " when";
oss << " there were only " << size << " elements in the BufferView";

throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}

BufferView<T> newSection(data, sectionSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ inline void ScratchMemory::put<sys::ubyte>(const std::string& key,
{
std::ostringstream oss;
oss << "Scratch memory space was already reserved for " << key;
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}
mSegments.insert(
iterSeg,
Expand Down
12 changes: 5 additions & 7 deletions externals/coda-oss/modules/c++/mem/source/ScratchMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,25 @@ const ScratchMemory::Segment& ScratchMemory::lookupSegment(
if (mBuffer.data == nullptr)
{
std::ostringstream oss;
oss << "Tried to get scratch memory for \"" << key
<< "\" before running setup.";
throw except::Exception(Ctxt(oss.str()));
oss << "Tried to get scratch memory for \"" << key << "\" before running setup.";
throw except::Exception(Ctxt(oss));
}

std::map<std::string, Segment>::const_iterator iterSeg = mSegments.find(key);
if (iterSeg == mSegments.end())
{
std::ostringstream oss;
oss << "Scratch memory segment was not found for \"" << key << "\"";
throw except::Exception(Ctxt(oss.str()));
throw except::Exception(Ctxt(oss));
}

const Segment& segment = iterSeg->second;
if (indexBuffer >= segment.buffers.size())
{
std::ostringstream oss;
oss << "Trying to get buffer index " << indexBuffer << " for \""
<< key << "\", which has only " << segment.buffers.size()
<< " buffers";
throw except::Exception(Ctxt(oss.str()));
<< key << "\", which has only " << segment.buffers.size() << " buffers";
throw except::Exception(Ctxt(oss));
}
return segment;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void runBalanced1D(size_t numElements,
std::ostringstream ostr;
ostr << "Got " << numThreads << " threads but " << ops.size()
<< " functors";
throw except::Exception(Ctxt(ostr.str()));
throw except::Exception(Ctxt(ostr));
}

if (numThreads <= 1)
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/mt/include/mt/Runnable1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void run1D(size_t numElements, size_t numThreads, const std::vector<OpT>& ops)
std::ostringstream ostr;
ostr << "Got " << numThreads << " threads but " << ops.size()
<< " functors";
throw except::Exception(Ctxt(ostr.str()));
throw except::Exception(Ctxt(ostr));
}

if (numThreads <= 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ void runWorkSharingBalanced1D(size_t numElements,
std::ostringstream ostr;
ostr << "Got " << numThreads << " threads but " << ops.size()
<< " functors";
throw except::Exception(Ctxt(ostr.str()));
throw except::Exception(Ctxt(ostr));
}

std::vector<size_t> threadPoolEndElements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct AvailableCPUProvider final : public AbstractNextCPUProviderLinux
{
std::ostringstream msg;
msg << "No more CPUs available (size = " << mCPUs.size() << ")";
throw except::Exception(Ctxt(msg.str()));
throw except::Exception(Ctxt(msg));
}

std::unique_ptr<sys::ScopedCPUMaskUnix> mask(new sys::ScopedCPUMaskUnix());
Expand Down
Loading

0 comments on commit e8e1c07

Please sign in to comment.