rapidyaml 0.14.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
quickstart.cpp File Reference
#include <ryml.hpp>
#include <ryml_std.hpp>
#include <c4/format.hpp>
#include <c4/format_base64.hpp>
#include <c4/yml/file.hpp>
#include <c4/yml/error.def.hpp>
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <csetjmp>

Go to the source code of this file.

Classes

struct  ErrorHandlerExample
 an example error handler, required for some of the quickstart examples. More...
struct  ScopedErrorHandlerExample
 Shows how to create a scoped error handler. More...
struct  vec2< T >
 example scalar type, serialized and deserialized More...
struct  vec3< T >
 example scalar type, serialized and deserialized More...
struct  vec4< T >
 example scalar type, serialized and deserialized More...
struct  parse_only_vec2< T >
 example scalar type, deserialized only More...
struct  parse_only_vec3< T >
 example scalar type, deserialized only More...
struct  parse_only_vec4< T >
 example scalar type, deserialized only More...
struct  emit_only_vec2< T >
 example scalar type, serialized only More...
struct  emit_only_vec3< T >
 example scalar type, serialized only More...
struct  emit_only_vec4< T >
 example scalar type, serialized only More...
struct  my_seq_type< T >
 example user container type: seq-like More...
struct  my_map_type< K, V >
 example user container type: map-like More...
struct  my_type
 example user container type with nested container members. More...
struct  GlobalAllocatorExample
struct  PerTreeMemoryExample
 an example for a per-tree memory allocator More...

Macros

#define CHECK(predicate)
 a quick'n'dirty assertion to verify a predicate

Functions

void ensure_callbacks ()
 set up default callbacks when ryml does not provide them (ie when RYML_NO_DEFAULT_CALLBACKS is defined)
ryml::Callbacks default_callbacks ()
 a bare-bones implementation of the callbacks
bool report_check (int line, const char *predicate, bool result)
void sample_lightning_overview ()
 a lightning tour over most features see sample_quick_overview
void sample_quick_overview ()
 a brief tour over most features
void sample_substr ()
 demonstrate usage of ryml::substr and ryml::csubstr
void sample_parse_file ()
 demonstrate how to load a YAML file from disk to parse with ryml.
void sample_parse_in_place ()
 demonstrate in-place parsing of a mutable YAML source buffer.
void sample_parse_in_arena ()
 demonstrate parsing of a read-only YAML source buffer
void sample_parse_reuse_tree ()
 demonstrate reuse/modification of tree when parsing
void sample_parse_reuse_parser ()
 Demonstrates reuse of an existing parser.
void sample_parse_reuse_tree_and_parser ()
 for ultimate speed when parsing multiple times, reuse both the tree and parser
void sample_iterate_trees ()
 shows how to programatically iterate through trees
void sample_create_trees ()
 shows how to programatically create trees
void sample_tree_arena ()
 demonstrates explicit and implicit interaction with the tree's string arena.
void 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.
void sample_empty_null_values ()
 Shows how to deal with empty/null values.
void sample_formatting ()
 ryml provides facilities for formatting/deformatting (imported from c4core into the ryml namespace).
void sample_base64 ()
 demonstrates how to read and write base64-encoded blobs.
template<class T>
size_t to_chars (ryml::substr buf, vec2< T > v)
template<class T>
size_t to_chars (ryml::substr buf, vec3< T > v)
template<class T>
size_t to_chars (ryml::substr buf, vec4< T > v)
template<class T>
size_t to_chars (ryml::substr buf, emit_only_vec2< T > v)
template<class T>
size_t to_chars (ryml::substr buf, emit_only_vec3< T > v)
template<class T>
size_t to_chars (ryml::substr buf, emit_only_vec4< T > v)
template<class T>
bool from_chars (ryml::csubstr buf, vec2< T > *v)
template<class T>
bool from_chars (ryml::csubstr buf, vec3< T > *v)
template<class T>
bool from_chars (ryml::csubstr buf, vec4< T > *v)
template<class T>
bool from_chars (ryml::csubstr buf, parse_only_vec2< T > *v)
template<class T>
bool from_chars (ryml::csubstr buf, parse_only_vec3< T > *v)
template<class T>
bool from_chars (ryml::csubstr buf, parse_only_vec4< T > *v)
void sample_user_scalar_types ()
 to add scalar types (ie leaf types converting to/from string), define the functions above for those types.
template<class T>
void write (ryml::NodeRef *n, my_seq_type< T > const &seq)
template<class K, class V>
void write (ryml::NodeRef *n, my_map_type< K, V > const &map)
void write (ryml::NodeRef *n, my_type const &val)
template<class T>
bool read (ryml::ConstNodeRef const &n, my_seq_type< T > *seq)
template<class K, class V>
bool read (ryml::ConstNodeRef const &n, my_map_type< K, V > *map)
bool read (ryml::ConstNodeRef const &n, my_type *val)
void sample_user_container_types ()
 shows how to serialize/deserialize container types.
void sample_std_types ()
 demonstrates usage with the std implementations provided by ryml in the ryml_std.hpp header
void sample_float_precision ()
 control precision of serialized floats
void sample_emit_to_container ()
 demonstrates how to emit to a linear container of char
void sample_emit_to_stream ()
 demonstrates how to emit to a stream-like structure
void sample_emit_to_file ()
 demonstrates how to emit to a FILE*
void sample_emit_nested_node ()
 just like parsing into a nested node, you can also emit from a nested node.
void sample_style ()
 [experimental] query/set/modify node style to control formatting of emitted YAML code.
void sample_style_flow_ml_indent ()
 [experimental] control the indentation of emitted FLOW_ML containers
void sample_style_flow_ml_filter ()
 [experimental] set the parser to pick FLOW_SL even if the container being parsed is FLOW_ML
void sample_json ()
 shows how to parse and emit JSON.
void sample_anchors_and_aliases ()
 demonstrates usage with anchors and alias references.
void sample_anchors_and_aliases_create ()
 demonstrates how to use the API to programatically create anchors and aliases
void sample_tags ()
void sample_tag_directives ()
void sample_docs ()
void sample_error_handler ()
 demonstrates how to set a custom error handler for ryml
void sample_error_basic ()
void sample_error_parse ()
void sample_error_visit ()
 Visit errors happen when an error is triggered while reading from a node.
void sample_error_visit_location ()
 It is possible to obtain the YAML location from a visit error: when the tree is obtained from parsing YAML, the messages may be enriched by using a parser set to track the locations.
void sample_global_allocator ()
 demonstrates how to set the global allocator for ryml
void sample_per_tree_allocator ()
void sample_static_trees ()
 shows how to work around the static initialization order fiasco when using a static-duration ryml tree
void sample_location_tracking ()
 demonstrates how to obtain the (zero-based) location of a node from a recently parsed tree
void handle_args (int argc, const char *argv[])
int report_checks ()

Variables

static std::jmp_buf s_jmp_env
static std::string s_jmp_msg