rapidyaml  0.13.0
parse and emit YAML, and do it fast
Callbacks for errors and allocation

Functions called by ryml to allocate/free memory and to report errors. More...

Classes

struct  c4::yml::Callbacks
 A c-style callbacks class to customize behavior on errors or allocation. More...
 

Typedefs

using c4::yml::pfn_allocate = void *(*)(size_t len, void *hint, void *user_data)
 the type of the function used to allocate memory; ryml will only allocate memory through this callback. More...
 
using c4::yml::pfn_free = void(*)(void *mem, size_t size, void *user_data)
 the type of the function used to free memory; ryml will only free memory through this callback. More...
 
using c4::yml::pfn_error_basic = void(*)(csubstr msg, ErrorDataBasic const &errdata, void *user_data)
 the type of the function used to report basic errors. More...
 
using c4::yml::pfn_error_parse = void(*)(csubstr msg, ErrorDataParse const &errdata, void *user_data)
 the type of the function used to report parse errors. More...
 
using c4::yml::pfn_error_visit = void(*)(csubstr msg, ErrorDataVisit const &errdata, void *user_data)
 the type of the function used to report visit errors. More...
 

Functions

void c4::yml::set_callbacks (Callbacks const &c)
 set the global callbacks for the library; after a call to this function, these callbacks will be used by newly created objects (unless they are copying older objects with different callbacks). More...
 
Callbacks const & c4::yml::get_callbacks ()
 get the global callbacks More...
 
void c4::yml::reset_callbacks ()
 set the global callbacks back to their defaults. More...
 

Detailed Description

Functions called by ryml to allocate/free memory and to report errors.

See also
sample::sample_error_handler
sample::sample_global_allocator
sample::sample_per_tree_allocator

Typedef Documentation

◆ pfn_allocate

using c4::yml::pfn_allocate = typedef void* (*)(size_t len, void* hint, void *user_data)

the type of the function used to allocate memory; ryml will only allocate memory through this callback.

Definition at line 490 of file common.hpp.

◆ pfn_free

using c4::yml::pfn_free = typedef void (*)(void* mem, size_t size, void *user_data)

the type of the function used to free memory; ryml will only free memory through this callback.

Definition at line 495 of file common.hpp.

◆ pfn_error_basic

using c4::yml::pfn_error_basic = typedef void (*) (csubstr msg, ErrorDataBasic const& errdata, void *user_data)

the type of the function used to report basic errors.

Warning
Must not return. When implemented by the user, this function MUST interrupt execution (and ideally be marked with [[noreturn]]). If the function returned, the caller could enter into an infinite loop, or the program may crash. It is up to the user to choose the interruption mechanism; typically by either throwing an exception, or using std::longjmp() (see documentation) or ultimately by calling std::abort().

Definition at line 508 of file common.hpp.

◆ pfn_error_parse

using c4::yml::pfn_error_parse = typedef void (*) (csubstr msg, ErrorDataParse const& errdata, void *user_data)

the type of the function used to report parse errors.

Warning
Must not return. When implemented by the user, this function MUST interrupt execution (and ideally be marked with [[noreturn]]). If the function returned, the caller could enter into an infinite loop, or the program may crash. It is up to the user to choose the interruption mechanism; typically by either throwing an exception, or using std::longjmp() (see documentation) or ultimately by calling std::abort().

Definition at line 519 of file common.hpp.

◆ pfn_error_visit

using c4::yml::pfn_error_visit = typedef void (*) (csubstr msg, ErrorDataVisit const& errdata, void *user_data)

the type of the function used to report visit errors.

Warning
Must not return. When implemented by the user, this function MUST interrupt execution (and ideally be marked with [[noreturn]]). If the function returned, the caller could enter into an infinite loop, or the program may crash. It is up to the user to choose the interruption mechanism; typically by either throwing an exception, or using std::longjmp() (see documentation) or ultimately by calling std::abort().

Definition at line 530 of file common.hpp.

Function Documentation

◆ set_callbacks()

void c4::yml::set_callbacks ( Callbacks const &  c)

set the global callbacks for the library; after a call to this function, these callbacks will be used by newly created objects (unless they are copying older objects with different callbacks).

If RYML_NO_DEFAULT_CALLBACKS is defined, it is mandatory to call this function prior to using any other library facility.

Warning
This function is NOT thread-safe, because it sets global static data

Definition at line 89 of file common.cpp.

90 {
91  s_default_callbacks = c;
92 }

◆ get_callbacks()

Callbacks const & c4::yml::get_callbacks ( )

get the global callbacks

Warning
This function is NOT thread-safe, because it reads global static data

Definition at line 94 of file common.cpp.

95 {
96  return s_default_callbacks;
97 }

◆ reset_callbacks()

void c4::yml::reset_callbacks ( )

set the global callbacks back to their defaults.

Warning
This function is NOT thread-safe, because it sets global static data

Definition at line 99 of file common.cpp.

100 {
101  set_callbacks(Callbacks());
102 }
void set_callbacks(Callbacks const &c)
set the global callbacks for the library; after a call to this function, these callbacks will be used...
Definition: common.cpp:89