rapidyaml 0.15.2
parse and emit YAML, and do it fast
Loading...
Searching...
No Matches
common.hpp File Reference

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

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

Go to the source code of this file.

Classes

struct  c4::yml::ReadResult
 A lightweight truthy type, used to enable reporting the offending node when a deserializing error happens in nested reads. More...
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::Callbacks
 A c-style callbacks class to customize behavior on errors or allocation. More...

Namespaces

namespace  c4
namespace  c4::yml

Macros

#define RYML_DEFAULT_TREE_CAPACITY   (16)
 default capacity for the tree when not set explicitly
#define RYML_DEFAULT_TREE_ARENA_CAPACITY   (0)
 default capacity for the tree's arena when not set explicitly
#define RYML_DEFAULT_TREE_ARENA_CAPACITY_START   (256)
 default starting capacity for the tree's arena when it is first allocated. should be larger than RYML_DEFAULT_TREE_ARENA_CAPACITY
#define RYML_LOCATIONS_SMALL_THRESHOLD   (30)
 threshold at which a location search will revert from linear to binary search.
#define RYML_ERRMSG_SIZE   (1024)
 size for the error message buffer
#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.
#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.
#define RYML_ID_TYPE   size_t
 The type of a node id in the YAML tree.

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.
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.
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.
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.
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.
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.

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).
Callbacks const & c4::yml::get_callbacks ()
 get the global callbacks
void c4::yml::reset_callbacks ()
 set the global callbacks back to their defaults.

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 21 of file common.hpp.

Referenced by c4::yml::Tree::Tree().

◆ 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 26 of file common.hpp.

Referenced by c4::yml::Tree::Tree(), c4::yml::Tree::Tree(), and c4::yml::Tree::reserve_arena().

◆ RYML_DEFAULT_TREE_ARENA_CAPACITY_START

#define RYML_DEFAULT_TREE_ARENA_CAPACITY_START   (256)

default starting capacity for the tree's arena when it is first allocated. should be larger than RYML_DEFAULT_TREE_ARENA_CAPACITY

Definition at line 32 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 39 of file common.hpp.

◆ RYML_ERRMSG_SIZE

#define RYML_ERRMSG_SIZE   (1024)

size for the error message buffer

Definition at line 45 of file common.hpp.

Referenced by c4::yml::err_basic(), c4::yml::err_parse(), and c4::yml::err_visit().

◆ 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 55 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 67 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 117 of file common.hpp.