rapidyaml  0.16.0
parseandemitYAML,anddoitfast
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 error handler used by 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  Inner
 
struct  Outer
 serializes as a map 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 user types. More...
 
struct  GlobalAllocatorExample
 
struct  PerTreeMemoryExample
 an example for a per-tree memory allocator More...
 

Macros

#define CHECK(predicate)   assert(predicate)
 a testing assertion, used only in this quickstart More...
 

Functions

void sample_lightning_overview ()
 lightning overview of most common features More...
 
void sample_quick_overview ()
 quick overview of most common features More...
 
void sample_substr ()
 about ryml's string views (from c4core) More...
 
void sample_parse_file ()
 ready-to-go example of parsing a file from disk More...
 
void sample_parse_in_place ()
 parse a mutable YAML source buffer More...
 
void sample_parse_in_arena ()
 parse a read-only YAML source buffer More...
 
void sample_parse_reuse_tree ()
 parse into an existing tree, maybe into a node More...
 
void sample_parse_reuse_parser ()
 reuse an existing parser More...
 
void sample_parse_reuse_tree_and_parser ()
 how to reuse existing trees and parsers More...
 
void sample_parse_style ()
 shows how rapidyaml retains the style of parsed YAML More...
 
void sample_iterate_tree ()
 visit individual nodes and iterate through trees More...
 
void sample_location_tracking ()
 track node YAML source locations in the parsed tree More...
 
void sample_create_tree ()
 programatically create trees More...
 
void sample_create_tree_style ()
 set node styles while creating trees More...
 
void sample_tree_arena ()
 interact with the tree's serialization arena More...
 
void sample_fundamental_types ()
 serialize/deserialize fundamental types More...
 
void sample_empty_null_values ()
 serialize/deserialize/query empty or null values More...
 
void sample_formatting ()
 control formatting when serializing/deserializing More...
 
void sample_base64 ()
 encode/decode base64 More...
 
void sample_serialize_basic ()
 serialize/deserialize fundamental types More...
 
void sample_user_scalar_types ()
 serialize/deserialize scalar (leaf/scalar) types More...
 
void sample_user_container_types_brief ()
 serialize/deserialize container (map or seq) types: brief version More...
 
void sample_user_container_types ()
 serialize/deserialize container (map or seq) types More...
 
void sample_std_types ()
 serialize/deserialize STL containers More...
 
void sample_deserialize_error ()
 shows error on deserializing nested nodes More...
 
void sample_float_precision ()
 control precision of serialized floats More...
 
void sample_emit_to_container ()
 emit to memory, eg a string or vector-like container More...
 
void sample_emit_to_stream ()
 emit to a stream, eg std::ostream More...
 
void sample_emit_to_file ()
 emit to a FILE* More...
 
void sample_emit_nested_node ()
 pick a nested node as the root when emitting More...
 
void sample_json ()
 JSON parsing and emitting. More...
 
void sample_style ()
 query/set node styles More...
 
void sample_style_flow_formatting ()
 control formatting of flow containers More...
 
void sample_style_flow_ml_indent ()
 control indentation of FLOW_ML1 and FLOW_MLN containers More...
 
void sample_anchors_and_aliases ()
 deal with YAML anchors and aliases More...
 
void sample_anchors_and_aliases_create ()
 how to create YAML anchors and aliases More...
 
void sample_tags ()
 deal with YAML type tags More...
 
void sample_tag_directives ()
 deal with YAML tag namespace directives More...
 
void sample_docs ()
 deal with YAML docs More...
 
void sample_error_handler ()
 set custom error handlers More...
 
void sample_error_basic ()
 handler for basic errors, and obtain a full error message with basic context More...
 
void sample_error_parse ()
 handler for parse errors, and obtain a full error message with parse context More...
 
void sample_error_visit ()
 handler for visit errors, and obtain a full error message with visit context More...
 
void sample_error_visit_location ()
 obtaining the YAML location from a visit error More...
 
void sample_global_allocator ()
 set a global allocator for ryml More...
 
void sample_per_tree_allocator ()
 set per-tree allocators More...
 
void sample_static_trees ()
 how to use static trees in ryml More...
 
int main (int argc, const char *argv[])
 
bool report_check (int line, const char *predicate, bool result)
 used by CHECK() More...
 
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 ()
 set up a bare-bones implementation of the callbacks 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 write (ryml::NodeRef &n, Inner const &inner)
 serializes as a seq More...
 
void write (ryml::NodeRef &n, Outer const &outer)
 
ryml::ReadResult read (ryml::ConstNodeRef const &n, Inner *inner)
 
