rapidyaml
0.6.0
parse and emit YAML, and do it fast
|
Example code for every feature. More...
Modules | |
Sample helpers | |
Functions and classes used in the examples of this sample. | |
Functions | |
ryml::Callbacks | sample::ErrorHandlerExample::callbacks () |
a helper to create the Callbacks object with the custom error handler More... | |
static void | sample::ErrorHandlerExample::s_error (const char *msg, size_t len, ryml::Location loc, void *this_) |
template<class Fn > | |
bool | sample::ErrorHandlerExample::check_error_occurs (Fn &&fn) const |
template<class Fn > | |
bool | sample::ErrorHandlerExample::check_assertion_occurs (Fn &&fn) const |
void | sample::ErrorHandlerExample::check_effect (bool committed) const |
sample::ErrorHandlerExample::ErrorHandlerExample () | |
sample::ScopedErrorHandlerExample::ScopedErrorHandlerExample () | |
sample::ScopedErrorHandlerExample::~ScopedErrorHandlerExample () | |
void | sample::sample_lightning_overview () |
a lightning tour over most features see sample_quick_overview More... | |
void | sample::sample_quick_overview () |
a brief tour over most features More... | |
void | sample::sample_substr () |
demonstrate usage of ryml::substr and ryml::csubstr More... | |
void | sample::sample_parse_file () |
demonstrate how to load a YAML file from disk to parse with ryml. More... | |
void | sample::sample_parse_in_place () |
demonstrate in-place parsing of a mutable YAML source buffer. More... | |
void | sample::sample_parse_in_arena () |
demonstrate parsing of a read-only YAML source buffer More... | |
void | sample::sample_parse_reuse_tree () |
demonstrate reuse/modification of tree when parsing More... | |
void | sample::sample_parse_reuse_parser () |
Demonstrates reuse of an existing parser. More... | |
void | sample::sample_parse_reuse_tree_and_parser () |
for ultimate speed when parsing multiple times, reuse both the tree and parser More... | |
void | sample::sample_iterate_trees () |
shows how to programatically iterate through trees More... | |
void | sample::sample_create_trees () |
shows how to programatically create trees More... | |
void | sample::sample_tree_arena () |
demonstrates explicit and implicit interaction with the tree's string arena. More... | |
void | sample::sample_fundamental_types () |
ryml provides facilities for serializing and deserializing the C++ fundamental types, including boolean and null values; this is provided by the several overloads in to_chars: generalized chars to value and from_chars: generalized chars to value. More... | |
void | sample::sample_empty_null_values () |
Shows how to deal with empty/null values. More... | |
void | sample::sample_formatting () |
ryml provides facilities for formatting/deformatting (imported from c4core into the ryml namespace). More... | |
void | sample::sample_base64 () |
demonstrates how to read and write base64-encoded blobs. More... | |
void | sample::sample_user_scalar_types () |
to add scalar types (ie leaf types converting to/from string), define the functions above for those types. More... | |
void | sample::sample_user_container_types () |
shows how to serialize/deserialize container types. More... | |
void | sample::sample_std_types () |
demonstrates usage with the std implementations provided by ryml in the ryml_std.hpp header More... | |
void | sample::sample_float_precision () |
control precision of serialized floats More... | |
void | sample::sample_emit_to_container () |
demonstrates how to emit to a linear container of char More... | |
void | sample::sample_emit_to_stream () |
demonstrates how to emit to a stream-like structure More... | |
void | sample::sample_emit_to_file () |
demonstrates how to emit to a FILE* More... | |
void | sample::sample_emit_nested_node () |
just like parsing into a nested node, you can also emit from a nested node. More... | |
void | sample::sample_emit_style () |
[experimental] pick flow/block style for certain nodes. More... | |
void | sample::sample_json () |
shows how to parse and emit JSON. More... | |
void | sample::sample_anchors_and_aliases () |
demonstrates usage with anchors and alias references. More... | |
void | sample::sample_tags () |
void | sample::sample_tag_directives () |
void | sample::sample_docs () |
void | sample::sample_error_handler () |
demonstrates how to set a custom error handler for ryml More... | |
void | sample::sample_global_allocator () |
demonstrates how to set the global allocator for ryml More... | |
void | sample::sample_per_tree_allocator () |
void | sample::sample_static_trees () |
shows how to work around the static initialization order fiasco when using a static-duration ryml tree More... | |
void | sample::sample_location_tracking () |
demonstrates how to obtain the (zero-based) location of a node from a recently parsed tree More... | |
Variables | |
ryml::Callbacks | sample::ErrorHandlerExample::defaults |
Example code for every feature.
This file does a quick tour of ryml.
It has multiple self-contained and well-commented samples that illustrate how to use ryml, and how it works.
Although this is not a unit test, the samples are written as a sequence of actions and predicate checks to better convey what is the expected result at any stage. And to ensure the code here is correct and up to date, it's also run as part of the CI tests.
If something is unclear, please open an issue or send a pull request at https://github.com/biojppm/rapidyaml . If you have an issue while using ryml, it is also encouraged to try to reproduce the issue here, or look first through the relevant section.
Happy ryml'ing!
The directories that exist side-by-side with this file contain several examples on how to build this with cmake, such that you can hit the ground running. See the relevant section of the main README for an overview of the different choices. I suggest starting first with the add_subdirectory
example, treating it just like any other self-contained cmake project.
Or very quickly, to build and run this sample on your PC, start by creating this CMakeLists.txt
:
Now run the following commands in the same folder:
ryml::Callbacks sample::ErrorHandlerExample::callbacks | ( | ) |
a helper to create the Callbacks object with the custom error handler
Definition at line 5249 of file quickstart.cpp.
References sample::ErrorHandlerExample::s_error().
Referenced by sample::sample_error_handler(), and sample::sample_quick_overview().
|
static |
Referenced by sample::ErrorHandlerExample::callbacks(), and sample::ErrorHandlerExample::check_effect().
bool sample::ErrorHandlerExample::check_error_occurs | ( | Fn && | fn | ) | const |
Referenced by sample::sample_error_handler(), and sample::sample_quick_overview().
bool sample::ErrorHandlerExample::check_assertion_occurs | ( | Fn && | fn | ) | const |
Referenced by sample::sample_quick_overview().
void sample::ErrorHandlerExample::check_effect | ( | bool | committed | ) | const |
Definition at line 5254 of file quickstart.cpp.
References CHECK, sample::ErrorHandlerExample::defaults, c4::yml::get_callbacks(), c4::yml::Callbacks::m_allocate, c4::yml::Callbacks::m_error, c4::yml::Callbacks::m_free, and sample::ErrorHandlerExample::s_error().
Referenced by sample::sample_error_handler().
|
inline |
Definition at line 251 of file quickstart.cpp.
|
inline |
Definition at line 257 of file quickstart.cpp.
References c4::yml::set_callbacks().
|
inline |
void sample::sample_lightning_overview | ( | ) |
a lightning tour over most features see sample_quick_overview
Definition at line 270 of file quickstart.cpp.
References c4::yml::NodeRef::append_child(), CHECK, c4::yml::emit_yaml(), and c4::yml::parse_in_place().
void sample::sample_quick_overview | ( | ) |
a brief tour over most features
Definition at line 318 of file quickstart.cpp.
References c4::yml::NodeRef::append_child(), c4::yml::Tree::arena(), sample::ErrorHandlerExample::callbacks(), c4::yml::Tree::callbacks(), CHECK, sample::ErrorHandlerExample::check_assertion_occurs(), sample::ErrorHandlerExample::check_error_occurs(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::children(), c4::yml::Location::col, c4::yml::emit_yaml(), c4::yml::Tree::find_child(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::first_child(), c4::yml::Tree::first_child(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::first_sibling(), c4::yml::Tree::first_sibling(), c4::FTOA_FLOAT, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::has_child(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::has_key(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::has_val(), c4::yml::ConstNodeRef::id(), c4::yml::Tree::in_arena(), c4::yml::NodeRef::invalid(), c4::yml::ConstNodeRef::invalid(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_map(), c4::yml::Tree::is_map(), c4::yml::NodeRef::is_seed(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_seq(), c4::yml::Tree::is_seq(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_val(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::key(), c4::yml::Tree::key(), c4::yml::key(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::last_child(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::last_sibling(), c4::yml::Location::line, c4::yml::ParseEngine< EventHandler >::location(), c4::yml::ParseEngine< EventHandler >::location_contents(), c4::yml::MAP, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::next_sibling(), c4::yml::Tree::next_sibling(), c4::yml::NONE, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::num_children(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::num_siblings(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::parent(), c4::yml::parse_in_arena(), c4::yml::parse_in_place(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::prev_sibling(), c4::yml::NodeRef::readable(), c4::yml::ConstNodeRef::readable(), c4::fmt::real(), c4::yml::Tree::root_id(), c4::yml::Tree::rootref(), c4::yml::SEQ, c4::yml::Tree::size(), c4::to_csubstr(), c4::yml::ConstNodeRef::tree(), and c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::val().
void sample::sample_substr | ( | ) |
demonstrate usage of ryml::substr and ryml::csubstr
These types are imported from the c4core library into the ryml namespace You may have noticed above the use of a csubstr
class. This class is defined in another library, c4core, which is imported by ryml. This is a library I use with my projects consisting of multiplatform low-level utilities. One of these is c4::csubstr
(the name comes from "constant substring") which is a non-owning read-only string view, with many methods that make it practical to use (I would certainly argue more practical than std::string
). In fact, c4::csubstr
and its writeable counterpart c4::substr
are the workhorses of the ryml parsing and serialization code.
Definition at line 932 of file quickstart.cpp.
References CHECK, c4::yml::npos, c4::to_csubstr(), and c4::to_substr().
void sample::sample_parse_file | ( | ) |
demonstrate how to load a YAML file from disk to parse with ryml.
ryml offers no overload to directly parse files from disk; it only parses source buffers (which may be mutable or immutable). It is up to the caller to load the file contents into a buffer before parsing with ryml.
But that does not mean that loading a file is unimportant. There are many ways to achieve this in C++, but for convenience and to enable you to quickly get up to speed, here is an example implementation loading a file from disk and then parsing the resulting buffer with ryml.
Definition at line 1739 of file quickstart.cpp.
References CHECK, sample::file_put_contents(), c4::yml::parse_in_arena(), c4::yml::parse_in_place(), c4::to_csubstr(), and c4::to_substr().
void sample::sample_parse_in_place | ( | ) |
demonstrate in-place parsing of a mutable YAML source buffer.
Definition at line 1780 of file quickstart.cpp.
References CHECK, c4::yml::Tree::crootref(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_map(), c4::yml::key(), and c4::yml::parse_in_place().
void sample::sample_parse_in_arena | ( | ) |
demonstrate parsing of a read-only YAML source buffer
Definition at line 1834 of file quickstart.cpp.
References CHECK, c4::yml::Tree::crootref(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_map(), c4::yml::key(), and c4::yml::parse_in_arena().
void sample::sample_parse_reuse_tree | ( | ) |
demonstrate reuse/modification of tree when parsing
Definition at line 1880 of file quickstart.cpp.
References c4::yml::NodeRef::append_child(), CHECK, c4::yml::Tree::clear(), c4::yml::Tree::clear_arena(), c4::yml::Tree::crootref(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_map(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_seq(), c4::yml::key(), c4::yml::KEY, c4::yml::KEYMAP, c4::yml::KEYSEQ, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::num_children(), c4::yml::parse_in_arena(), c4::yml::Tree::reserve(), c4::yml::Tree::reserve_arena(), and c4::yml::Tree::rootref().
void sample::sample_parse_reuse_parser | ( | ) |
Demonstrates reuse of an existing parser.
Doing this is recommended when multiple files are parsed.
Definition at line 2032 of file quickstart.cpp.
References CHECK, c4::yml::parse_in_arena(), and c4::yml::ParseEngine< EventHandler >::reserve_stack().
void sample::sample_parse_reuse_tree_and_parser | ( | ) |
for ultimate speed when parsing multiple times, reuse both the tree and parser
Definition at line 2059 of file quickstart.cpp.
References CHECK, c4::yml::Tree::clear(), c4::yml::parse_in_arena(), c4::yml::Tree::reserve(), and c4::yml::ParseEngine< EventHandler >::reserve_stack().
void sample::sample_iterate_trees | ( | ) |
shows how to programatically iterate through trees
Definition at line 2117 of file quickstart.cpp.
References CHECK, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::children(), c4::yml::Tree::crootref(), c4::yml::key(), and c4::yml::parse_in_arena().
void sample::sample_create_trees | ( | ) |
shows how to programatically create trees
Definition at line 2183 of file quickstart.cpp.
References c4::yml::NodeRef::append_child(), c4::fmt::boolalpha(), CHECK, c4::yml::NodeRef::invalid(), c4::yml::NodeRef::is_seed(), c4::yml::MAP, c4::fmt::real(), c4::yml::Tree::rootref(), c4::yml::SEQ, and c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::val().
void sample::sample_tree_arena | ( | ) |
demonstrates explicit and implicit interaction with the tree's string arena.
Notice that ryml only holds strings in the tree's nodes.
Definition at line 2264 of file quickstart.cpp.
References c4::yml::Tree::alloc_arena(), c4::yml::Tree::arena(), c4::yml::Tree::arena_capacity(), CHECK, c4::yml::Tree::copy_to_arena(), c4::yml::Tree::key(), c4::yml::parse_in_arena(), c4::yml::parse_in_place(), c4::yml::Tree::reserve_arena(), c4::yml::Tree::rootref(), c4::yml::Tree::set_val(), c4::yml::NodeRef::set_val_serialized(), c4::yml::Tree::to_arena(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::val(), and c4::yml::Tree::val().
void sample::sample_fundamental_types | ( | ) |
ryml provides facilities for serializing and deserializing the C++ fundamental types, including boolean and null values; this is provided by the several overloads in to_chars: generalized chars to value and from_chars: generalized chars to value.
To add serialization for user scalar types (ie, those types that should be serialized as strings in leaf nodes), you just need to define the appropriate overloads of to_chars and from_chars for those types; see sample_user_scalar_types for an example on how to achieve this, and see Serialization/deserialization for more information on serialization.
Definition at line 2429 of file quickstart.cpp.
References c4::yml::Tree::arena(), c4::fmt::boolalpha(), CHECK, c4::yml::parse_in_arena(), and c4::yml::Tree::to_arena().
void sample::sample_empty_null_values | ( | ) |
Shows how to deal with empty/null values.
See also c4::yml::Tree::val_is_null
Definition at line 2494 of file quickstart.cpp.
References c4::yml::Tree::arena(), CHECK, c4::yml::Tree::clear(), c4::yml::Tree::clear_arena(), c4::yml::MAP, c4::yml::parse_in_arena(), c4::yml::Tree::rootref(), and c4::yml::scalar_is_null().
void sample::sample_formatting | ( | ) |
ryml provides facilities for formatting/deformatting (imported from c4core into the ryml namespace).
See Format utilities . These functions are very useful to serialize and deserialize scalar types; see Serialization/deserialization .
Definition at line 2661 of file quickstart.cpp.
References c4::fmt::bin, c4::fmt::boolalpha(), c4::cat(), c4::cat_sub(), c4::catrs(), c4::catrs_append(), c4::catsep(), c4::catsep_sub(), c4::catseprs(), c4::catseprs_append(), CHECK, c4::fmt::craw(), c4::format(), c4::format_sub(), c4::formatrs(), c4::formatrs_append(), c4::FTOA_FLEX, c4::FTOA_FLOAT, c4::FTOA_HEXA, c4::FTOA_SCIENT, c4::fmt::hex, c4::fmt::left(), c4::yml::npos, c4::fmt::oct, c4::fmt::raw(), c4::fmt::real(), c4::fmt::right(), c4::to_csubstr(), c4::uncat(), c4::uncatsep(), c4::unformat(), and c4::fmt::zpad().
void sample::sample_base64 | ( | ) |
demonstrates how to read and write base64-encoded blobs.
Definition at line 3095 of file quickstart.cpp.
References c4::yml::NodeRef::append_child(), c4::fmt::base64(), c4::base64_decode(), CHECK, c4::yml::Tree::key(), c4::yml::key(), c4::yml::MAP, c4::yml::Tree::rootref(), c4::yml::Tree::size(), c4::to_substr(), and c4::yml::Tree::val().
void sample::sample_user_scalar_types | ( | ) |
to add scalar types (ie leaf types converting to/from string), define the functions above for those types.
See Serialize/deserialize scalar types.
Definition at line 3475 of file quickstart.cpp.
References CHECK, c4::yml::MAP, and c4::yml::Tree::rootref().
void sample::sample_user_container_types | ( | ) |
shows how to serialize/deserialize container types.
Definition at line 3671 of file quickstart.cpp.
References CHECK, c4::yml::Tree::crootref(), sample::my_type::map, sample::my_map_type< K, V >::map_member, c4::yml::Tree::rootref(), sample::my_type::seq, sample::my_seq_type< T >::seq_member, sample::my_type::v2, sample::my_type::v3, sample::my_type::v4, sample::vec4< T >::w, sample::vec2< T >::x, sample::vec3< T >::x, sample::vec4< T >::x, sample::vec2< T >::y, sample::vec3< T >::y, sample::vec4< T >::y, sample::vec3< T >::z, and sample::vec4< T >::z.
void sample::sample_std_types | ( | ) |
demonstrates usage with the std implementations provided by ryml in the ryml_std.hpp header
Definition at line 3732 of file quickstart.cpp.
References CHECK, c4::yml::parse_in_place(), c4::yml::Tree::rootref(), and c4::to_substr().
void sample::sample_float_precision | ( | ) |
control precision of serialized floats
Definition at line 3796 of file quickstart.cpp.
References c4::yml::NodeRef::append_child(), CHECK, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::children(), c4::FTOA_FLOAT, c4::yml::parse_in_arena(), c4::fmt::real(), c4::yml::Tree::rootref(), c4::yml::SEQ, and c4::to_csubstr().
void sample::sample_emit_to_container | ( | ) |
demonstrates how to emit to a linear container of char
Definition at line 3929 of file quickstart.cpp.
References CHECK, c4::yml::emit_yaml(), c4::yml::emitrs_yaml(), c4::yml::parse_in_arena(), c4::to_csubstr(), and c4::to_substr().
void sample::sample_emit_to_stream | ( | ) |
demonstrates how to emit to a stream-like structure
Definition at line 4050 of file quickstart.cpp.
References CHECK, c4::yml::parse_in_arena(), and c4::to_csubstr().
void sample::sample_emit_to_file | ( | ) |
demonstrates how to emit to a FILE*
Definition at line 4114 of file quickstart.cpp.
References CHECK, c4::yml::emit_yaml(), and c4::yml::parse_in_arena().
void sample::sample_emit_nested_node | ( | ) |
just like parsing into a nested node, you can also emit from a nested node.
Definition at line 4147 of file quickstart.cpp.
References CHECK, and c4::yml::parse_in_arena().
void sample::sample_emit_style | ( | ) |
[experimental] pick flow/block style for certain nodes.
Definition at line 4189 of file quickstart.cpp.
References CHECK, c4::yml::FLOW_SL, c4::yml::parse_in_arena(), and c4::yml::Tree::rootref().
void sample::sample_json | ( | ) |
shows how to parse and emit JSON.
Definition at line 4241 of file quickstart.cpp.
References CHECK, c4::yml::parse_in_arena(), and c4::yml::parse_json_in_arena().
void sample::sample_anchors_and_aliases | ( | ) |
demonstrates usage with anchors and alias references.
Note that dereferencing is opt-in; after parsing, you have to call Tree::resolve()
explicitly if you want resolved references in the tree. This method will resolve all references and substitute the anchored values in place of the reference.
The Tree::resolve()
method first does a full traversal of the tree to gather all anchors and references in a separate collection, then it goes through that collection to locate the names, which it does by obeying the YAML standard diktat that
an alias node refers to the most recent node in the serialization having the specified anchor
So, depending on the number of anchor/alias nodes, this is a potentially expensive operation, with a best-case linear complexity (from the initial traversal) and a worst-case quadratic complexity (if every node has an alias/anchor). This potential cost is the reason for requiring an explicit call to Tree::resolve()
.
Definition at line 4299 of file quickstart.cpp.
References CHECK, c4::yml::parse_in_arena(), c4::yml::Tree::resolve(), and c4::to_csubstr().
void sample::sample_tags | ( | ) |
Definition at line 4375 of file quickstart.cpp.
References CHECK, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::children(), c4::yml::from_tag(), c4::yml::from_tag_long(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_stream(), c4::yml::normalize_tag(), c4::yml::normalize_tag_long(), c4::yml::Tree::normalize_tags(), c4::yml::Tree::normalize_tags_long(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::num_children(), c4::yml::parse_in_arena(), c4::yml::Tree::rootref(), c4::yml::TAG_INT, c4::yml::TAG_MAP, c4::yml::TAG_NONE, c4::yml::TAG_SEQ, c4::yml::TAG_SET, c4::yml::TAG_STR, c4::to_csubstr(), and c4::yml::to_tag().
void sample::sample_tag_directives | ( | ) |
Definition at line 4515 of file quickstart.cpp.
References CHECK, c4::yml::parse_in_arena(), c4::yml::Tree::resolve_tags(), and c4::to_csubstr().
void sample::sample_docs | ( | ) |
Definition at line 4549 of file quickstart.cpp.
References CHECK, c4::yml::Tree::child(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::child(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::children(), c4::yml::Tree::doc(), c4::yml::Tree::docref(), c4::yml::Tree::find_child(), c4::yml::Tree::first_child(), c4::yml::NodeRef::id(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_doc(), c4::yml::Tree::is_doc(), c4::yml::Tree::is_map(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_root(), c4::yml::Tree::is_root(), c4::yml::Tree::is_seq(), c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::is_stream(), c4::yml::Tree::is_stream(), c4::yml::Tree::next_sibling(), c4::yml::NONE, c4::yml::detail::RoNodeMethods< Impl, ConstImpl >::num_children(), c4::yml::Tree::num_children(), c4::yml::parse_in_place(), c4::yml::Tree::root_id(), c4::yml::Tree::rootref(), c4::to_substr(), and c4::yml::Tree::val().
void sample::sample_error_handler | ( | ) |
demonstrates how to set a custom error handler for ryml
Definition at line 4685 of file quickstart.cpp.
References sample::ErrorHandlerExample::callbacks(), CHECK, sample::ErrorHandlerExample::check_effect(), sample::ErrorHandlerExample::check_error_occurs(), sample::ErrorHandlerExample::defaults, and c4::yml::set_callbacks().
void sample::sample_global_allocator | ( | ) |
demonstrates how to set the global allocator for ryml
Definition at line 4797 of file quickstart.cpp.
References sample::GlobalAllocatorExample::alloc_size, sample::GlobalAllocatorExample::callbacks(), CHECK, sample::GlobalAllocatorExample::check_and_reset(), c4::yml::get_callbacks(), c4::yml::Callbacks::m_allocate, c4::yml::Callbacks::m_free, sample::GlobalAllocatorExample::num_allocs, c4::yml::parse_in_arena(), c4::yml::Tree::reserve(), c4::yml::Tree::reserve_arena(), c4::yml::ParseEngine< EventHandler >::reserve_stack(), sample::GlobalAllocatorExample::s_allocate(), sample::GlobalAllocatorExample::s_free(), and c4::yml::set_callbacks().
void sample::sample_per_tree_allocator | ( | ) |
Definition at line 4920 of file quickstart.cpp.
References sample::PerTreeMemoryExample::alloc_size, sample::PerTreeMemoryExample::callbacks(), CHECK, sample::PerTreeMemoryExample::num_allocs, and c4::yml::parse_in_arena().
void sample::sample_static_trees | ( | ) |
shows how to work around the static initialization order fiasco when using a static-duration ryml tree
Definition at line 4954 of file quickstart.cpp.
References CHECK, and c4::yml::parse_in_arena().
void sample::sample_location_tracking | ( | ) |
demonstrates how to obtain the (zero-based) location of a node from a recently parsed tree
Definition at line 4979 of file quickstart.cpp.
References CHECK, c4::yml::Location::col, c4::yml::Location::line, c4::yml::ParseEngine< EventHandler >::location(), c4::yml::ParseEngine< EventHandler >::location_contents(), c4::yml::ParserOptions::locations(), c4::yml::Location::offset, c4::yml::ParseEngine< EventHandler >::options(), c4::yml::parse_in_arena(), c4::yml::ParseEngine< EventHandler >::reserve_locations(), and c4::yml::Tree::rootref().
ryml::Callbacks sample::ErrorHandlerExample::defaults |
Definition at line 252 of file quickstart.cpp.
Referenced by sample::ErrorHandlerExample::check_effect(), and sample::sample_error_handler().