🎨 use Clang-Format

This commit is contained in:
Niels Lohmann
2023-11-29 15:02:51 +01:00
parent 9cca280a4d
commit 311ad0b877
123 changed files with 17740 additions and 15765 deletions
+36 -30
View File
@@ -30,13 +30,19 @@ class alt_string
static constexpr auto npos = static_cast<std::size_t>(-1);
alt_string(const char* str): str_impl(str) {}
alt_string(const char* str, std::size_t count): str_impl(str, count) {}
alt_string(size_t count, char chr): str_impl(count, chr) {}
alt_string(const char* str)
: str_impl(str)
{}
alt_string(const char* str, std::size_t count)
: str_impl(str, count)
{}
alt_string(size_t count, char chr)
: str_impl(count, chr)
{}
alt_string() = default;
template <typename...TParams>
alt_string& append(TParams&& ...params)
template<typename... TParams>
alt_string& append(TParams&&... params)
{
str_impl.append(std::forward<TParams>(params)...);
return *this;
@@ -47,7 +53,7 @@ class alt_string
str_impl.push_back(c);
}
template <typename op_type>
template<typename op_type>
bool operator==(const op_type& op) const
{
return str_impl == op;
@@ -58,7 +64,7 @@ class alt_string
return str_impl == op.str_impl;
}
template <typename op_type>
template<typename op_type>
bool operator!=(const op_type& op) const
{
return str_impl != op;
@@ -74,17 +80,17 @@ class alt_string
return str_impl.size();
}
void resize (std::size_t n)
void resize(std::size_t n)
{
str_impl.resize(n);
}
void resize (std::size_t n, char c)
void resize(std::size_t n, char c)
{
str_impl.resize(n, c);
}
template <typename op_type>
template<typename op_type>
bool operator<(const op_type& op) const noexcept
{
return str_impl < op;
@@ -158,7 +164,7 @@ class alt_string
}
private:
std::string str_impl {};
std::string str_impl{};
friend bool operator<(const char* /*op1*/, const alt_string& /*op2*/) noexcept;
};
@@ -168,16 +174,16 @@ void int_to_string(alt_string& target, std::size_t value)
target = std::to_string(value).c_str();
}
using alt_json = nlohmann::basic_json <
std::map,
std::vector,
alt_string,
bool,
std::int64_t,
std::uint64_t,
double,
std::allocator,
nlohmann::adl_serializer >;
using alt_json = nlohmann::basic_json<
std::map,
std::vector,
alt_string,
bool,
std::int64_t,
std::uint64_t,
double,
std::allocator,
nlohmann::adl_serializer>;
bool operator<(const char* op1, const alt_string& op2) noexcept
{
@@ -225,14 +231,14 @@ TEST_CASE("alternative string type")
{
alt_json doc;
doc["list"] = { 1, 0, 2 };
doc["list"] = {1, 0, 2};
alt_string dump = doc.dump();
CHECK(dump == R"({"list":[1,0,2]})");
}
{
alt_json doc;
doc["object"] = { {"currency", "USD"}, {"value", 42.99} };
doc["object"] = {{"currency", "USD"}, {"value", 42.99}};
alt_string dump = doc.dump();
CHECK(dump == R"({"object":{"currency":"USD","value":42.99}})");
}
@@ -259,11 +265,11 @@ TEST_CASE("alternative string type")
for (const auto& item : doc_array.items())
{
if (item.key() == "0" )
if (item.key() == "0")
{
CHECK( item.value() == "foo" );
CHECK(item.value() == "foo");
}
else if (item.key() == "1" )
else if (item.key() == "1")
{
CHECK(item.value() == "bar");
}
@@ -280,14 +286,14 @@ TEST_CASE("alternative string type")
doc["Who are you?"] = "I'm Batman";
CHECK("I'm Batman" == doc["Who are you?"]);
CHECK(doc["Who are you?"] == "I'm Batman");
CHECK(doc["Who are you?"] == "I'm Batman");
CHECK_FALSE("I'm Batman" != doc["Who are you?"]);
CHECK_FALSE(doc["Who are you?"] != "I'm Batman");
CHECK_FALSE(doc["Who are you?"] != "I'm Batman");
CHECK("I'm Bruce Wayne" != doc["Who are you?"]);
CHECK(doc["Who are you?"] != "I'm Bruce Wayne");
CHECK(doc["Who are you?"] != "I'm Bruce Wayne");
CHECK_FALSE("I'm Bruce Wayne" == doc["Who are you?"]);
CHECK_FALSE(doc["Who are you?"] == "I'm Bruce Wayne");
CHECK_FALSE(doc["Who are you?"] == "I'm Bruce Wayne");
{
const alt_json& const_doc = doc;