|
JSON Voorhees
Killer JSON for C++
|
An RAII guard naming one step of the deserialization path while it is alive. More...
#include <jsonv/serialization/deserialize.hpp>
Public Member Functions | |
| path_scope (deserialization_context &context, std::size_t index) noexcept | |
| Name the element at index of the array being deserialized, on context. | |
| path_scope (deserialization_context &context, std::string_view key) noexcept | |
| Name the member key of the object being deserialized, on context. key is viewed rather than copied. | |
| template<std::size_t N> | |
| path_scope (deserialization_context &context, const char(&key)[N]) noexcept | |
| Name the member key of the object being deserialized, on context. | |
| template<std::size_t N> | |
| path_scope (deserialization_context &context, const char(&&key)[N]) | |
| Name the member key of the object being deserialized, on context, keeping a copy of key for as long as this scope lives. | |
| template<typename TString > requires std::same_as<TString, std::string> | |
| path_scope (deserialization_context &context, const TString &key) noexcept | |
| Name the member key of the object being deserialized, on context. | |
| template<typename TString > requires std::same_as<std::remove_const_t<TString>, std::string> | |
| path_scope (deserialization_context &context, TString &&key) | |
| Name the member key of the object being deserialized, on context, keeping key for as long as this scope lives. | |
| path_scope (deserialization_context &context, path_element elem) | |
| Name elem on context, keeping a copy of it for as long as this scope lives. | |
| path_scope (const path_scope &)=delete | |
| path_scope & | operator= (const path_scope &)=delete |
Friends | |
| class | deserialization_context |
An RAII guard naming one step of the deserialization path while it is alive.
A reader knows where the reader is, which is not always where the deserializer is: an adapter which re-roots onto a subtree gets a reader whose reader::current_path is relative to that subtree, and an adapter which renames a member wants the name the caller declared rather than the one the document used. Pushing a scope says where the deserializer is, and takes precedence over the reader's own answer.
Scopes are kept on the C++ stack and linked into a chain, so a push is two stores and a pop is one. No jsonv::path is built until something calls deserialization_context::path, which happens only when a problem is recorded.
The overloads which view their argument allocate nothing: the std::size_t one, and those naming a key by std::string_view, std::string lvalue or string literal. A key they view must outlive the scope, which is why an owning path_element overload exists for the callers that cannot promise it (a key decoded from an ast_node_type::key_escaped node, for instance). A std::string or char array rvalue, const or not, is owned the same way rather than viewed, since it would be gone before the scope is. A const char* variable is ambiguous between the std::string_view and path_element overloads; spell it std::string_view(key).
Definition at line 755 of file deserialize.hpp.
|
inlinenoexcept |
Name the member key of the object being deserialized, on context.
key is a string literal, or some other array holding a NUL-terminated string, and is viewed rather than copied.
Definition at line 767 of file deserialize.hpp.
|
inline |
Name the member key of the object being deserialized, on context, keeping a copy of key for as long as this scope lives.
key is an array of char holding a NUL-terminated string which is about to be destroyed, such as a member of a temporary.
Definition at line 779 of file deserialize.hpp.
|
inlinenoexcept |
Name the member key of the object being deserialized, on context.
key is a std::string, and is viewed rather than copied.
Definition at line 787 of file deserialize.hpp.
|
inline |
Name the member key of the object being deserialized, on context, keeping key for as long as this scope lives.
key is a std::string rvalue. One which is const, such as one returned as a const std::string, cannot be moved from, so it is copied rather than viewed after it is gone.
Definition at line 799 of file deserialize.hpp.
|
friend |
Definition at line 812 of file deserialize.hpp.