mirror of
https://github.com/nlohmann/json.git
synced 2026-11-22 02:44:22 +00:00
Give code outside basic_json the reference tokens of a json_pointer
detail::json_pointer_access returns the reference tokens of a pointer, so that code resolving pointers without a basic_json value (such as the zero-copy view) does not have to parse to_string() again. No change in behavior. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
2 files changed
+42
No files matched your search
@@ -30,6 +30,11 @@
|
|||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
struct json_pointer_access;
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
|
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
|
||||||
/// @sa https://json.nlohmann.me/api/json_pointer/
|
/// @sa https://json.nlohmann.me/api/json_pointer/
|
||||||
template<typename RefStringType>
|
template<typename RefStringType>
|
||||||
@@ -42,6 +47,8 @@ class json_pointer
|
|||||||
template<typename>
|
template<typename>
|
||||||
friend class json_pointer;
|
friend class json_pointer;
|
||||||
|
|
||||||
|
friend struct detail::json_pointer_access;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct string_t_helper
|
struct string_t_helper
|
||||||
{
|
{
|
||||||
@@ -1164,4 +1171,18 @@ inline bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
/// the reference tokens of a json_pointer, for code that resolves pointers
|
||||||
|
/// without a basic_json value (such as the zero-copy view)
|
||||||
|
struct json_pointer_access
|
||||||
|
{
|
||||||
|
template<typename RefStringType>
|
||||||
|
static const std::vector<typename json_pointer<RefStringType>::string_t>& reference_tokens(const json_pointer<RefStringType>& ptr) noexcept
|
||||||
|
{
|
||||||
|
return ptr.reference_tokens;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
@@ -19781,6 +19781,11 @@ NLOHMANN_JSON_NAMESPACE_END
|
|||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
struct json_pointer_access;
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
|
/// @brief JSON Pointer defines a string syntax for identifying a specific value within a JSON document
|
||||||
/// @sa https://json.nlohmann.me/api/json_pointer/
|
/// @sa https://json.nlohmann.me/api/json_pointer/
|
||||||
template<typename RefStringType>
|
template<typename RefStringType>
|
||||||
@@ -19793,6 +19798,8 @@ class json_pointer
|
|||||||
template<typename>
|
template<typename>
|
||||||
friend class json_pointer;
|
friend class json_pointer;
|
||||||
|
|
||||||
|
friend struct detail::json_pointer_access;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
struct string_t_helper
|
struct string_t_helper
|
||||||
{
|
{
|
||||||
@@ -20915,6 +20922,20 @@ inline bool operator<(const json_pointer<RefStringTypeLhs>& lhs,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
/// the reference tokens of a json_pointer, for code that resolves pointers
|
||||||
|
/// without a basic_json value (such as the zero-copy view)
|
||||||
|
struct json_pointer_access
|
||||||
|
{
|
||||||
|
template<typename RefStringType>
|
||||||
|
static const std::vector<typename json_pointer<RefStringType>::string_t>& reference_tokens(const json_pointer<RefStringType>& ptr) noexcept
|
||||||
|
{
|
||||||
|
return ptr.reference_tokens;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
NLOHMANN_JSON_NAMESPACE_END
|
NLOHMANN_JSON_NAMESPACE_END
|
||||||
|
|
||||||
// #include <nlohmann/detail/json_ref.hpp>
|
// #include <nlohmann/detail/json_ref.hpp>
|
||||||
|
|||||||
Reference in new issue
Block a user