|
rapidyaml
0.12.1
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... | |
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 |
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 | |
| 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 259 of file parse_engine.hpp.
| using c4::yml::ParseEngine< EventHandler >::handler_type = EventHandler |
Definition at line 263 of file parse_engine.hpp.
| c4::yml::ParseEngine< EventHandler >::ParseEngine | ( | EventHandler * | evt_handler, |
| ParserOptions | opts = {} |
||
| ) |
Definition at line 297 of file parse_engine.def.hpp.
| c4::yml::ParseEngine< EventHandler >::~ParseEngine |
Definition at line 290 of file parse_engine.def.hpp.
|
noexcept |
Definition at line 316 of file parse_engine.def.hpp.
| c4::yml::ParseEngine< EventHandler >::ParseEngine | ( | ParseEngine< EventHandler > const & | that | ) |
Definition at line 335 of file parse_engine.def.hpp.
|
noexcept |
Definition at line 360 of file parse_engine.def.hpp.
| ParseEngine< EventHandler > & c4::yml::ParseEngine< EventHandler >::operator= | ( | ParseEngine< EventHandler > const & | that | ) |
Definition at line 381 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 302 of file parse_engine.hpp.
|
inline |
Reserve a certain capacity for the array used to track node locations in the source buffer.
Definition at line 310 of file parse_engine.hpp.
|
inline |
Get the options used to build this parser object.
Definition at line 323 of file parse_engine.hpp.
|
inline |
Get the current callbacks in the parser.
Definition at line 326 of file parse_engine.hpp.
|
inline |
Get the name of the latest file parsed by this object.
Definition at line 329 of file parse_engine.hpp.
|
inline |
Get the latest YAML buffer parsed by this object.
Definition at line 332 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 336 of file parse_engine.hpp.
References c4::yml::NOBOM, and c4::yml::UTF8.
|
inline |
Definition at line 338 of file parse_engine.hpp.
|
inline |
Definition at line 339 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
| void c4::yml::ParseEngine< EventHandler >::parse_json_in_place_ev | ( | csubstr | filename, |
| substr | src | ||
| ) |
parse JSON in place, emitting events to the current handler
| 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.
| 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