Skip to content

Commit

Permalink
Merge branch 'main' into develop/remove-compiler-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Nov 15, 2023
2 parents bcc5f9e + b97c4a8 commit d1e1405
Show file tree
Hide file tree
Showing 272 changed files with 7,619 additions and 4,528 deletions.
5 changes: 4 additions & 1 deletion UnitTest/UnitTest.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#include "pch.h"
#include "CppUnitTest.h"

#include <nitf/PluginRegistry.h>
#include <nitf/UnitTests.hpp>

// https://learn.microsoft.com/en-us/visualstudio/test/microsoft-visualstudio-testtools-cppunittestframework-api-reference?view=vs-2022
TEST_MODULE_INITIALIZE(methodName)
{
nitf_PluginRegistry_PreloadedTREHandlersEnable(NRT_TRUE);

// module initialization code
nitf::Test::setNitfPluginPath();
nitf::Test::j2kSetNitfPluginPath();
}
33 changes: 0 additions & 33 deletions UnitTest/UnitTest.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -258,39 +258,6 @@
<ProjectReference Include="..\modules\c\nitf-c.vcxproj">
<Project>{f06550ad-cfc7-40b8-8727-6c82c69a8982}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\ACCHZB.vcxproj">
<Project>{53f9f908-c678-4dee-9309-e71c1d03a45f}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\ACCPOB.vcxproj">
<Project>{730b1e6e-2469-4f9e-b093-d0c6262453c9}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\ACFTA.vcxproj">
<Project>{51d7b426-899e-428d-9f69-5ddac9e403fb}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\AIMIDB.vcxproj">
<Project>{12aa0752-4ee3-4e0a-85af-0e5deadbf343}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\CSCRNA.vcxproj">
<Project>{023de06d-3967-4406-b1b8-032118bb2552}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\CSEXRB.vcxproj">
<Project>{0a9bda26-092f-4a2c-bbef-00c64bf0c65e}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\ENGRDA.vcxproj">
<Project>{53f9f908-c678-4dee-9309-e71c1e03a45f}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\HISTOA.vcxproj">
<Project>{d749aa73-4c9a-473d-96bb-070a6d9caa54}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\JITCID.vcxproj">
<Project>{d1d7fcd3-6130-4504-9da0-9d80506be55e}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\PTPRAA.vcxproj">
<Project>{2baaaca9-a5a4-412c-ae52-b16c2d107f55}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\RPFHDR.vcxproj">
<Project>{cf5b4f02-364d-4117-9fb9-6c9c7938e412}</Project>
</ProjectReference>
<ProjectReference Include="..\modules\c\nitf\XML_DATA_CONTENT.vcxproj">
<Project>{78849481-d356-4cc7-b182-31c21f857ed1}</Project>
</ProjectReference>
Expand Down
2 changes: 1 addition & 1 deletion UnitTest/nitf-c++.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include <import/nitf.hpp>
#include <nitf/UnitTests.hpp>
#include <nitf/TREField.hpp>
#include <nitf/TREsTyped.hpp>
#include <nitf/TestingTest.hpp>
#include <nitf/J2KReader.hpp>
#include <nitf/J2KWriter.hpp>
Expand Down
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
Loading

0 comments on commit d1e1405

Please sign in to comment.