rapidyaml 0.15.2
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 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  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)
 a testing assertion, used only in this quickstart

Functions

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

◆ main()

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

Definition at line 239 of file quickstart.cpp.

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