Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenberry committed Jun 12, 2024
1 parent 21c62fb commit adb4964
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 37 deletions.
50 changes: 21 additions & 29 deletions include/glaze/json/json_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,30 +166,21 @@ namespace glz
// Can be used for string_view and the like
return get<std::string>();
}

[[nodiscard]] bool is_array() const noexcept {
return holds<json_t::array_t>();
}

[[nodiscard]] bool is_object() const noexcept {
return holds<json_t::object_t>();
}

[[nodiscard]] bool is_number() const noexcept {
return holds<double>();
}

[[nodiscard]] bool is_string() const noexcept {
return holds<std::string>();
}

[[nodiscard]] bool is_null() const noexcept {
return holds<std::nullptr_t>();
}


[[nodiscard]] bool is_array() const noexcept { return holds<json_t::array_t>(); }

[[nodiscard]] bool is_object() const noexcept { return holds<json_t::object_t>(); }

[[nodiscard]] bool is_number() const noexcept { return holds<double>(); }

[[nodiscard]] bool is_string() const noexcept { return holds<std::string>(); }

[[nodiscard]] bool is_null() const noexcept { return holds<std::nullptr_t>(); }

// 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<object_t>(); v) {
return v->empty();
}
Expand All @@ -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<object_t>(); v) {
return v->size();
}
Expand All @@ -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(); }
}

Expand Down
16 changes: 8 additions & 8 deletions tests/json_test/json_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3112,7 +3112,7 @@ suite generic_json_tests = [] {
expect(not glz::write_json(glz::json_t(*(glz::read_json<glz::json_t>("{}"))), s));
expect(s == "{}") << s;
};

"json_t is_object"_test = [] {
glz::json_t json{};
expect(not glz::read_json(json, "{}"));
Expand All @@ -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"})"));
Expand All @@ -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, "[]"));
Expand All @@ -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]"));
Expand All @@ -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"("")"));
Expand All @@ -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")"));
Expand All @@ -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"));
Expand All @@ -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"));
Expand Down

0 comments on commit adb4964

Please sign in to comment.