|
rapidyaml
0.7.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 &&) | |
| ParseEngine (ParseEngine const &) | |
| ParseEngine & | operator= (ParseEngine &&) |
| 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... | |
| 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 291 of file parse_engine.hpp.
| using c4::yml::ParseEngine< EventHandler >::handler_type = EventHandler |
Definition at line 295 of file parse_engine.hpp.
| c4::yml::ParseEngine< EventHandler >::ParseEngine | ( | EventHandler * | evt_handler, |
| ParserOptions | opts = {} |
||
| ) |
Definition at line 233 of file parse_engine.def.hpp.
| c4::yml::ParseEngine< EventHandler >::~ParseEngine |
Definition at line 226 of file parse_engine.def.hpp.
| c4::yml::ParseEngine< EventHandler >::ParseEngine | ( | ParseEngine< EventHandler > && | that | ) |
Definition at line 249 of file parse_engine.def.hpp.
| c4::yml::ParseEngine< EventHandler >::ParseEngine | ( | ParseEngine< EventHandler > const & | that | ) |
Definition at line 265 of file parse_engine.def.hpp.
| ParseEngine< EventHandler > & c4::yml::ParseEngine< EventHandler >::operator= | ( | ParseEngine< EventHandler > && | that | ) |
Definition at line 287 of file parse_engine.def.hpp.
| ParseEngine< EventHandler > & c4::yml::ParseEngine< EventHandler >::operator= | ( | ParseEngine< EventHandler > const & | that | ) |
Definition at line 305 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 334 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 341 of file parse_engine.hpp.
Referenced by sample::sample_location_tracking().
|
inline |
Definition at line 347 of file parse_engine.hpp.
|
inline |
Get the options used to build this parser object.
Definition at line 357 of file parse_engine.hpp.
Referenced by sample::sample_location_tracking().
|
inline |
Get the current callbacks in the parser.
Definition at line 360 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 363 of file parse_engine.hpp.
|
inline |
Get the latest YAML buffer parsed by this object.
Definition at line 366 of file parse_engine.hpp.
|
inline |
Definition at line 368 of file parse_engine.hpp.
|
inline |
Definition at line 369 of file parse_engine.hpp.
|
inline |
Definition at line 372 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
Definition at line 8046 of file parse_engine.def.hpp.
References _c4dbgnextline, c4::yml::BLCK, c4::yml::FLOW, c4::yml::RMAP, c4::yml::RSEQ, c4::yml::RSEQIMAP, c4::yml::RUNK, and c4::yml::USTY.
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
Definition at line 8002 of file parse_engine.def.hpp.
References _c4dbgnextline, c4::yml::RMAP, c4::yml::RSEQ, and c4::yml::RUNK.
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.
Definition at line 3824 of file parse_engine.def.hpp.
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.
Definition at line 3817 of file parse_engine.def.hpp.
References c4::yml::ConstNodeRef::id(), c4::yml::ConstNodeRef::readable(), and c4::yml::ConstNodeRef::tree().
| 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.
Definition at line 3810 of file parse_engine.def.hpp.
References c4::yml::Location::offset.
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. |
Definition at line 3930 of file parse_engine.def.hpp.
References c4::yml::Location::col, c4::yml::Location::line, c4::yml::Location::name, c4::yml::Location::offset, and RYML_LOCATIONS_SMALL_THRESHOLD.
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_plain | ( | csubstr | scalar, |
| substr | dst, | ||
| size_t | indentation | ||
| ) |
filter a plain scalar
Definition at line 2358 of file parse_engine.def.hpp.
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_plain_in_place | ( | substr | scalar, |
| size_t | cap, | ||
| size_t | indentation | ||
| ) |
filter a plain scalar in place
Definition at line 2365 of file parse_engine.def.hpp.
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_squoted | ( | csubstr | scalar, |
| substr | dst | ||
| ) |
filter a single-quoted scalar
Definition at line 2469 of file parse_engine.def.hpp.
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_squoted_in_place | ( | substr | scalar, |
| size_t | cap | ||
| ) |
filter a single-quoted scalar in place
Definition at line 2476 of file parse_engine.def.hpp.
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_dquoted | ( | csubstr | scalar, |
| substr | dst | ||
| ) |
filter a double-quoted scalar
Definition at line 2760 of file parse_engine.def.hpp.
| FilterResultExtending c4::yml::ParseEngine< EventHandler >::filter_scalar_dquoted_in_place | ( | substr | scalar, |
| size_t | cap | ||
| ) |
filter a double-quoted scalar in place
Definition at line 2767 of file parse_engine.def.hpp.
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_block_literal | ( | csubstr | scalar, |
| substr | dst, | ||
| size_t | indentation, | ||
| BlockChomp_e | chomp | ||
| ) |
filter a block-literal scalar
Definition at line 3091 of file parse_engine.def.hpp.
| 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
Definition at line 3098 of file parse_engine.def.hpp.
| FilterResult c4::yml::ParseEngine< EventHandler >::filter_scalar_block_folded | ( | csubstr | scalar, |
| substr | dst, | ||
| size_t | indentation, | ||
| BlockChomp_e | chomp | ||
| ) |
filter a block-folded scalar
Definition at line 3377 of file parse_engine.def.hpp.
| 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
Definition at line 3384 of file parse_engine.def.hpp.