Skip to content

Commit

Permalink
Squashed 'externals/coda-oss/' changes from 5f858856e..a8c5a3b2b
Browse files Browse the repository at this point in the history
a8c5a3b2b Merge branch 'main' into cpp17
00e2dd928 another FmtX() overload
165a799c5 more FmtX() overloads (#729)
8dee6f7a6 revert toString() changes (#728)
bf7ae4a71 use overloads rather than varargs for std::format() (#727)
22e050207 utility routines to reduce duplicated code (#726)
a5ea60647 remove str::EncodedStringView (#725)

git-subtree-dir: externals/coda-oss
git-subtree-split: a8c5a3b2b2c32fc150007e6a6cc20c00e7b32b54
  • Loading branch information
Dan Smith committed Aug 29, 2023
1 parent a38501a commit d12bcf8
Show file tree
Hide file tree
Showing 36 changed files with 733 additions and 1,305 deletions.
2 changes: 0 additions & 2 deletions UnitTest/str.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#include <string>

#include <import/str.h>
#include <str/EncodedString.h>
#include <str/EncodedStringView.h>

namespace str
{
Expand Down
5 changes: 1 addition & 4 deletions modules/c++/cli/include/cli/Value.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ class CODA_OSS_API Value
{
if (index >= mValues.size())
throw except::IndexOutOfRangeException(
Ctxt(
FmtX(
"Invalid index: %d",
index)));
Ctxt(FmtX("Invalid index: %d", index)));
return str::toType<T>(mValues[index]);
}

Expand Down
23 changes: 7 additions & 16 deletions modules/c++/cli/source/ArgumentParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
std::map<std::string, Argument*>& flagMap =
(subOption ? shortOptionsFlags : shortFlags);
if (flagMap.find(op) != flagMap.end())
parseError(FmtX("Conflicting option: %c%s", mPrefixChar,
op.c_str()));
parseError(FmtX("Conflicting option: %c%s", mPrefixChar, op));
flagMap[op] = arg;
}
for (std::vector<std::string>::const_iterator it =
Expand All @@ -328,8 +327,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
std::map<std::string, Argument*>& flagMap =
(subOption ? longOptionsFlags : longFlags);
if (flagMap.find(op) != flagMap.end())
parseError(FmtX("Conflicting option: %c%c%s", mPrefixChar,
mPrefixChar, op.c_str()));
parseError(FmtX("Conflicting option: %c%c%s", mPrefixChar, mPrefixChar, op));
flagMap[op] = arg;
}
}
Expand Down Expand Up @@ -458,8 +456,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
}
else
{
throw except::Exception(Ctxt(
FmtX("Invalid option: [%s]", argStr.c_str())));
throw except::Exception(Ctxt(FmtX("Invalid option: [%s]", argStr)));
}
}
}
Expand Down Expand Up @@ -500,8 +497,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
}
else
{
throw except::Exception(Ctxt(
FmtX("Invalid option: [%s]", argStr.c_str())));
throw except::Exception(Ctxt(FmtX("Invalid option: [%s]", argStr)));
}

}
Expand Down Expand Up @@ -549,10 +545,7 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
}

if (!added)
parseError(
FmtX(
"option requires value or has exceeded its max: [%s]",
argVar.c_str()));
parseError(FmtX("option requires value or has exceeded its max: [%s]", argVar));

