Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest from CODA-OSS #596

Merged
merged 19 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions externals/coda-oss/ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# coda-oss Release Notes

## [Release 202?-??-??](https://github.com/mdaus/coda-oss/releases/tag/202?-??-??)
* Update to [HighFive 2.8.0](https://github.com/BlueBrain/HighFive/releases/tag/v2.8.0).

## [Release 2023-10-23](https://github.com/mdaus/coda-oss/releases/tag/2023-10-23)
* Tweaked **.gitattributes**.
* Removed *str::EncodedStringView*; made *str* conversion routines more consistent.
Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/cli/unittests/test_cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ TEST_CASE(testValue)
for(int i = 0; i < 10; ++i)
{
floats.push_back(10.0f * i);
strings.push_back(str::toString(i));
strings.push_back(std::to_string(i));
}

// floats
Expand All @@ -60,7 +60,7 @@ TEST_CASE(testValue)
v.setContainer(strings);
for(int i = 0; i < 10; ++i)
{
TEST_ASSERT_EQ(v.at<std::string>(i), str::toString(i));
TEST_ASSERT_EQ(v.at<std::string>(i), std::to_string(i));
}
TEST_ASSERT_EQ(std::ssize(v), 10);
}
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/io/source/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ std::string io::FileUtils::createFile(std::string dirname,
int count = 0;
while (os.exists(outFilename))
{
std::string base = filename + "-" + str::toString(++count);
std::string base = filename + "-" + std::to_string(++count);
outFilename = sys::Path::joinPaths(dirname, base);
if (!ext.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions externals/coda-oss/modules/c++/io/unittests/test_streams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ TEST_CASE(testRotate)

for(size_t i = 0; i < maxFiles - 1; ++i)
{
std::string fname = outFile + "." + str::toString(i + 1);
std::string next = outFile + "." + str::toString(i + 2);
std::string fname = outFile + "." + std::to_string(i + 1);
std::string next = outFile + "." + std::to_string(i + 2);

TEST_ASSERT(os.isFile(fname));
TEST_ASSERT_FALSE(os.isFile(next));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,14 @@ void StandardFormatter::format(const LogRecord* record, io::OutputStream& os) co
// populate log
long threadId = sys::getThreadID();
std::string format = mFmt;
str::replace(format, THREAD_ID, str::toString(threadId));
str::replace(format, THREAD_ID, std::to_string(threadId));
str::replace(format, LOG_NAME, name);
str::replace(format, LOG_LEVEL, record->getLevelName());
str::replace(format, TIMESTAMP, record->getTimeStamp());
if (record->getLineNum() >= 0)
{
str::replace(format, FILE_NAME, record->getFile());
str::replace(format, LINE_NUM,
str::toString(record->getLineNum()));
str::replace(format, LINE_NUM, std::to_string(record->getLineNum()));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ void logging::XMLFormatter::format(const logging::LogRecord* record, io::OutputS
// conver record
std::string name = (record->getName().empty()) ?
("DEFAULT") : record->getName();
std::string line = str::toString(record->getLineNum());
std::string threadID = str::toString(sys::getThreadID());
const auto line = std::to_string(record->getLineNum());
const auto threadID = std::to_string(sys::getThreadID());

// populate vector with record
std::vector<std::string> logRecord;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ class Eigenvalue
if (A.rows() != A.cols())
{
throw except::Exception(Ctxt(
"Expected square matrix but got rows = " +
str::toString(A.rows()) + ", cols = " +
str::toString(A.cols())));
"Expected square matrix but got rows = " + std::to_string(A.rows()) + ", cols = " + std::to_string(A.cols())));
}

if (isSymmetric(A))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,10 @@ class TwoD
void set(size_t i, const OneD<_T>& p)
{
if (i > orderX())
throw except::Exception(
Ctxt("Index [" + str::toString(i) +
"] is out of bounds for orderX [" +
str::toString(orderX()) + "]"));
throw except::Exception(Ctxt("Index [" + std::to_string(i) + "] is out of bounds for orderX [" + std::to_string(orderX()) + "]"));
else if (p.order() != orderY())
throw except::Exception(
Ctxt("OneD poly [" + str::toString(p.order()) +
"] is of the incorrect size for orderY [" +
str::toString(orderY()) + "]"));
Ctxt("OneD poly [" + std::to_string(p.order()) + "] is of the incorrect size for orderY [" + std::to_string(orderY()) + "]"));
else
mCoef[i] = p;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ class ConvexHull
{
throw except::Exception(Ctxt(
"ConvexHull constructor error: must use at least 2 input "
"points but " + str::toString(rawPoints.size()) +
" were used"));
"points but " + std::to_string(rawPoints.size()) + " were used"));
}

// Enforce (at compile time) that T is a signed type
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/math/source/Utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ sys::Uint64_T nChooseK(size_t n, size_t k)
if (n < k)
{
throw except::Exception(Ctxt("n Choose k undefined for n < k.\n"
"n: " + str::toString(n) + " k: " + str::toString(k)));
"n: " + std::to_string(n) + " k: " + std::to_string(k)));
}

