rapidyaml  0.13.0
parse and emit YAML, and do it fast
quickstart.cpp File Reference
#include <ryml.hpp>
#include <ryml_std.hpp>
#include <c4/format.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)   assert(predicate)
 a quick'n'dirty assertion to verify a predicate More...
 

Functions

void ensure_callbacks ()
 set up default callbacks when ryml does not provide them (ie when RYML_NO_DEFAULT_CALLBACKS is defined) More...
 
ryml::Callbacks default_callbacks ()
 a bare-bones implementation of the callbacks More...
 
template<class CharContainer >
CharContainer file_get_contents (const char *filename)
 load a file from disk and return a newly created CharContainer More...
 
template<class CharContainer >
size_t file_get_contents (const char *filename, CharContainer *v)
 load a file from disk into an existing CharContainer More...
 
template<class CharContainer >
void file_put_contents (const char *filename, CharContainer const &v, const char *access)
 save a buffer into a file More...
 
void file_put_contents (const char *filename, const char *buf, size_t sz, const char *access)
 save a buffer into a file More...
 
bool report_check (int line, const char *predicate, bool result)
 
void sample_lightning_overview ()
 a lightning tour over most features see sample_quick_overview More...
 
void sample_quick_overview ()
 a brief tour over most features More...
 
void sample_substr ()
 demonstrate usage of ryml::substr and ryml::csubstr More...
 
void sample_parse_file ()
 demonstrate how to load a YAML file from disk to parse with ryml. More...
 
void sample_parse_in_place ()
 demonstrate in-place parsing of a mutable YAML source buffer. More...
 
void sample_parse_in_arena ()
 demonstrate parsing of a read-only YAML source buffer More...
 
void sample_parse_reuse_tree ()
 demonstrate reuse/modification of tree when parsing More...
 
void sample_parse_reuse_parser ()
 Demonstrates reuse of an existing parser. More...
 
void sample_parse_reuse_tree_and_parser ()
 for ultimate speed when parsing multiple times, reuse both the tree and parser More...
 
void sample_iterate_trees ()
 shows how to programatically iterate through trees More...
 
void sample_create_trees ()
 shows how to programatically create trees More...
 
void sample_tree_arena ()
 demonstrates explicit and implicit interaction with the tree's string arena. More...
 
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. More...
 
void sample_empty_null_values ()
 Shows how to deal with empty/null values. More...
 
void sample_formatting ()
 ryml provides facilities for formatting/deformatting (imported from c4core into the ryml namespace). More...
 
void sample_base64 ()
 demonstrates how to read and write base64-encoded blobs. More...
 
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. More...
 
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. More...
 
void sample_std_types ()
 demonstrates usage with the std implementations provided by ryml in the ryml_std.hpp header More...
 
void sample_float_precision ()
 control precision of serialized floats More...
 
void sample_emit_to_container ()
 demonstrates how to emit to a linear container of char More...
 
void sample_emit_to_stream ()
 demonstrates how to emit to a stream-like structure More...
 
void sample_emit_to_file ()
 demonstrates how to emit to a FILE* More...
 
void sample_emit_nested_node ()
 just like parsing into a nested node, you can also emit from a nested node. More...
 
void sample_style ()
 [experimental] query/set/modify node style to control formatting of emitted YAML code. More...
 
void sample_style_flow_ml_indent ()
 [experimental] control the indentation of emitted FLOW_ML containers More...
 
void sample_style_flow_ml_filter ()
 [experimental] set the parser to pick FLOW_SL even if the container being parsed is FLOW_ML More...
 
void sample_json ()
 shows how to parse and emit JSON. More...
 
void sample_anchors_and_aliases ()
 demonstrates usage with anchors and alias references. More...
 
void sample_anchors_and_aliases_create ()
 demonstrates how to use the API to programatically create anchors and aliases More...
 
void sample_tags ()
 
void sample_tag_directives ()
 
void sample_docs ()
 
void sample_error_handler ()
 demonstrates how to set a custom error handler for ryml More...
 
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. More...
 
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. More...
 
void sample_global_allocator ()
 demonstrates how to set the global allocator for ryml More...
 
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 More...
 
void sample_location_tracking ()
 demonstrates how to obtain the (zero-based) location of a node from a recently parsed tree More...
 
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