From adb4964bc152757b512539399118cbf75cccbd52 Mon Sep 17 00:00:00 2001 From: stephenberry Date: Wed, 12 Jun 2024 16:23:08 +0000 Subject: [PATCH] Committing clang-format changes --- include/glaze/json/json_t.hpp | 50 +++++++++++++++-------------------- tests/json_test/json_test.cpp | 16 +++++------ 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/include/glaze/json/json_t.hpp b/include/glaze/json/json_t.hpp index 1d2c4fbc0e..52f9d2ddda 100644 --- a/include/glaze/json/json_t.hpp +++ b/include/glaze/json/json_t.hpp @@ -166,30 +166,21 @@ namespace glz // Can be used for string_view and the like return get(); } - - [[nodiscard]] bool is_array() const noexcept { - return holds(); - } - - [[nodiscard]] bool is_object() const noexcept { - return holds(); - } - - [[nodiscard]] bool is_number() const noexcept { - return holds(); - } - - [[nodiscard]] bool is_string() const noexcept { - return holds(); - } - - [[nodiscard]] bool is_null() const noexcept { - return holds(); - } - + + [[nodiscard]] bool is_array() const noexcept { return holds(); } + + [[nodiscard]] bool is_object() const noexcept { return holds(); } + + [[nodiscard]] bool is_number() const noexcept { return holds(); } + + [[nodiscard]] bool is_string() const noexcept { return holds(); } + + [[nodiscard]] bool is_null() const noexcept { return holds(); } + // empty() returns true if the value is an empty JSON object, array, or string, or a null value // otherwise returns false - [[nodiscard]] bool empty() const noexcept { + [[nodiscard]] bool empty() const noexcept + { if (auto* v = get_if(); v) { return v->empty(); } @@ -206,9 +197,10 @@ namespace glz return false; } } - + // returns the count of items in an object or an array, or the size of a string, otherwise returns zero - [[nodiscard]] size_t size() const noexcept { + [[nodiscard]] size_t size() const noexcept + { if (auto* v = get_if(); v) { return v->size(); } @@ -223,15 +215,15 @@ namespace glz } } }; - + [[nodiscard]] inline bool is_array(const json_t& value) { return value.is_array(); } - + [[nodiscard]] inline bool is_object(const json_t& value) { return value.is_object(); } - + [[nodiscard]] inline bool is_number(const json_t& value) { return value.is_number(); } - + [[nodiscard]] inline bool is_string(const json_t& value) { return value.is_string(); } - + [[nodiscard]] inline bool is_null(const json_t& value) { return value.is_null(); } } diff --git a/tests/json_test/json_test.cpp b/tests/json_test/json_test.cpp index 58eb3a60fe..8f52821f44 100644 --- a/tests/json_test/json_test.cpp +++ b/tests/json_test/json_test.cpp @@ -3112,7 +3112,7 @@ suite generic_json_tests = [] { expect(not glz::write_json(glz::json_t(*(glz::read_json("{}"))), s)); expect(s == "{}") << s; }; - + "json_t is_object"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, "{}")); @@ -3121,7 +3121,7 @@ suite generic_json_tests = [] { expect(json.empty()); expect(json.size() == 0); }; - + "json_t is_object"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, R"({"age":"22","name":"Noah"})")); @@ -3130,7 +3130,7 @@ suite generic_json_tests = [] { expect(not json.empty()); expect(json.size() == 2); }; - + "json_t is_array"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, "[]")); @@ -3139,7 +3139,7 @@ suite generic_json_tests = [] { expect(json.empty()); expect(json.size() == 0); }; - + "json_t is_array"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, "[1,2,3]")); @@ -3148,7 +3148,7 @@ suite generic_json_tests = [] { expect(not json.empty()); expect(json.size() == 3); }; - + "json_t is_string"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, R"("")")); @@ -3157,7 +3157,7 @@ suite generic_json_tests = [] { expect(json.empty()); expect(json.size() == 0); }; - + "json_t is_string"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, R"("Beautiful beginning")")); @@ -3166,7 +3166,7 @@ suite generic_json_tests = [] { expect(not json.empty()); expect(json.size() == 19); }; - + "json_t is_number"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, "3.882e2")); @@ -3175,7 +3175,7 @@ suite generic_json_tests = [] { expect(not json.empty()); expect(json.size() == 0); }; - + "json_t is_null"_test = [] { glz::json_t json{}; expect(not glz::read_json(json, "null"));