rapidyaml 0.14.0
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
c4::yml::Callbacks Struct Reference

A c-style callbacks class to customize behavior on errors or allocation. More...

#include <common.hpp>

Public Member Functions

 Callbacks () noexcept
 Construct an object with the default callbacks.
 Callbacks (void *user_data, pfn_allocate alloc, pfn_free free, pfn_error_basic error_basic)
Callbacksset_user_data (void *user_data)
 Set the user data.
Callbacksset_allocate (pfn_allocate allocate=nullptr)
 Set or reset the allocate callback.
Callbacksset_free (pfn_free free=nullptr)
 Set or reset the free callback.
Callbacksset_error_basic (pfn_error_basic error_basic=nullptr)
 Set or reset the error_basic callback.
Callbacksset_error_parse (pfn_error_parse error_parse=nullptr)
 Set or reset the error_parse callback.
Callbacksset_error_visit (pfn_error_visit error_visit=nullptr)
 Set or reset the error_visit callback.
bool operator!= (Callbacks const &that) const
bool operator== (Callbacks const &that) const

Public Attributes

void * m_user_data
 data to be forwarded in every call to a callback
pfn_allocate m_allocate
 a pointer to an allocate handler function
pfn_free m_free
 a pointer to a free handler function
pfn_error_basic m_error_basic
 a pointer to a basic error handler function
pfn_error_parse m_error_parse
 a pointer to a parse error handler function
pfn_error_visit m_error_visit
 a pointer to a visit error handler function

Detailed Description

A c-style callbacks class to customize behavior on errors or allocation.

Can be used globally by the library and/or locally by Tree and Parser objects.

Definition at line 545 of file common.hpp.

Constructor & Destructor Documentation

◆ Callbacks() [1/2]

c4::yml::Callbacks::Callbacks ( )
noexcept

Construct an object with the default callbacks.

If RYML_NO_DEFAULT_CALLBACKS is defined, the object will be set with null members.

Definition at line 105 of file common.cpp.

106 :
107 m_user_data(nullptr),
108 #ifndef RYML_NO_DEFAULT_CALLBACKS
109 m_allocate(allocate_impl),
110 m_free(free_impl),
111 m_error_basic(error_basic_impl),
112 m_error_parse(error_parse_impl),
113 m_error_visit(error_visit_impl)
114 #else
115 m_allocate(nullptr),
116 m_free(nullptr),
117 m_error_basic(nullptr),
118 m_error_parse(nullptr),
119 m_error_visit(nullptr)
120 #endif
121{
122}
pfn_error_basic m_error_basic
a pointer to a basic error handler function
Definition common.hpp:550
pfn_error_parse m_error_parse
a pointer to a parse error handler function
Definition common.hpp:551
void * m_user_data
data to be forwarded in every call to a callback
Definition common.hpp:547
pfn_allocate m_allocate
a pointer to an allocate handler function
Definition common.hpp:548
pfn_error_visit m_error_visit
a pointer to a visit error handler function
Definition common.hpp:552
pfn_free m_free
a pointer to a free handler function
Definition common.hpp:549

◆ Callbacks() [2/2]

c4::yml::Callbacks::Callbacks ( void * user_data,
pfn_allocate alloc,
pfn_free free,
pfn_error_basic error_basic )

Definition at line 124 of file common.cpp.

125 :
126 m_user_data(user_data),
127 #ifndef RYML_NO_DEFAULT_CALLBACKS
128 m_allocate(alloc_ ? alloc_ : allocate_impl),
129 m_free(free_ ? free_ : free_impl),
130 m_error_basic(error_basic_ ? error_basic_ : error_basic_impl),
131 m_error_parse(error_parse_impl),
132 m_error_visit(error_visit_impl)
133 #else
134 m_allocate(alloc_),
135 m_free(free_),
136 m_error_basic(error_basic_),
137 m_error_parse(nullptr),
138 m_error_visit(nullptr)
139 #endif
140{
141}

Member Function Documentation

◆ set_user_data()

Callbacks & c4::yml::Callbacks::set_user_data ( void * user_data)

Set the user data.

Definition at line 144 of file common.cpp.

145{
146 m_user_data = user_data;
147 return *this;
148}

◆ set_allocate()

Callbacks & c4::yml::Callbacks::set_allocate ( pfn_allocate allocate = nullptr)

Set or reset the allocate callback.

When the parameter is null, m_allocate will fall back to ryml's default allocate implementation, unless RYML_NO_DEFAULT_CALLBACKS is defined.