ryml::ReadResult read (ryml::ConstNodeRef const &n, Outer *val)
 
template<class T >
void write (ryml::Tree *tree, ryml::id_type id, my_seq_type< T > const &seq)
 
void write (ryml::Tree *tree, ryml::id_type id, my_seq_type< std::string > const &seq)
 
template<class K , class V >
void write (ryml::Tree *tree, ryml::id_type id, my_map_type< K, V > const &map)
 
void write (ryml::Tree *tree, ryml::id_type id, my_type const &val)
 
template<class T >
ryml::ReadResult read (ryml::Tree const *tree, ryml::id_type id, my_seq_type< T > *seq)
 
template<class K , class V >
ryml::ReadResult read (ryml::Tree const *tree, ryml::id_type id, my_map_type< K, V > *map)
 
ryml::ReadResult read (ryml::ConstNodeRef const &n, my_type *val)
 
ryml::ReadResult read (ryml::Tree const *tree, ryml::id_type id, my_type *val)
 
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
 

Function Documentation

int main ( int  argc,
const char *  argv[] 
)

Definition at line 240 of file quickstart.cpp.

241 {
242  handle_args(argc, argv);
246  sample_substr();
262  sample_base64();
274  sample_style();
277  sample_json();
280  sample_tags();
282  sample_docs();
291  return report_checks();
292 }
void sample_fundamental_types()
serialize/deserialize fundamental types
void sample_style_flow_ml_indent()
control indentation of FLOW_ML1 and FLOW_MLN containers
void sample_user_container_types()
serialize/deserialize container (map or seq) types
void sample_error_visit_location()
obtaining the YAML location from a visit error
void sample_error_basic()
handler for basic errors, and obtain a full error message with basic context
void sample_emit_nested_node()
pick a nested node as the root when emitting
void sample_error_parse()
handler for parse errors, and obtain a full error message with parse context
void sample_lightning_overview()
lightning overview of most common features
Definition: quickstart.cpp:409
void sample_substr()
about ryml's string views (from c4core)
void sample_anchors_and_aliases_create()
how to create YAML anchors and aliases
void sample_parse_in_arena()
parse a read-only YAML source buffer
void sample_iterate_tree()
visit individual nodes and iterate through trees
void sample_create_tree_style()
set node styles while creating trees
void sample_parse_reuse_parser()
reuse an existing parser
void sample_tags()
deal with YAML type tags
void sample_serialize_basic()
serialize/deserialize fundamental types
void sample_parse_style()
shows how rapidyaml retains the style of parsed YAML
void sample_per_tree_allocator()
set per-tree allocators
void sample_docs()
deal with YAML docs
void sample_tree_arena()
interact with the tree's serialization arena
void sample_std_types()
serialize/deserialize STL containers
void sample_parse_reuse_tree_and_parser()
how to reuse existing trees and parsers
void sample_style()
query/set node styles
void sample_user_container_types_brief()
serialize/deserialize container (map or seq) types: brief version
void sample_create_tree()
programatically create trees
void sample_formatting()
control formatting when serializing/deserializing
void sample_static_trees()
how to use static trees in ryml
int report_checks()
void sample_anchors_and_aliases()
deal with YAML anchors and aliases
void sample_parse_file()
ready-to-go example of parsing a file from disk
void sample_location_tracking()
track node YAML source locations in the parsed tree
void sample_parse_in_place()
parse a mutable YAML source buffer
void sample_float_precision()
control precision of serialized floats
void sample_tag_directives()
deal with YAML tag namespace directives
void sample_global_allocator()
set a global allocator for ryml
void sample_parse_reuse_tree()
parse into an existing tree, maybe into a node
void sample_emit_to_container()
emit to memory, eg a string or vector-like container
void sample_style_flow_formatting()
control formatting of flow containers
void ensure_callbacks()
set up default callbacks when ryml does not provide them (ie when RYML_NO_DEFAULT_CALLBACKS is define...
void sample_user_scalar_types()
serialize/deserialize scalar (leaf/scalar) types
void sample_quick_overview()
quick overview of most common features
Definition: quickstart.cpp:464
void sample_base64()
encode/decode base64
void sample_empty_null_values()
serialize/deserialize/query empty or null values
void sample_emit_to_stream()
emit to a stream, eg std::ostream
void handle_args(int argc, const char *argv[])
void sample_error_visit()
handler for visit errors, and obtain a full error message with visit context
void sample_deserialize_error()
shows error on deserializing nested nodes
void sample_json()
JSON parsing and emitting.
void sample_emit_to_file()
emit to a FILE*
void sample_error_handler()
set custom error handlers