rapidyaml  0.11.1
parse and emit YAML, and do it fast
common.hpp File Reference

Common utilities and infrastructure used by ryml. More...

#include <cstddef>
#include <c4/substr.hpp>
#include <c4/charconv.hpp>
#include <c4/yml/export.hpp>

Go to the source code of this file.

Classes

struct  c4::yml::Location
 holds a source or yaml file position, for example when an error is detected; See also location_format() and location_format_with_context(). More...
 
struct  c4::yml::ErrorDataBasic
 Data for a basic error. More...
 
struct  c4::yml::ErrorDataParse
 Data for a parse error. More...
 
struct  c4::yml::ErrorDataVisit
 Data for a visit error. More...
 
struct  c4::yml::ParserOptions
 Options to give to the parser to control its behavior. More...
 
struct  c4::yml::Callbacks
 A c-style callbacks class to customize behavior on errors or allocation. More...
 

Namespaces

 c4
 (Undefined by default) Use shorter error message from checks/asserts: do not show the check condition in the error message.
 
 c4::yml
 

Macros

#define RYML_DEFAULT_TREE_CAPACITY   (16)
 default capacity for the tree when not set explicitly More...
 
#define RYML_DEFAULT_TREE_ARENA_CAPACITY   (0)
 default capacity for the tree's arena when not set explicitly More...
 
#define RYML_LOCATIONS_SMALL_THRESHOLD   (30)
 threshold at which a location search will revert from linear to binary search. More...
 
#define RYML_ERRMSG_SIZE   (1024)
 size for the error message buffer More...
 
#define RYML_LOGBUF_SIZE   (256)
 size for the buffer used to format individual values to string while preparing an error message. This is only used for formatting individual values in the message; final messages will be larger than this value (see RYML_ERRMSG_SIZE). This is also used for the detailed debug log messages when RYML_DBG is defined. More...
 
#define RYML_LOGBUF_SIZE_MAX   (1024)
 size for the fallback larger log buffer. When RYML_LOGBUF_SIZE is not large enough to convert a value to string, then temporary stack memory is allocated up to RYML_LOGBUF_SIZE_MAX. This limit is in place to prevent a stack overflow. If the printed value requires more than RYML_LOGBUF_SIZE_MAX, the value is silently skipped. More...
 
#define RYML_USE_ASSERT
 define this macro with a boolean value to enable/disable assertions to check preconditions and assumptions throughout the codebase; this causes a slowdown of the code, and larger code size. More...
 
#define RYML_NO_DEFAULT_CALLBACKS
 (Undefined by default) Define this macro to disable ryml's default implementation of the callback functions. More...
 
#define RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS
 (Undefined by default) When this macro is defined (and RYML_NO_DEFAULT_CALLBACKS is not defined), the default error handler will throw exceptions. More...
 
#define RYML_NOEXCEPT
 Conditionally expands to noexcept when RYML_USE_ASSERT is 0 and is empty otherwise. More...
 
#define RYML_ID_TYPE   size_t
 The type of a node id in the YAML tree. More...
 

Typedefs

using c4::yml::id_type = RYML_ID_TYPE
 The type of a node id in the YAML tree; to override the default type, define the macro RYML_ID_TYPE to a suitable integer type. More...
 
typedef enum c4::yml::Encoding_ c4::yml::Encoding_e
 
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...
 

Enumerations

enum  : id_type { c4::yml::NONE = id_type(-1) }
 
enum  : size_t { c4::yml::npos = size_t(-1) }
 
enum  c4::yml::Encoding_ {
  c4::yml::NOBOM , c4::yml::UTF8 , c4::yml::UTF16LE , c4::yml::UTF16BE ,
  c4::yml::UTF32LE , c4::yml::UTF32BE
}
 

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

Common utilities and infrastructure used by ryml.

Definition in file common.hpp.

Macro Definition Documentation

◆ RYML_DEFAULT_TREE_CAPACITY

#define RYML_DEFAULT_TREE_CAPACITY   (16)

default capacity for the tree when not set explicitly

Definition at line 16 of file common.hpp.

◆ RYML_DEFAULT_TREE_ARENA_CAPACITY

#define RYML_DEFAULT_TREE_ARENA_CAPACITY   (0)

default capacity for the tree's arena when not set explicitly

Definition at line 21 of file common.hpp.

◆ RYML_LOCATIONS_SMALL_THRESHOLD

#define RYML_LOCATIONS_SMALL_THRESHOLD   (30)

threshold at which a location search will revert from linear to binary search.

Definition at line 28 of file common.hpp.

◆ RYML_ERRMSG_SIZE

#define RYML_ERRMSG_SIZE   (1024)

size for the error message buffer

Definition at line 34 of file common.hpp.

◆ RYML_LOGBUF_SIZE

#define RYML_LOGBUF_SIZE   (256)

size for the buffer used to format individual values to string while preparing an error message. This is only used for formatting individual values in the message; final messages will be larger than this value (see RYML_ERRMSG_SIZE). This is also used for the detailed debug log messages when RYML_DBG is defined.

Definition at line 44 of file common.hpp.

◆ RYML_LOGBUF_SIZE_MAX

#define RYML_LOGBUF_SIZE_MAX   (1024)

size for the fallback larger log buffer. When RYML_LOGBUF_SIZE is not large enough to convert a value to string, then temporary stack memory is allocated up to RYML_LOGBUF_SIZE_MAX. This limit is in place to prevent a stack overflow. If the printed value requires more than RYML_LOGBUF_SIZE_MAX, the value is silently skipped.

Definition at line 66 of file common.hpp.

◆ RYML_USE_ASSERT

#define RYML_USE_ASSERT

define this macro with a boolean value to enable/disable assertions to check preconditions and assumptions throughout the codebase; this causes a slowdown of the code, and larger code size.

By default, this macro is defined unless NDEBUG is defined (see C4_USE_ASSERT); as a result, by default this macro is truthy only in debug builds.

Definition at line 179 of file common.hpp.

◆ RYML_NO_DEFAULT_CALLBACKS

#define RYML_NO_DEFAULT_CALLBACKS

(Undefined by default) Define this macro to disable ryml's default implementation of the callback functions.

See Callbacks for errors and allocation.

Definition at line 183 of file common.hpp.

◆ RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS

#define RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS

(Undefined by default) When this macro is defined (and RYML_NO_DEFAULT_CALLBACKS is not defined), the default error handler will throw exceptions.

See Error handling.

Definition at line 188 of file common.hpp.

◆ RYML_NOEXCEPT

#define RYML_NOEXCEPT

Conditionally expands to noexcept when RYML_USE_ASSERT is 0 and is empty otherwise.

The user is unable to override this macro.

Definition at line 192 of file common.hpp.

◆ RYML_ID_TYPE

#define RYML_ID_TYPE   size_t

The type of a node id in the YAML tree.

In the future, the default will likely change to int32_t, which was observed to be faster.

See also
id_type

Definition at line 237 of file common.hpp.