sajson
High-Performance JSON Parser
Public Member Functions | List of all members
sajson::single_allocation Class Reference

Allocation policy that allocates one large buffer guaranteed to hold the resulting AST. More...

#include <sajson.h>

Public Member Functions

 single_allocation ()
 Allocate a single worst-case AST buffer with one word per byte in the input document. More...
 
 single_allocation (size_t *existing_buffer, size_t size_in_words)
 Write the AST into an existing buffer. More...
 
template<size_t N>
 single_allocation (size_t(&existing_buffer)[N])
 Convenience wrapper for single_allocation(size_t*, size_t) that automatically infers the length of a given array. More...
 

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.

Constructor & Destructor Documentation

sajson::single_allocation::single_allocation ( )
inline

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

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.

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.


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