// Algorithm to compute n Choose k without using factorials found here:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ template <typename Request_T> class WorkerThread : public sys::Thread
*/
std::string getThreadId()
{
return str::toString(sys::getThreadID());
return std::to_string(sys::getThreadID());
}
protected:

Expand Down
4 changes: 1 addition & 3 deletions externals/coda-oss/modules/c++/net/source/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ size_t net::Socket::recv(void* b, size_t len, int flags)

sys::Err err;
std::ostringstream oss;
oss << "When receiving " << str::toString(len) << " bytes: " <<
err.toString();

oss << "When receiving " << len << " bytes: " << err.toString();
throw sys::SocketException(Ctxt(oss));
}
else if (numBytes == 0)
Expand Down
44 changes: 43 additions & 1 deletion externals/coda-oss/modules/c++/str/include/str/Convert.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,56 @@ template <typename T> int getPrecision(const types::ComplexInteger<T>&);
// Note that std::to_string() doesn't necessarily generate the same output as writing
// to std::cout; see https://en.cppreference.com/w/cpp/string/basic_string/to_string
template <typename T>
std::string toString(const T& value)
std::string toString_(const T& value)
{
std::ostringstream buf;
buf.precision(getPrecision(value));
buf << std::boolalpha << value;
return buf.str();
}
template <typename T>
inline auto toString(const T& value)
{
return toString_(value);
}

// https://en.cppreference.com/w/cpp/string/basic_string/to_string
inline auto toString(int value)
{
return toString_(value);
}
inline auto toString(long value)
{
return toString_(value);
}
inline auto toString(long long value)
{
return toString_(value);
}
inline auto toString(unsigned value)
{
return toString_(value);
}
inline auto toString(unsigned long value)
{
return toString_(value);
}
inline auto toString(unsigned long long value)
{
return toString_(value);
}
inline auto toString(float value)
{
return toString_(value);
}
inline auto toString(double value)
{
return toString_(value);
}
inline auto toString(long double value)
{
return toString_(value);
}
inline std::string toString(uint8_t value)
{
return toString(gsl::narrow<unsigned int>(value));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ TEST_CASE(testBadConvert)

TEST_CASE(testEightBitIntToString)
{
TEST_ASSERT_EQ(str::toString(static_cast<uint8_t>(1)), "1");
TEST_ASSERT_EQ(str::toString(static_cast<int8_t>(2)), "2");
TEST_ASSERT_EQ(str::toString(static_cast<int8_t>(-2)), "-2");
TEST_ASSERT_EQ(std::to_string(static_cast<uint8_t>(1)), "1");
TEST_ASSERT_EQ(std::to_string(static_cast<int8_t>(2)), "2");
TEST_ASSERT_EQ(std::to_string(static_cast<int8_t>(-2)), "-2");
}

TEST_CASE(testCharToString)
Expand Down
4 changes: 1 addition & 3 deletions externals/coda-oss/modules/c++/sys/include/sys/Conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ namespace sys
#error "Don't know how to implement alignedAlloc()."
#endif
if (!p)
throw except::Exception(Ctxt(
"Aligned allocation failure of size [" +
str::toString(size) + "] bytes"));
throw except::Exception(Ctxt("Aligned allocation failure of size [" + std::to_string(size) + "] bytes"));
return p;
}

Expand Down
6 changes: 3 additions & 3 deletions externals/coda-oss/modules/c++/sys/source/AbstractOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ static std::string getSpecialEnv_PID(const AbstractOS& os, const std::string& en
UNREFERENCED_PARAMETER(envVar);
#endif
const auto pid = os.getProcessId();
return str::toString(pid);
return std::to_string(pid);
}

