Public Member Functions | Private Attributes | List of all members
sajson::single_allocation Class Reference

#include <sajson.h>

Public Member Functions

 single_allocation ()
 
 single_allocation (size_t *existing_buffer_, size_t size_in_words)
 
template<size_t N>
 single_allocation (size_t(&existing_buffer_)[N])
 

Private Attributes

size_t * existing_buffer
 
size_t existing_buffer_size
 
bool has_existing_buffer
 

Detailed Description

Allocation policy that allocates one large buffer guaranteed to hold the resulting AST. This allocation policy is the fastest since it requires no conditionals to see if more memory must be allocated.

Definition at line 886 of file sajson.h.

Constructor & Destructor Documentation

◆ single_allocation() [1/3]

sajson::single_allocation::single_allocation ( )
inline

Allocate a single worst-case AST buffer with one word per byte in the input document.

Definition at line 1032 of file sajson.h.

◆ single_allocation() [2/3]

sajson::single_allocation::single_allocation ( size_t *  existing_buffer_,
size_t  size_in_words 
)
inline

Write the AST into an existing buffer. Will fail with an out of memory error if the buffer is not guaranteed to be big enough for the document. The caller must guarantee the memory is valid for the duration of the parse and the AST traversal.

Definition at line 1042 of file sajson.h.

◆ single_allocation() [3/3]

template<size_t N>
sajson::single_allocation::single_allocation ( size_t(&)  existing_buffer_[N])
inlineexplicit

Convenience wrapper for single_allocation(size_t*, size_t) that automatically infers the length of a given array.

Definition at line 1051 of file sajson.h.

Member Data Documentation

◆ existing_buffer

size_t* sajson::single_allocation::existing_buffer
private

Definition at line 1080 of file sajson.h.

◆ existing_buffer_size

size_t sajson::single_allocation::existing_buffer_size
private

Definition at line 1081 of file sajson.h.

◆ has_existing_buffer

bool sajson::single_allocation::has_existing_buffer
private

Definition at line 1079 of file sajson.h.


The documentation for this class was generated from the following file:


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:23