Definition at line 150 of file common.cpp.

151{
152 m_allocate = allocate;
153 #ifndef RYML_NO_DEFAULT_CALLBACKS
154 m_allocate = m_allocate ? m_allocate : allocate_impl;
155 #endif
156 return *this;
157}

◆ set_free()

Callbacks & c4::yml::Callbacks::set_free ( pfn_free free = nullptr)

Set or reset the free callback.

When the parameter is null, m_free will fall back to ryml's default free implementation, unless RYML_NO_DEFAULT_CALLBACKS is defined.

Definition at line 159 of file common.cpp.

160{
161 m_free = free;
162 #ifndef RYML_NO_DEFAULT_CALLBACKS
163 m_free = m_free ? m_free : free_impl;
164 #endif
165 return *this;
166}

◆ set_error_basic()

Callbacks & c4::yml::Callbacks::set_error_basic ( pfn_error_basic error_basic = nullptr)

Set or reset the error_basic callback.

When the parameter is null, m_error_basic will fall back to ryml's default error_basic implementation, unless RYML_NO_DEFAULT_CALLBACKS is defined.

Definition at line 168 of file common.cpp.

169{
170 m_error_basic = error_basic;
171 #ifndef RYML_NO_DEFAULT_CALLBACKS
172 m_error_basic = m_error_basic ? m_error_basic : error_basic_impl;
173 #endif
174 return *this;
175}

◆ set_error_parse()

Callbacks & c4::yml::Callbacks::set_error_parse ( pfn_error_parse error_parse = nullptr)

Set or reset the error_parse callback.

When the parameter is null, m_error_parse will fall back to ryml's default error_parse implementation, unless RYML_NO_DEFAULT_CALLBACKS is defined.

Definition at line 177 of file common.cpp.

178{
179 m_error_parse = error_parse;
180 #ifndef RYML_NO_DEFAULT_CALLBACKS
181 m_error_parse = m_error_parse ? m_error_parse : error_parse_impl;
182 #endif
183 return *this;
184}

◆ set_error_visit()

Callbacks & c4::yml::Callbacks::set_error_visit ( pfn_error_visit error_visit = nullptr)

Set or reset the error_visit callback.

When the parameter is null, m_error_visit will fall back to ryml's default error_visit implementation, unless RYML_NO_DEFAULT_CALLBACKS is defined.

Definition at line 186 of file common.cpp.

187{
188 m_error_visit = error_visit;
189 #ifndef RYML_NO_DEFAULT_CALLBACKS
190 m_error_visit = m_error_visit ? m_error_visit : error_visit_impl;
191 #endif
192 return *this;
193}

◆ operator!=()

bool c4::yml::Callbacks::operator!= ( Callbacks const & that) const
inline

Definition at line 597 of file common.hpp.

597{ return !operator==(that); }
bool operator==(Callbacks const &that) const
Definition common.hpp:598

◆ operator==()

bool c4::yml::Callbacks::operator== ( Callbacks const & that) const
inline

Definition at line 598 of file common.hpp.

599 {
600 return (m_user_data == that.m_user_data &&
601 m_allocate == that.m_allocate &&
602 m_free == that.m_free &&
603 m_error_basic == that.m_error_basic &&
604 m_error_parse == that.m_error_parse &&
605 m_error_visit == that.m_error_visit);
606 }

Member Data Documentation

◆ m_user_data

void* c4::yml::Callbacks::m_user_data

data to be forwarded in every call to a callback

Definition at line 547 of file common.hpp.

◆ m_allocate

pfn_allocate c4::yml::Callbacks::m_allocate

a pointer to an allocate handler function

Definition at line 548 of file common.hpp.

◆ m_free

pfn_free c4::yml::Callbacks::m_free

a pointer to a free handler function

Definition at line 549 of file common.hpp.

◆ m_error_basic

pfn_error_basic c4::yml::Callbacks::m_error_basic

a pointer to a basic error handler function

Definition at line 550 of file common.hpp.

◆ m_error_parse

pfn_error_parse c4::yml::Callbacks::m_error_parse

a pointer to a parse error handler function

Definition at line 551 of file common.hpp.

◆ m_error_visit

pfn_error_visit c4::yml::Callbacks::m_error_visit

a pointer to a visit error handler function

Definition at line 552 of file common.hpp.


The documentation for this struct was generated from the following files:
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/v0.14.0/src/c4/yml/common.hpp
  • /home/docs/checkouts/readthedocs.org/user_builds/rapidyaml/checkouts/v0.14.0/src/c4/yml/common.cpp