static std::string getSpecialEnv_USER(const AbstractOS& os, const std::string& envVar)
Expand Down Expand Up @@ -394,7 +394,7 @@ static std::string getSpecialEnv_SECONDS_()
// https://en.cppreference.com/w/cpp/chrono/c/difftime
static const auto start = std::time(nullptr);
const auto diff = static_cast<int64_t>(std::difftime(std::time(nullptr), start));
return str::toString(diff);
return std::to_string(diff);
}
static std::string getSpecialEnv_SECONDS(const AbstractOS&, const std::string& envVar)
{
Expand Down Expand Up @@ -475,7 +475,7 @@ std::string AbstractOS::getSpecialEnv(const std::string& envVar) const

if (envVar == "EPOCHSECONDS")
{
return str::toString(sys::DateTime::getEpochSeconds());
return std::to_string(sys::DateTime::getEpochSeconds());
}

if (envVar == "OSTYPE")
Expand Down
6 changes: 2 additions & 4 deletions externals/coda-oss/modules/c++/sys/source/DateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ char* strptime(const char *buf, const char *fmt, struct tm& tm, double& millis)
{
bc = *bp++;
if (bc != fc)
throw except::Exception(Ctxt(
"Value does not match format (" + str::toString(fc) +
"): " + str::toString(bc)));
throw except::Exception(Ctxt("Value does not match format (" + str::toString(fc) + "): " + str::toString(bc)));
continue;
}

Expand Down Expand Up @@ -316,7 +314,7 @@ char* strptime(const char *buf, const char *fmt, struct tm& tm, double& millis)
case 'Y': // The year.
i = TM_YEAR_BASE;
if (!(conv_num(bp, i, 0, 9999)))
throw except::Exception(Ctxt("Invalid year: " + str::toString(i)));
throw except::Exception(Ctxt("Invalid year: " + std::to_string(i)));
tm.tm_year = i - TM_YEAR_BASE;
break;

Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/sys/source/FileWin32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ sys::Off_T sys::File::seekTo(sys::Off_T offset, int whence)
if (SetFilePointerEx(mHandle, largeInt, &newFilePointer, dwMoveMethod) == 0)
{
const auto dwLastError = GetLastError();
throw sys::SystemException(Ctxt("SetFilePointer failed: GetLastError() = " + str::toString(dwLastError)));
throw sys::SystemException(Ctxt("SetFilePointer failed: GetLastError() = " + std::to_string(dwLastError)));
}

return static_cast<sys::Off_T>(newFilePointer.QuadPart);
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/sys/unittests/test_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ TEST_CASE(testSpecialEnvVars)
result = os.getSpecialEnv("$"); // i.e., ${$}
TEST_ASSERT_FALSE(result.empty());
TEST_ASSERT_EQ(result, pid);
const auto strPid = str::toString(os.getProcessId());
const auto strPid = std::to_string(os.getProcessId());
TEST_ASSERT_EQ(result, strPid);

result = os.getSpecialEnv("PWD");
Expand Down
8 changes: 3 additions & 5 deletions externals/coda-oss/modules/c++/tiff/source/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ tiff::IFD* tiff::Utils::createGeoTiffIFD(tiff::IFD* ifd)
if (idx + 3 >= geoVals.size())
{
throw except::Exception(Ctxt(
"'GeoKeyDirectoryTag' specified " +
str::toString(numKeys) + " keys but the IFD entry only had " +
str::toString(geoVals.size()) + " values"));
"'GeoKeyDirectoryTag' specified " +
std::to_string(numKeys) + " keys but the IFD entry only had " + std::to_string(geoVals.size()) + " values"));
}

const unsigned short keyId =
Expand Down Expand Up @@ -143,8 +142,7 @@ tiff::IFD* tiff::Utils::createGeoTiffIFD(tiff::IFD* ifd)
{
if (count != 1)
{
throw except::Exception(Ctxt(
"Expected a count of 1 but got " + str::toString(count)));
throw except::Exception(Ctxt("Expected a count of 1 but got " + std::to_string(count)));
}

entry->addValue(new tiff::GenericType<unsigned short>(valueStr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct ValidationInfo final
std::ostringstream oss;
oss << "[" << this->getLevel() << "]" <<
" from File: " << this->getFile() <<
" on Line: " << str::toString(this->getLine()) <<
" on Line: " << this->getLine() <<
" with Message: " << this->getMessage();
return oss.str();
}
Expand Down
2 changes: 1 addition & 1 deletion externals/coda-oss/modules/c++/xml.lite/source/Element.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ std::tuple<xml::lite::Element*, std::string> getElement(TGetElements getElements
{
return std::make_tuple(elements[0], "");
}
return std::make_tuple(nullptr, str::toString(elements.size()));
return std::make_tuple(nullptr, std::to_string(elements.size()));
}
template <typename TGetElements, typename TMakeContext>
xml::lite::Element& getElement(TGetElements getElements, TMakeContext makeContext)
Expand Down

This file was deleted.

Loading