rapidyaml  0.16.0
parseandemitYAML,anddoitfast
common.hpp
Go to the documentation of this file.
1 #ifndef C4_YML_COMMON_HPP_
2 #define C4_YML_COMMON_HPP_
3 
4 /** @file common.hpp Common utilities and infrastructure used by ryml. */
5 
6 #include <cstddef>
7 #include <utility> // for std::forward
8 
9 #ifndef C4_SUBSTR_HPP_
10 #include <c4/substr.hpp>
11 #endif
12 #ifndef C4_YML_EXPORT_HPP_
13 #include <c4/yml/export.hpp>
14 #endif
15 
16 
17 //-----------------------------------------------------------------------------
18 
19 #ifndef RYML_DEFAULT_TREE_CAPACITY
20 /// default capacity for the tree when not set explicitly
21 #define RYML_DEFAULT_TREE_CAPACITY (16)
22 #endif
23 
24 #ifndef RYML_DEFAULT_TREE_ARENA_CAPACITY
25 /// default capacity for the tree's arena when not set explicitly
26 #define RYML_DEFAULT_TREE_ARENA_CAPACITY (0)
27 #endif
28 
29 #ifndef RYML_DEFAULT_TREE_ARENA_CAPACITY_START
30 /// default starting capacity for the tree's arena when it is first
31 /// allocated. should be larger than @ref RYML_DEFAULT_TREE_ARENA_CAPACITY
32 #define RYML_DEFAULT_TREE_ARENA_CAPACITY_START (256)
33 #endif
34 
35 
36 #ifndef RYML_LOCATIONS_SMALL_THRESHOLD
37 /// threshold at which a location search will revert from linear to
38 /// binary search.
39 #define RYML_LOCATIONS_SMALL_THRESHOLD (30)
40 #endif
41 
42 
43 #ifndef RYML_ERRMSG_SIZE
44 /// size for the error message buffer
45 #define RYML_ERRMSG_SIZE (1024)
46 #endif
47 
48 
49 #ifndef RYML_LOGBUF_SIZE
50 /// size for the buffer used to format individual values to string
51 /// while preparing an error message. This is only used for formatting
52 /// individual values in the message; final messages will be larger
53 /// than this value (see @ref RYML_ERRMSG_SIZE). This is also used for
54 /// the detailed debug log messages when RYML_DBG is defined.
55 #define RYML_LOGBUF_SIZE (256)
56 #endif
57 static_assert(RYML_LOGBUF_SIZE < RYML_ERRMSG_SIZE, "invalid size");
58 
59 
60 #ifndef RYML_LOGBUF_SIZE_MAX
61 /// size for the fallback larger log buffer. When @ref
62 /// RYML_LOGBUF_SIZE is not large enough to convert a value to string,
63 /// then temporary stack memory is allocated up to
64 /// RYML_LOGBUF_SIZE_MAX. This limit is in place to prevent a stack
65 /// overflow. If the printed value requires more than
66 /// RYML_LOGBUF_SIZE_MAX, the value is silently skipped.
67 #define RYML_LOGBUF_SIZE_MAX (1024)
68 #endif
69 
70 
71 //-----------------------------------------------------------------------------
72 
73 /** @cond dev */
74 
75 #ifndef RYML_USE_ASSERT
76 # define RYML_USE_ASSERT C4_USE_ASSERT
77 #endif
78 
79 #if RYML_USE_ASSERT
80 # define RYML_NOEXCEPT
81 #else
82 # define RYML_NOEXCEPT noexcept
83 #endif
84 
85 #define RYML_DEPRECATED(msg) C4_DEPRECATED(msg)
86 
87 #ifdef RYML_WITH_LEGACY_OPERATORS
88 # define RYML_LEGACY_OPERATOR(txt)
89 #else
90 # define RYML_LEGACY_OPERATOR(txt) RYML_DEPRECATED(txt ". To avoid this warning, define the symbol RYML_WITH_LEGACY_OPERATORS while compiling")
91 #endif
92 
93 #define RYML_CHECK_TYPE_IS_WRAPPER_LIKE_(type) \
94  static_assert(!std::is_fundamental<type>::value, \
95  "did you forget to use '&'? " \
96  "This overload is for wrapper types such as c4::fmt::base64()");
97 
98 /** @endcond */
99 
100 
101 //-----------------------------------------------------------------------------
102 //-----------------------------------------------------------------------------
103 //-----------------------------------------------------------------------------
104 
105 namespace c4 {
106 namespace yml {
107 
108 C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH("-Wold-style-cast")
109 
110 class Tree;
111 
112 
113 #ifndef RYML_ID_TYPE
114 /** The type of a node id in the YAML tree. In the future, the default
115  * will likely change to int32_t, which was observed to be faster.
116  * @see id_type */
117 #define RYML_ID_TYPE size_t
118 #endif
119 
120 
121 /** The type of a node id in the YAML tree; to override the default
122  * type, define the macro @ref RYML_ID_TYPE to a suitable integer
123  * type. */
125 static_assert(std::is_integral<id_type>::value, "id_type must be an integer type");
126 
127 
128 C4_SUPPRESS_WARNING_GCC_WITH_PUSH("-Wuseless-cast")
129 enum : id_type { // NOLINT
130  /** an index to none */
131  NONE = id_type(-1), // NOLINT
132 };
133 C4_SUPPRESS_WARNING_GCC_CLANG_POP
134 
135 
136 enum : size_t { // NOLINT
137  /** a null string position */
138  npos = size_t(-1) // NOLINT
139 };
140 
141 
142 typedef enum Encoding_ { // NOLINT
143  NOBOM, //!< No Byte Order Mark was found
144  UTF8, //!< UTF8
145  UTF16LE, //!< UTF16, Little-Endian
146  UTF16BE, //!< UTF16, Big-Endian
147  UTF32LE, //!< UTF32, Little-Endian
148  UTF32BE, //!< UTF32, Big-Endian
149 } Encoding_e;
150 
151 
152 //-----------------------------------------------------------------------------
153 //-----------------------------------------------------------------------------
154 //-----------------------------------------------------------------------------
155 
156 /** A lightweight truthy type, used to enable reporting the offending
157  * node when a deserializing error happens in nested reads. It reports
158  * the innermost node causing the error, or true (empty-initialized)
159  * when there is no error.
160  */
162 {
164  enum : id_type { VALID = NONE - 1 }; // NOLINT
165 
166 public:
167 
168  /** convert to boolean to signify success/error */
169  operator bool() const noexcept { return node == VALID; }
170 
171 public:
172 
173  /** construct as success */
174  C4_ALWAYS_INLINE ReadResult() noexcept : node(VALID) {}
175 
176  /** construct as failure on the given node id */
177  C4_ALWAYS_INLINE explicit ReadResult(id_type node_) noexcept
178  : node(node_) {}
179 
180  /** construct as failure on the given parent_, IF node_ is NONE */
181  C4_ALWAYS_INLINE explicit ReadResult(id_type parent_, id_type node_) noexcept
182  : node(node_ != NONE ? VALID : parent_) {}
183 
184 public:
185 
186  // These adapter ctors are used by rapidyaml in the functions
187  // calling read(), and enable working both with legacy and
188  // up-to-date user implementations of read(). See for example
189  // Tree::deserialize().
190 
191  /** adapter: will match legacy user code (`%read()`
192  * implementations returning bool). On error, this will report
193  * node_ as the offending node.
194  *
195  * This is an adapter ctor used by rapidyaml in the functions
196  * calling `%read()`, and enables rapidyaml to work both with
197  * legacy and up-to-date user implementations of `%read()`. See
198  * for example @ref Tree::deserialize().
199  */
200  C4_ALWAYS_INLINE explicit ReadResult(bool ok, id_type node_) noexcept
201  : node(ok ? VALID : node_) {}
202 
203  /** adapter: will match up-to-date user code (`%read()`
204  * implementations returning @ref ReadResult). On error, this will
205  * report the node in the original @ref ReadResult.
206  *
207  * This is an adapter ctor used by rapidyaml in the functions
208  * calling `%read()`, and enables rapidyaml to work both with
209  * legacy and up-to-date user implementations of `%read()`. See
210  * for example @ref Tree::deserialize().
211  */
212  C4_ALWAYS_INLINE explicit ReadResult(ReadResult result, id_type) noexcept
213  : node(result.node) {}
214 };
215 
216 
217 //-----------------------------------------------------------------------------
218 //-----------------------------------------------------------------------------
219 //-----------------------------------------------------------------------------
220 
221 C4_SUPPRESS_WARNING_MSVC_WITH_PUSH(4251) // csubstr needs to have dll-interface to be used by clients of Location
222 
223 /** holds a source or yaml file position, for example when an error is
224  * detected; See also @ref location_format() and @ref
225  * location_format_with_context().
226  *
227  * @ingroup doc_error_handling */
229 {
230  size_t offset; ///< number of bytes from the beginning of the source buffer
231  size_t line; ///< line
232  size_t col; ///< column
233  csubstr name; ///< name of the file
234 
235  operator bool () const noexcept { return !name.empty() || line != npos || offset != npos || col != npos; }
236 
237  C4_NO_INLINE Location() noexcept : offset(npos), line(npos), col(npos), name() {}
238  C4_NO_INLINE Location( size_t l ) noexcept : offset(npos), line(l), col(npos), name() {}
239  C4_NO_INLINE Location( size_t l, size_t c) noexcept : offset(npos), line(l), col(c ), name() {}
240  C4_NO_INLINE Location( size_t b, size_t l, size_t c) noexcept : offset(b ), line(l), col(c ), name() {}
241  C4_NO_INLINE Location( csubstr n, size_t l ) noexcept : offset(npos), line(l), col(npos), name(n) {}
242  C4_NO_INLINE Location( csubstr n, size_t l, size_t c) noexcept : offset(npos), line(l), col(c ), name(n) {}
243  C4_NO_INLINE Location( csubstr n, size_t b, size_t l, size_t c) noexcept : offset(b ), line(l), col(c ), name(n) {}
244  C4_NO_INLINE Location(const char *n, size_t l ) noexcept : offset(npos), line(l), col(npos), name(to_csubstr(n)) {}
245  C4_NO_INLINE Location(const char *n, size_t l, size_t c) noexcept : offset(npos), line(l), col(c ), name(to_csubstr(n)) {}
246  C4_NO_INLINE Location(const char *n, size_t b, size_t l, size_t c) noexcept : offset(b ), line(l), col(c ), name(to_csubstr(n)) {}
247 };
248 static_assert(std::is_standard_layout<Location>::value, "Location not trivial");
249 
250 C4_SUPPRESS_WARNING_MSVC_POP
251 
252 /// @cond dev
253 #define RYML_LOC_HERE() (::c4::yml::Location(__FILE__, static_cast<size_t>(__LINE__)))
254 /// @endcond
255 
256 
257 /** Data for a basic error.
258  * @ingroup doc_error_handling */
260 {
261  Location location; ///< location where the error was detected (may be from YAML or C++ source code)
262  ErrorDataBasic() noexcept = default;
263  ErrorDataBasic(Location const& cpploc_) noexcept : location(cpploc_) {}
264 };
265 
266 /** Data for a parse error.
267  * @ingroup doc_error_handling */
269 {
270  Location cpploc; ///< location in the C++ source file where the error was detected.
271  Location ymlloc; ///< location in the YAML source buffer where the error was detected.
272  ErrorDataParse() noexcept = default;
273  ErrorDataParse(Location const& cpploc_, Location const& ymlloc_) noexcept : cpploc(cpploc_), ymlloc(ymlloc_) {}
274 };
275 
276 /** Data for a visit error.
277  * @ingroup doc_error_handling */
279 {
280  Location cpploc; ///< location in the C++ source file where the error was detected.
281  Tree const* tree; ///< tree where the error was detected
282  id_type node; ///< node where the error was detected
283  ErrorDataVisit() noexcept = default;
284  ErrorDataVisit(Location const& cpploc_, Tree const *tree_ , id_type node_) noexcept : cpploc(cpploc_), tree(tree_), node(node_) {}
285 };
286 
287 
288 //-----------------------------------------------------------------------------
289 
290 /** @addtogroup doc_callbacks
291  *
292  * @{ */
293 
294 struct Callbacks;
295 
296 
297 /** set the global callbacks for the library; after a call to this
298  * function, these callbacks will be used by newly created objects
299  * (unless they are copying older objects with different
300  * callbacks). If @ref RYML_NO_DEFAULT_CALLBACKS is defined, it is
301  * mandatory to call this function prior to using any other library
302  * facility.
303  *
304  * @warning This function is NOT thread-safe, because it sets global static data
305  * */
306 RYML_EXPORT void set_callbacks(Callbacks const& c);
307 
308 /** get the global callbacks
309  *
310  * @warning This function is NOT thread-safe, because it reads global static data
311  * */
312 RYML_EXPORT Callbacks const& get_callbacks();
313 
314 /** set the global callbacks back to their defaults.
315  *
316  * @warning This function is NOT thread-safe, because it sets global static data
317  * */
319 
320 
321 /** the type of the function used to allocate memory; ryml will only
322  * allocate memory through this callback. */
323 using pfn_allocate = void* (*)(size_t len, void* hint, void *user_data);
324 
325 
326 /** the type of the function used to free memory; ryml will only free
327  * memory through this callback. */
328 using pfn_free = void (*)(void* mem, size_t size, void *user_data);
329 
330 
331 /** the type of the function used to report basic errors.
332  *
333  * @warning Must not return. When implemented by the user, this
334  * function MUST interrupt execution (and ideally be marked with
335  * `[[noreturn]]`). If the function returned, the caller could enter
336  * into an infinite loop, or the program may crash. It is up to the
337  * user to choose the interruption mechanism; typically by either
338  * throwing an exception, or using `std::longjmp()` ([see
339  * documentation](https://en.cppreference.com/w/cpp/utility/program/setjmp))
340  * or ultimately by calling `std::abort()`. */
341 using pfn_error_basic = void (*) (csubstr msg, ErrorDataBasic const& errdata, void *user_data);
342 /** the type of the function used to report parse errors.
343  *
344  * @warning Must not return. When implemented by the user, this
345  * function MUST interrupt execution (and ideally be marked with
346  * `[[noreturn]]`). If the function returned, the caller could enter
347  * into an infinite loop, or the program may crash. It is up to the
348  * user to choose the interruption mechanism; typically by either
349  * throwing an exception, or using `std::longjmp()` ([see
350  * documentation](https://en.cppreference.com/w/cpp/utility/program/setjmp))
351  * or ultimately by calling `std::abort()`. */
352 using pfn_error_parse = void (*) (csubstr msg, ErrorDataParse const& errdata, void *user_data);
353 /** the type of the function used to report visit errors.
354  *
355  * @warning Must not return. When implemented by the user, this
356  * function MUST interrupt execution (and ideally be marked with
357  * `[[noreturn]]`). If the function returned, the caller could enter
358  * into an infinite loop, or the program may crash. It is up to the
359  * user to choose the interruption mechanism; typically by either
360  * throwing an exception, or using `std::longjmp()` ([see
361  * documentation](https://en.cppreference.com/w/cpp/utility/program/setjmp))
362  * or ultimately by calling `std::abort()`. */
363 using pfn_error_visit = void (*) (csubstr msg, ErrorDataVisit const& errdata, void *user_data);
364 
365 /// @cond dev
366 using pfn_error RYML_DEPRECATED("use a more specific error type: `basic`, `parse` or `visit`") = void (*) (const char* msg, size_t msg_len, Location const& cpploc, void *user_data);
367 /// @endcond
368 
369 
370 /** A c-style callbacks class to customize behavior on errors or
371  * allocation. Can be used globally by the library and/or locally by
372  * @ref Tree and @ref Parser objects. */
374 {
375  void * m_user_data; ///< data to be forwarded in every call to a callback
376  pfn_allocate m_allocate; ///< a pointer to an allocate handler function
377  pfn_free m_free; ///< a pointer to a free handler function
378  pfn_error_basic m_error_basic; ///< a pointer to a basic error handler function
379  pfn_error_parse m_error_parse; ///< a pointer to a parse error handler function
380  pfn_error_visit m_error_visit; ///< a pointer to a visit error handler function
381 
382 public:
383 
384  /** Construct an object with the default callbacks. If
385  * @ref RYML_NO_DEFAULT_CALLBACKS is defined, the object will be set with null
386  * members.*/
387  Callbacks() noexcept;
388 
389  RYML_DEPRECATED("use the default constructor, followed by the appropriate setters")
390  Callbacks(void *user_data, pfn_allocate alloc, pfn_free free, pfn_error_basic error_basic);
391 
392 public:
393 
394  /** Set the user data. */
395  Callbacks& set_user_data(void* user_data);
396 
397  /** Set or reset the allocate callback. When the parameter is
398  * null, m_allocate will fall back to ryml's default allocate
399  * implementation, unless @ref RYML_NO_DEFAULT_CALLBACKS is
400  * defined. */
401  Callbacks& set_allocate(pfn_allocate allocate=nullptr);
402 
403  /** Set or reset the free callback. When the parameter is null,
404  * m_free will fall back to ryml's default free implementation,
405  * unless @ref RYML_NO_DEFAULT_CALLBACKS is defined. */
406  Callbacks& set_free(pfn_free free=nullptr);
407 
408  /** Set or reset the error_basic callback. When the parameter is null,
409  * m_error_basic will fall back to ryml's default error_basic implementation,
410  * unless @ref RYML_NO_DEFAULT_CALLBACKS is defined. */
411  Callbacks& set_error_basic(pfn_error_basic error_basic=nullptr);
412 
413  /** Set or reset the error_parse callback. When the parameter is null,
414  * m_error_parse will fall back to ryml's default error_parse implementation,
415  * unless @ref RYML_NO_DEFAULT_CALLBACKS is defined. */
416  Callbacks& set_error_parse(pfn_error_parse error_parse=nullptr);
417 
418  /** Set or reset the error_visit callback. When the parameter is null,
419  * m_error_visit will fall back to ryml's default error_visit implementation,
420  * unless @ref RYML_NO_DEFAULT_CALLBACKS is defined. */
421  Callbacks& set_error_visit(pfn_error_visit error_visit=nullptr);
422 
423 public:
424 
425  bool operator!= (Callbacks const& that) const { return !operator==(that); }
426  bool operator== (Callbacks const& that) const
427  {
428  return (m_user_data == that.m_user_data &&
429  m_allocate == that.m_allocate &&
430  m_free == that.m_free &&
431  m_error_basic == that.m_error_basic &&
432  m_error_parse == that.m_error_parse &&
433  m_error_visit == that.m_error_visit);
434  }
435 };
436 
437 /** @} */
438 
439 
440 //-----------------------------------------------------------------------------
441 //-----------------------------------------------------------------------------
442 //-----------------------------------------------------------------------------
443 
444 /** @cond dev */
445 
446 C4_SUPPRESS_WARNING_PUSH
447 C4_SUPPRESS_WARNING_GCC_CLANG("-Wdeprecated")
448 C4_SUPPRESS_WARNING_GCC_CLANG("-Wdeprecated-declarations")
449 C4_SUPPRESS_WARNING_MSVC(4996) // deprecated
450 
451 /** A tag type to select the key when building the tree, or when
452  * (de)serializing with operator<< or operator>> */
453 template<class K>
454 struct RYML_LEGACY_OPERATOR("prefer .set_key() methods in the Tree and node")
455 Key
456 {
457  K &&k; // NOLINT
458 };
459 
460 /** A tag function to select the key when building the tree, or when
461  * (de)serializing with operator<< or operator>> */
462 template<class K>
463 RYML_LEGACY_OPERATOR("prefer .set_key() methods in the Tree and node")
464 C4_ALWAYS_INLINE Key<K> key(K && k)
465 {
466  return Key<K>{std::forward<K>(k)};
467 }
468 
469 C4_SUPPRESS_WARNING_POP
470 
471 /** @endcond */
472 
473 //-----------------------------------------------------------------------------
474 //-----------------------------------------------------------------------------
475 //-----------------------------------------------------------------------------
476 
477 /// @cond dev
478 
479 #define RYML_CB_ALLOC_HINT_(cb, T, num, hint) (T*) (cb).m_allocate((num) * sizeof(T), (hint), (cb).m_user_data)
480 #define RYML_CB_ALLOC_(cb, T, num) RYML_CB_ALLOC_HINT_((cb), T, (num), nullptr)
481 #define RYML_CB_FREE_(cb, buf, T, num) \
482  do { \
483  (cb).m_free((buf), (num) * sizeof(T), (cb).m_user_data); \
484  (buf) = nullptr; \
485  } while(false)
486 
487 namespace detail {
488 template<int8_t signedval, uint8_t unsignedval>
489 struct _charconstant_t // is there a better way to do this?
490  : public std::conditional<std::is_signed<char>::value,
491  std::integral_constant<int8_t, static_cast<int8_t>(unsignedval)>,
492  std::integral_constant<uint8_t, unsignedval>>::type
493 {};
494 #define RYML_CHCONST_(signedval, unsignedval) ::c4::yml::detail::_charconstant_t<INT8_C(signedval), UINT8_C(unsignedval)>::value
495 } // namespace detail
496 
497 inline csubstr _c4prc(const char &C4_RESTRICT c) // pass by reference!
498 {
499  switch(c)
500  {
501  case '\n': return csubstr("\\n");
502  case '\t': return csubstr("\\t");
503  case '\0': return csubstr("\\0");
504  case '\r': return csubstr("\\r");
505  case '\f': return csubstr("\\f");
506  case '\b': return csubstr("\\b");
507  case '\v': return csubstr("\\v");
508  case '\a': return csubstr("\\a");
509  default: return csubstr(&c, 1);
510  }
511 }
512 
513 #if C4_CPP >= 17 \
514  || (defined(__GNUC__) && __GNUC__ >= 6) \
515  || (defined(_MSC_VER) && !defined(__clang__))
516 #define RYML_HAS_DEPRECATED_ENUMS_
517 #endif
518 
519 /// @endcond
520 
521 C4_SUPPRESS_WARNING_GCC_POP
522 
523 } // namespace yml
524 } // namespace c4
525 
526 #endif /* C4_YML_COMMON_HPP_ */
enum c4::yml::Encoding_ Encoding_e
Location cpploc
location in the C++ source file where the error was detected.
Definition: common.hpp:270
an index to none
Definition: common.hpp:131
size_t offset
number of bytes from the beginning of the source buffer
Definition: common.hpp:230
A lightweight truthy type, used to enable reporting the offending node when a deserializing error hap...
Definition: common.hpp:161
ReadResult(id_type parent_, id_type node_) noexcept
construct as failure on the given parent_, IF node_ is NONE
Definition: common.hpp:181
Location(csubstr n, size_t l, size_t c) noexcept
Definition: common.hpp:242
Location(const char *n, size_t b, size_t l, size_t c) noexcept
Definition: common.hpp:246
#define RYML_ID_TYPE
The type of a node id in the YAML tree.
Definition: common.hpp:117
size_t col
column
Definition: common.hpp:232
Location() noexcept
Definition: common.hpp:237
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
csubstr name
name of the file
Definition: common.hpp:233
A c-style callbacks class to customize behavior on errors or allocation.
Definition: common.hpp:373
ReadResult(id_type node_) noexcept
construct as failure on the given node id
Definition: common.hpp:177
UTF32, Little-Endian.
Definition: common.hpp:147
Location ymlloc
location in the YAML source buffer where the error was detected.
Definition: common.hpp:271
Data for a parse error.
Definition: common.hpp:268
void *(*)(size_t len, void *hint, void *user_data) pfn_allocate
the type of the function used to allocate memory; ryml will only allocate memory through this callbac...
Definition: common.hpp:323
Location cpploc
location in the C++ source file where the error was detected.
Definition: common.hpp:280
Tree const * tree
tree where the error was detected
Definition: common.hpp:281
void(*)(void *mem, size_t size, void *user_data) pfn_free
the type of the function used to free memory; ryml will only free memory through this callback...
Definition: common.hpp:328
read+write string views
UTF16, Big-Endian.
Definition: common.hpp:146
Location(size_t l) noexcept
Definition: common.hpp:238
#define RYML_ERRMSG_SIZE
size for the error message buffer
Definition: common.hpp:45
ReadResult() noexcept
construct as success
Definition: common.hpp:174
Location location
location where the error was detected (may be from YAML or C++ source code)
Definition: common.hpp:261
RYML_ID_TYPE id_type
The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE t...
Definition: common.hpp:124
UTF8.
Definition: common.hpp:144
void(*)(csubstr msg, ErrorDataVisit const &errdata, void *user_data) pfn_error_visit
the type of the function used to report visit errors.
Definition: common.hpp:363
void * m_user_data
data to be forwarded in every call to a callback
Definition: common.hpp:375
UTF32, Big-Endian.
Definition: common.hpp:148
Location(const char *n, size_t l) noexcept
Definition: common.hpp:244
pfn_error_parse m_error_parse
a pointer to a parse error handler function
Definition: common.hpp:379
csubstr to_csubstr(const char(&s)[N]) noexcept
Definition: substr.hpp:2380
a null string position
Definition: common.hpp:138
basic_substring< const char > csubstr
an immutable string view
Definition: substr.hpp:2356
void(*)(csubstr msg, ErrorDataParse const &errdata, void *user_data) pfn_error_parse
the type of the function used to report parse errors.
Definition: common.hpp:352
pfn_free m_free
a pointer to a free handler function
Definition: common.hpp:377
holds a source or yaml file position, for example when an error is detected; See also location_format...
Definition: common.hpp:228
No Byte Order Mark was found.
Definition: common.hpp:143
Data for a visit error.
Definition: common.hpp:278
pfn_error_basic m_error_basic
a pointer to a basic error handler function
Definition: common.hpp:378
Location(size_t l, size_t c) noexcept
Definition: common.hpp:239
UTF16, Little-Endian.
Definition: common.hpp:145
ReadResult(ReadResult result, id_type) noexcept
adapter: will match up-to-date user code (read() implementations returning ReadResult).
Definition: common.hpp:212
#define RYML_LOGBUF_SIZE
size for the buffer used to format individual values to string while preparing an error message...
Definition: common.hpp:55
pfn_error_visit m_error_visit
a pointer to a visit error handler function
Definition: common.hpp:380
void reset_callbacks()
set the global callbacks back to their defaults.
Definition: common.cpp:99
id_type node
node where the error was detected
Definition: common.hpp:282
pfn_allocate m_allocate
a pointer to an allocate handler function
Definition: common.hpp:376
Location(size_t b, size_t l, size_t c) noexcept
Definition: common.hpp:240
Callbacks const & get_callbacks()
get the global callbacks
Definition: common.cpp:94
bool empty() const noexcept
Definition: substr.hpp:356
Location(const char *n, size_t l, size_t c) noexcept
Definition: common.hpp:245
Data for a basic error.
Definition: common.hpp:259
#define RYML_EXPORT
Definition: export.hpp:18
ReadResult(bool ok, id_type node_) noexcept
adapter: will match legacy user code (read() implementations returning bool).
Definition: common.hpp:200
void(*)(csubstr msg, ErrorDataBasic const &errdata, void *user_data) pfn_error_basic
the type of the function used to report basic errors.
Definition: common.hpp:341
Location(csubstr n, size_t l) noexcept
Definition: common.hpp:241
Location(csubstr n, size_t b, size_t l, size_t c) noexcept
Definition: common.hpp:243
bool operator==(const char c, basic_substring< C > const that) noexcept
Definition: substr.hpp:2438
size_t line
line
Definition: common.hpp:231