|
rapidyaml
0.9.0
parse and emit YAML, and do it fast
|
This is the main driver of parsing logic: it scans the YAML or JSON source for tokens, and emits the appropriate sequence of parsing events to its event handler. More...
#include <parse_engine.hpp>
Public Types | |
| using | handler_type = EventHandler |
Public Member Functions | |
construction and assignment | |
| ParseEngine (EventHandler *evt_handler, ParserOptions opts={}) | |
| ~ParseEngine () | |
| ParseEngine (ParseEngine &&) noexcept | |
| ParseEngine (ParseEngine const &) | |
| ParseEngine & | operator= (ParseEngine &&) noexcept |
| ParseEngine & | operator= (ParseEngine const &) |
modifiers | |
| void | reserve_stack (id_type capacity) |
| Reserve a certain capacity for the parsing stack. More... | |
| void | reserve_locations (size_t num_source_lines) |
| Reserve a certain capacity for the array used to track node locations in the source buffer. More... | |
| void | reserve_filter_arena (size_t) |
getters | |
| ParserOptions const & | options () const |
| Get the options used to build this parser object. More... | |
| Callbacks const & | callbacks () const |
| Get the current callbacks in the parser. More... | |
| csubstr | filename () const |
| Get the name of the latest file parsed by this object. More... | |
| csubstr | source () const |
| Get the latest YAML buffer parsed by this object. More... | |
| Encoding_e | encoding () const |
| Get the encoding of the latest YAML buffer parsed by this object. More... | |
| id_type | stack_capacity () const |
| size_t | locations_capacity () const |
| size_t | filter_arena_capacity () const |
parse methods | |
| void | parse_in_place_ev (csubstr filename, substr src) |
| parse YAML in place, emitting events to the current handler More... | |
| void | parse_json_in_place_ev (csubstr filename, substr src) |
| parse JSON in place, emitting events to the current handler More... | |
locations | |
| Location | location (Tree const &tree, id_type node_id) const |
| Get the location of a node of the last tree to be parsed by this parser. More... | |
| Location | location (ConstNodeRef node) const |
| Get the location of a node of the last tree to be parsed by this parser. More... | |
| csubstr | location_contents (Location const &loc) const |
| Get the string starting at a particular location, to the end of the parsed source buffer. More... | |
| Location | val_location (const char *val) const |
| Given a pointer to a buffer position, get the location. More... | |
scalar filtering | |
| FilterResult | filter_scalar_plain (csubstr scalar, substr dst, size_t indentation) |
| filter a plain scalar More... | |
| FilterResult | filter_scalar_plain_in_place (substr scalar, size_t cap, size_t indentation) |
| filter a plain scalar in place More... | |
| FilterResult | filter_scalar_squoted (csubstr scalar, substr dst) |
| filter a single-quoted scalar More... | |
| FilterResult | filter_scalar_squoted_in_place (substr scalar, size_t cap) |
| filter a single-quoted scalar in place More... | |
| FilterResult | filter_scalar_dquoted (csubstr scalar, substr dst) |
| filter a double-quoted scalar More... | |
| FilterResultExtending | filter_scalar_dquoted_in_place (substr scalar, size_t cap) |
| filter a double-quoted scalar in place More... | |
| FilterResult | filter_scalar_block_literal (csubstr scalar, substr dst, size_t indentation, BlockChomp_e chomp) |
| filter a block-literal scalar More... | |
| FilterResult | filter_scalar_block_literal_in_place (substr scalar, size_t cap, size_t indentation, BlockChomp_e chomp) |
| filter a block-literal scalar in place More... | |
| FilterResult | filter_scalar_block_folded (csubstr scalar, substr dst, size_t indentation, BlockChomp_e chomp) |
| filter a block-folded scalar More... | |
| FilterResult | filter_scalar_block_folded_in_place (substr scalar, size_t cap, size_t indentation, BlockChomp_e chomp) |
| filter a block-folded scalar in place More... | |
This is the main driver of parsing logic: it scans the YAML or JSON source for tokens, and emits the appropriate sequence of parsing events to its event handler.
The parse engine itself has no special limitations, and can accomodate containers as keys; it is the event handler may introduce additional constraints.
There are two implemented handlers (see Event Handlers, which has important notes about the event model):
Definition at line 292 of file parse_engine.hpp.
| using c4::yml::ParseEngine< EventHandler >::handler_type = EventHandler |
Definition at line 296 of file parse_engine.hpp.
| c4::yml::ParseEngine< EventHandler >::ParseEngine | ( | EventHandler * | evt_handler, |
| ParserOptions | opts = {} |
||
| ) |
Definition at line 257 of file parse_engine.def.hpp.
| c4::yml::ParseEngine< EventHandler >::~ParseEngine |
Definition at line 250 of file parse_engine.def.hpp.
|
noexcept |
Definition at line 277 of file parse_engine.def.hpp.
| c4::yml::ParseEngine< EventHandler >::ParseEngine | ( | ParseEngine< EventHandler > const & | that | ) |
Definition at line 297 of file parse_engine.def.hpp.
|
noexcept |
Definition at line 323 of file parse_engine.def.hpp.
| ParseEngine< EventHandler > & c4::yml::ParseEngine< EventHandler >::operator= | ( | ParseEngine< EventHandler > const & | that | ) |
Definition at line 345 of file parse_engine.def.hpp.
|
inline |
Reserve a certain capacity for the parsing stack.
This should be larger than the expected depth of the parsed YAML tree.
The parsing stack is the only (potential) heap memory used directly by the parser.
If the requested capacity is below the default stack size of 16, the memory is used directly in the parser object; otherwise it will be allocated from the heap.
Definition at line 335 of file parse_engine.hpp.
Referenced by sample::sample_global_allocator(), sample::sample_parse_reuse_parser(), and sample::sample_parse_reuse_tree_and_parser().
|
inline |
Reserve a certain capacity for the array used to track node locations in the source buffer.
Definition at line 342 of file parse_engine.hpp.
Referenced by sample::sample_location_tracking().
|
inline |
Definition at line 348 of file parse_engine.hpp.
|
inline |
Get the options used to build this parser object.
Definition at line 358 of file parse_engine.hpp.
Referenced by sample::sample_location_tracking().
|
inline |
Get the current callbacks in the parser.
Definition at line 361 of file parse_engine.hpp.
Referenced by c4::yml::parse_in_arena(), c4::yml::parse_in_place(), c4::yml::parse_json_in_arena(), and c4::yml::parse_json_in_place().
|
inline |
Get the name of the latest file parsed by this object.
Definition at line 364 of file parse_engine.hpp.
|
inline |
Get the latest YAML buffer parsed by this object.
Definition at line 367 of file parse_engine.hpp.
|
inline |
Get the encoding of the latest YAML buffer parsed by this object.
If no encoding was specified, UTF8 is assumed as per the YAML standard.
Definition at line 371 of file parse_engine.hpp.
References c4::yml::NOBOM, and c4::yml::UTF8.
|
inline |
Definition at line 373 of file parse_engine.hpp.
|
inline |
Definition at line 374 of file parse_engine.hpp.
|
inline |
Definition at line 377 of file parse_engine.hpp.
| void c4::yml::ParseEngine< EventHandler >::parse_in_place_ev | ( | csubstr | filename, |
| substr | src | ||
| ) |
parse YAML in place, emitting events to the current handler
Referenced by c4::yml::parse_in_place().
| void c4::yml::ParseEngine< EventHandler >::parse_json_in_place_ev | ( | csubstr | filename, |
| substr | src | ||
| ) |
parse JSON in place, emitting events to the current handler
Referenced by c4::yml::parse_json_in_place().
| Location c4::yml::ParseEngine< EventHandler >::location | ( | Tree const & | tree, |
| id_type | node_id | ||
| ) | const |
Get the location of a node of the last tree to be parsed by this parser.
Referenced by sample::sample_location_tracking(), and sample::sample_quick_overview().
| Location c4::yml::ParseEngine< EventHandler >::location | ( | ConstNodeRef | node | ) | const |
Get the location of a node of the last tree to be parsed by this parser.
| csubstr c4::yml::ParseEngine< EventHandler >::location_contents | ( | Location const & | loc | ) | const |
Get the string starting at a particular location, to the end of the parsed source buffer.
Referenced by sample::sample_location_tracking(), and sample::sample_quick_overview().
| Location c4::yml::ParseEngine< EventHandler >::val_location | ( | const char * | val | ) | const |
Given a pointer to a buffer position, get the location.
| [in] | val | must be pointing to somewhere in the source buffer that was last parsed by this object. |
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_plain | ( | csubstr | scalar, |
| substr | dst, | ||
| size_t | indentation | ||
| ) |
filter a plain scalar
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_plain_in_place | ( | substr | scalar, |
| size_t | cap, | ||
| size_t | indentation | ||
| ) |
filter a plain scalar in place
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_squoted | ( | csubstr | scalar, |
| substr | dst | ||
| ) |
filter a single-quoted scalar
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_squoted_in_place | ( | substr | scalar, |
| size_t | cap | ||
| ) |
filter a single-quoted scalar in place
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_dquoted | ( | csubstr | scalar, |
| substr | dst | ||
| ) |
filter a double-quoted scalar
| FilterResultExtending c4::yml::ParseEngine< EventHandler >::filter_scalar_dquoted_in_place | ( | substr | scalar, |
| size_t | cap | ||
| ) |
filter a double-quoted scalar in place
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_block_literal | ( | csubstr | scalar, |
| substr | dst, | ||
| size_t | indentation, | ||
| BlockChomp_e | chomp | ||
| ) |
filter a block-literal scalar
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_block_literal_in_place | ( | substr | scalar, |
| size_t | cap, | ||
| size_t | indentation, | ||
| BlockChomp_e | chomp | ||
| ) |
filter a block-literal scalar in place
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_block_folded | ( | csubstr | scalar, |
| substr | dst, | ||
| size_t | indentation, | ||
| BlockChomp_e | chomp | ||
| ) |
filter a block-folded scalar
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_block_folded_in_place | ( | substr | scalar, |
| size_t | cap, | ||
| size_t | indentation, | ||
| BlockChomp_e | chomp | ||
| ) |
filter a block-folded scalar in place