|
JSON Voorhees
Killer JSON for C++
|
An RAII guard naming one step of the extraction path while it is alive. More...
#include <jsonv/serialization/extract.hpp>
Public Member Functions | |
| path_scope (extraction_context &context, std::size_t index) noexcept | |
| path_scope (extraction_context &context, std::string_view key) noexcept | |
| path_scope (extraction_context &context, path_element elem) | |
| path_scope (extraction_context &context, const jsonv::path &subpath) noexcept | |
| Push every element of subpath at once. subpath must outlive the scope. | |
| path_scope (const path_scope &)=delete | |
| path_scope & | operator= (const path_scope &)=delete |
Friends | |
| class | extraction_context |
An RAII guard naming one step of the extraction path while it is alive.
A reader knows where the reader is, which is not always where the extractor 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 extractor 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 extraction_context::path, which happens only when a problem is recorded.
The std::size_t and std::string_view overloads allocate nothing; the key of the latter 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).
Definition at line 574 of file extract.hpp.
|
friend |
Definition at line 590 of file extract.hpp.