currentResults->put(argVar, v);
break;
Expand Down Expand Up @@ -677,11 +670,9 @@ std::unique_ptr<cli::Results> cli::ArgumentParser::parse(const std::string& prog
if (arg->isRequired() || numGiven > 0)
{
if (minArgs > 0 && numGiven < static_cast<size_t>(minArgs))
parseError(FmtX("not enough arguments, %d required: [%s]",
minArgs, argId.c_str()));
parseError(FmtX("not enough arguments, %d required: [%s]", minArgs, argId));
if (maxArgs >= 0 && numGiven > static_cast<size_t>(maxArgs))
parseError(FmtX("too many arguments, %d supported: [%s]",
maxArgs, argId.c_str()));
parseError(FmtX("too many arguments, %d supported: [%s]", maxArgs, argId));
}


Expand Down
5 changes: 1 addition & 4 deletions modules/c++/coda-oss.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,12 @@
<ClInclude Include="sio.lite\include\sio\lite\UserDataDictionary.h" />
<ClInclude Include="std\include\import\std.h" />
<ClInclude Include="str\include\str\Convert.h" />
<ClInclude Include="str\include\str\EncodedString.h" />
<ClInclude Include="str\include\str\EncodedStringView.h" />
<ClInclude Include="str\include\str\Encoding.h" />
<ClInclude Include="str\include\str\Format.h" />
<ClInclude Include="str\include\str\Manip.h" />
<ClInclude Include="str\include\str\Tokenizer.h" />
<ClInclude Include="str\include\str\utf8.h" />
<ClInclude Include="str\include\str\W1252string.h" />
<ClInclude Include="sys\include\sys\AbstractOS.h" />
<ClInclude Include="sys\include\sys\AtomicCounter.h" />
<ClInclude Include="sys\include\sys\AtomicCounterCpp11.h" />
Expand Down Expand Up @@ -422,8 +421,6 @@
<ClCompile Include="sio.lite\source\SioFileWriter.cpp" />
<ClCompile Include="sio.lite\source\StreamReader.cpp" />
<ClCompile Include="str\source\Convert.cpp" />
<ClCompile Include="str\source\EncodedString.cpp" />
<ClCompile Include="str\source\EncodedStringView.cpp" />
<ClCompile Include="str\source\Encoding.cpp" />
<ClCompile Include="str\source\Format.cpp" />
<ClCompile Include="str\source\Manip.cpp" />
Expand Down
21 changes: 6 additions & 15 deletions modules/c++/coda-oss.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@
<ClInclude Include="str\include\str\Convert.h">
<Filter>str</Filter>
</ClInclude>
<ClInclude Include="str\include\str\EncodedString.h">
<Filter>str</Filter>
</ClInclude>
<ClInclude Include="str\include\str\EncodedStringView.h">
<Filter>str</Filter>
</ClInclude>
<ClInclude Include="str\include\str\Encoding.h">
<Filter>str</Filter>
</ClInclude>
Expand Down Expand Up @@ -951,6 +945,9 @@
<ClInclude Include="mem\include\mem\AutoPtr.h">
<Filter>mem</Filter>
</ClInclude>
<ClInclude Include="str\include\str\W1252string.h">
<Filter>str</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
Expand All @@ -969,12 +966,6 @@
<ClCompile Include="str\source\Convert.cpp">
<Filter>str</Filter>
</ClCompile>
<ClCompile Include="str\source\EncodedString.cpp">
<Filter>str</Filter>
</ClCompile>
<ClCompile Include="str\source\EncodedStringView.cpp">
<Filter>str</Filter>
</ClCompile>
<ClCompile Include="str\source\Encoding.cpp">
<Filter>str</Filter>
</ClCompile>
Expand Down Expand Up @@ -1412,9 +1403,6 @@
<Filter Include="gsl">
<UniqueIdentifier>{619ad1da-f21c-4027-9b5d-23f08225b96f}</UniqueIdentifier>
</Filter>
<Filter Include="coda_oss">
<UniqueIdentifier>{59f3d9a1-06d3-4779-aef2-cc55223c3017}</UniqueIdentifier>
</Filter>
<Filter Include="std">
<UniqueIdentifier>{3051f4b6-dad4-47ea-b4bd-d25d9e09f782}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -1499,6 +1487,9 @@
<Filter Include="unique">
<UniqueIdentifier>{79aa73a7-ed0d-4826-b7ed-c8d91d96998a}</UniqueIdentifier>
</Filter>
<Filter Include="coda_oss">
<UniqueIdentifier>{59f3d9a1-06d3-4779-aef2-cc55223c3017}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="gsl\include\gsl\algorithm">
Expand Down
3 changes: 1 addition & 2 deletions modules/c++/include/UnitTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <string>

#include "TestCase.h"
#include "str/EncodedStringView.h"

#if !_MSC_VER
#error "This file is for use with a Visual Studio 'UnitTest' project."
Expand Down Expand Up @@ -133,7 +132,7 @@ inline void assert_almost_eq(const std::string& testName, long double X1, long d
#define TEST_ASSERT_EQ_MSG(msg, X1, X2) testName, Microsoft::VisualStudio::CppUnitTestFramework::Logger::WriteMessage(msg.c_str()); TEST_ASSERT_EQ(X1, X2)

#undef TEST_FAIL_MSG
#define TEST_FAIL_MSG(msg) { (void)testName; Microsoft::VisualStudio::CppUnitTestFramework::Assert::Fail(str::EncodedStringView(msg).wstring().c_str()); }
#define TEST_FAIL_MSG(msg) { (void)testName; Microsoft::VisualStudio::CppUnitTestFramework::Assert::Fail(str::toWString(msg).c_str()); }

#undef TEST_EXCEPTION
#undef TEST_THROWS
Expand Down
14 changes: 7 additions & 7 deletions modules/c++/mem/unittests/test_unique_ptr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ TEST_CASE(testStdUniquePtr)
TEST_ASSERT_NULL(fooCtor.get());

fooCtor.reset(new Foo(123));
TEST_ASSERT_NOT_EQ(nullptr, fooCtor.get());
TEST_ASSERT_NOT_NULL(fooCtor.get());
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto fooCtor = std::make_unique<Foo>(123);
TEST_ASSERT_NOT_EQ(nullptr, fooCtor.get());
TEST_ASSERT_NOT_NULL(fooCtor.get());
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto pFoos = std::make_unique<Foo[]>(123); // 123 instances of Foo
TEST_ASSERT_NOT_EQ(nullptr, pFoos.get());
TEST_ASSERT_NOT_NULL(pFoos.get());
TEST_ASSERT_EQ(0, pFoos[0].mVal);
TEST_ASSERT_EQ(0, pFoos[122].mVal);
}
Expand All @@ -65,24 +65,24 @@ TEST_CASE(test_make_unique)
{
{
auto fooCtor = std::make_unique<Foo>(123);
TEST_ASSERT_NOT_EQ(nullptr, fooCtor.get());
TEST_ASSERT_NOT_NULL(fooCtor.get());
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto pFoos = std::make_unique<Foo[]>(123); // 123 instances of Foo
TEST_ASSERT_NOT_EQ(nullptr, pFoos.get());
TEST_ASSERT_NOT_NULL(pFoos.get());
TEST_ASSERT_EQ(0, pFoos[0].mVal);
TEST_ASSERT_EQ(0, pFoos[122].mVal);
}

{
auto fooCtor = std::make_unique<Foo>(123);
TEST_ASSERT_NOT_EQ(nullptr, fooCtor.get());
TEST_ASSERT_NOT_NULL(fooCtor.get());
TEST_ASSERT_EQ(123, fooCtor->mVal);
}
{
auto pFoos = std::make_unique<Foo[]>(123); // 123 instances of Foo
TEST_ASSERT_NOT_EQ(nullptr, pFoos.get());
TEST_ASSERT_NOT_NULL(pFoos.get());
TEST_ASSERT_EQ(0, pFoos[0].mVal);
TEST_ASSERT_EQ(0, pFoos[122].mVal);
}
Expand Down
7 changes: 7 additions & 0 deletions modules/c++/net/include/net/URL.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ class URL
std::string mFragment;

};

inline std::ostream& operator<<(std::ostream& os, const URL& url)
{
os << url.toString();
return os;
}

}
#endif

4 changes: 2 additions & 2 deletions modules/c++/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ CODA_OSS_disable_warning_pop
// change we want to rebuild everything anyway.
#include "gsl/gsl.h"
#include "config/Exports.h"
#include "mem/SharedPtr.h"
#include "sys/filesystem.h"
#include "except/Throwable.h"
#include "sys/Conf.h"
#include "sys/filesystem.h"
#include "mem/SharedPtr.h"

#include "xml/lite/xerces_.h"
#pragma comment(lib, "xerces-c")
Expand Down
2 changes: 1 addition & 1 deletion modules/c++/plugin/include/plugin/BasicPluginManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ template<typename T> class BasicPluginManager
for (unsigned int i = 0; ops[i] != nullptr; i++)
oss << ops[i] << ":";
eh->onPluginVersionUnsupported(
FmtX("For plugin supporting ops %s version [%d.%d] not supported (%d.%d)",
str::Format("For plugin supporting ops %s version [%d.%d] not supported (%d.%d)",
oss.str().c_str(), majorVersion, minorVersion,
mMajorVersion, mMinorVersion
)
Expand Down
Loading

0 comments on commit d12bcf8

Please sign in to comment.