rapidyaml  0.10.0
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/dump.hpp>
#include <c4/yml/export.hpp>
#include <alloca.h>

Go to the source code of this file.

Classes

struct  c4::yml::LineCol
 holds a position into a source buffer More...
 
struct  c4::yml::Location
 a source file position More...
 
struct  c4::yml::Callbacks
 a c-style callbacks class. More...
 

Namespaces

 c4
 
 c4::yml
 

Macros

#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_LOCATIONS_SMALL_THRESHOLD   (30)
 threshold at which a location search will revert from linear to binary search. 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; see c4::yml::Callbacks
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 C++ exceptions of type std::runtime_error. 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...
 
using c4::yml::pfn_error = void(*)(const char *msg, size_t msg_len, Location location, void *user_data)
 the type of the function used to report errors More...
 
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...
 

Enumerations

enum  : id_type { c4::yml::NONE = id_type(-1) }
 
enum  : size_t { c4::yml::npos = size_t(-1) }
 
enum  c4::yml::Encoding_e {
  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_ERRMSG_SIZE

#define RYML_ERRMSG_SIZE   (1024)

size for the error message buffer

Definition at line 24 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 33 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 43 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 49 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 154 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 c4::yml::Callbacks

Definition at line 158 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 C++ exceptions of type std::runtime_error.

Definition at line 163 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 167 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 246 of file common.hpp.