Class Parser

Nested Relationships

Nested Types

Class Documentation

class Parser

parse_in_place

substr src   = { return parse_in_place(filename, src)
substr Tree * t   = { parse_in_place(filename, src, t)
substr Tree size_t node_id   = { parse_in_place(filename, src, t, node_id)
substr NodeRef node   = { parse_in_place(filename, src, node)
inline Tree parse_in_place(csubstr filename, substr src)

Create a new tree and parse into its root. The tree is created with the callbacks currently in the parser.

inline void parse_in_place(csubstr filename, substr src, Tree *t)

Parse into an existing tree, starting at its root node. The callbacks in the tree are kept, and used to allocate the tree members, if any allocation is required.

void parse_in_place(csubstr filename, substr src, Tree *t, size_t node_id)

Parse into an existing node. The callbacks in the tree are kept, and used to allocate the tree members, if any allocation is required.

inline void parse_in_place(csubstr filename, substr src, NodeRef node)

Parse into an existing node. The callbacks in the tree are kept, and used to allocate the tree members, if any allocation is required.

RYML_DEPRECATED ("use parse_in_place() instead") Tree parse(csubstr filename
RYML_DEPRECATED ("use parse_in_place() instead") void parse(csubstr filename
RYML_DEPRECATED ("use parse_in_place() instead") void parse(csubstr filename
RYML_DEPRECATED ("use parse_in_place() instead") void parse(csubstr filename

parse_in_arena: copy the YAML source buffer to the

tree’s arena, then parse the copy in situ

Note

overloads receiving a substr YAML buffer are intentionally left undefined, such that calling parse_in_arena() with a substr will cause a linker error. This is to prevent an accidental copy of the source buffer to the tree’s arena, because substr is implicitly convertible to csubstr. If you really intend to parse a mutable buffer in the tree’s arena, convert it first to immutable by assigning the substr to a csubstr prior to calling parse_in_arena(). This is not needed for parse_in_place() because csubstr is not implicitly convertible to substr.

substr csrc
csubstr csrc   = { return parse_in_arena(filename, csrc)
csubstr Tree * t   = { parse_in_arena(filename, csrc, t)
csubstr Tree size_t node_id   = { parse_in_arena(filename, csrc, t, node_id)
csubstr NodeRef node   = { parse_in_arena(filename, csrc, node)
RYML_DEPRECATED (RYML_DONT_PARSE_SUBSTR_IN_ARENA) Tree parse_in_arena(csubstr filename
RYML_DEPRECATED (RYML_DONT_PARSE_SUBSTR_IN_ARENA) void parse_in_arena(csubstr filename
RYML_DEPRECATED (RYML_DONT_PARSE_SUBSTR_IN_ARENA) void parse_in_arena(csubstr filename
RYML_DEPRECATED (RYML_DONT_PARSE_SUBSTR_IN_ARENA) void parse_in_arena(csubstr filename
inline Tree parse_in_arena(csubstr filename, csubstr csrc)

Create a new tree and parse into its root. The immutable YAML source is first copied to the tree’s arena, and parsed from there. The callbacks in the tree are kept, and used to allocate the tree members, if any allocation is required.

inline void parse_in_arena(csubstr filename, csubstr csrc, Tree *t)

Parse into an existing tree, starting at its root node. The immutable YAML source is first copied to the tree’s arena, and parsed from there. The callbacks in the tree are kept, and used to allocate the tree members, if any allocation is required.

inline void parse_in_arena(csubstr filename, csubstr csrc, Tree *t, size_t node_id)

Parse into a specific node in an existing tree. The immutable YAML source is first copied to the tree’s arena, and parsed from there. The callbacks in the tree are kept, and used to allocate the tree members, if any allocation is required.

inline void parse_in_arena(csubstr filename, csubstr csrc, NodeRef node)

Parse into a specific node in an existing tree. The immutable YAML source is first copied to the tree’s arena, and parsed from there. The callbacks in the tree are kept, and used to allocate the tree members, if any allocation is required.

RYML_DEPRECATED ("use parse_in_arena() instead") Tree parse(csubstr filename
RYML_DEPRECATED ("use parse_in_arena() instead") void parse(csubstr filename
RYML_DEPRECATED ("use parse_in_arena() instead") void parse(csubstr filename
RYML_DEPRECATED ("use parse_in_arena() instead") void parse(csubstr filename

construction and assignment

Parser(Callbacks const &cb, ParserOptions opts = {})
inline Parser(ParserOptions opts = {})
~Parser()
Parser(Parser&&)
Parser(Parser const&)
Parser &operator=(Parser&&)
Parser &operator=(Parser const&)

modifiers

inline void reserve_stack(size_t capacity)

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 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.

Note

this reserves memory only for the parser itself; all the allocations for the parsed tree will go through the tree’s allocator.

Note

the tree and the arena can (and should) also be reserved.

inline void reserve_locations(size_t num_source_lines)

Reserve a certain capacity for the array used to track node locations in the source buffer.

inline void reserve_filter_arena(size_t num_characters)

Reserve a certain capacity for the character arena used to filter scalars.

getters and modifiers

inline Callbacks callbacks() const

Get the current callbacks in the parser.

inline csubstr filename() const

Get the name of the latest file parsed by this object.

inline csubstr source() const

Get the latest YAML buffer parsed by this object.

inline size_t stack_capacity() const
inline size_t locations_capacity() const
inline size_t filter_arena_capacity() const
inline ParserOptions const &options() const

locations

Location location(Tree const &tree, size_t node_id) const

Get the location of a node of the last tree to be parsed by this parser.

Location location(ConstNodeRef node) const

Get the location of a node of the last tree to be parsed by this parser.

csubstr location_contents(Location const &loc) const

Get the string starting at a particular location, to the end of the parsed source buffer.

Location val_location(const char *val) const

Given a pointer to a buffer position, get the location. val must be pointing to somewhere in the source buffer that was last parsed by this object.