From 164e0e54d97b445b39436ee337df64b75bbd0f60 Mon Sep 17 00:00:00 2001 From: garethsb-sony Date: Mon, 25 Feb 2019 08:57:12 +0000 Subject: [PATCH] Rename private json_pointer::is_root as public json_pointer::empty for consistency with std::filesystem::path --- include/nlohmann/detail/json_pointer.hpp | 8 ++++---- include/nlohmann/json.hpp | 2 +- single_include/nlohmann/json.hpp | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/nlohmann/detail/json_pointer.hpp b/include/nlohmann/detail/json_pointer.hpp index 8ec4179e..1efb5049 100644 --- a/include/nlohmann/detail/json_pointer.hpp +++ b/include/nlohmann/detail/json_pointer.hpp @@ -149,7 +149,7 @@ class json_pointer */ std::string pop_back() { - if (JSON_UNLIKELY(is_root())) + if (JSON_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -173,16 +173,16 @@ class json_pointer reference_tokens.push_back(std::move(token)); } - private: /// return whether pointer points to the root document - bool is_root() const noexcept + bool empty() const noexcept { return reference_tokens.empty(); } + private: json_pointer top() const { - if (JSON_UNLIKELY(is_root())) + if (JSON_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index d13f8a9e..b10c9f5b 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -7466,7 +7466,7 @@ class basic_json const auto operation_add = [&result](json_pointer & ptr, basic_json val) { // adding to the root of the target document means replacing it - if (ptr.is_root()) + if (ptr.empty()) { result = val; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index dd7236c8..f3688a1c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -11959,7 +11959,7 @@ class json_pointer */ std::string pop_back() { - if (JSON_UNLIKELY(is_root())) + if (JSON_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -11983,16 +11983,16 @@ class json_pointer reference_tokens.push_back(std::move(token)); } - private: /// return whether pointer points to the root document - bool is_root() const noexcept + bool empty() const noexcept { return reference_tokens.empty(); } + private: json_pointer top() const { - if (JSON_UNLIKELY(is_root())) + if (JSON_UNLIKELY(empty())) { JSON_THROW(detail::out_of_range::create(405, "JSON pointer has no parent")); } @@ -20016,7 +20016,7 @@ class basic_json const auto operation_add = [&result](json_pointer & ptr, basic_json val) { // adding to the root of the target document means replacing it - if (ptr.is_root()) + if (ptr.empty()) { result = val; }