pjson 1.0.0
A small, owning JSON value for C++11
Loading...
Searching...
No Matches
ByteDance::pjson::Allocator Struct Referenceabstract

Runtime allocator for persistent DOM storage. The allocator is non-owning and must outlive every pjson value that refers to it. Allocation covers pjson child/root nodes plus the std::string, array, and object wrapper objects. Storage used internally by those standard-library objects and transient parser/algorithm scratch space continues to use the standard allocator. More...

#include <pjson.h>

Public Types

enum  AllocationKind { NodeAllocation , StringAllocation , ArrayAllocation , ObjectAllocation }
 Selects one of the public JSON policies. More...
 

Public Member Functions

virtual ~Allocator ()
 Public API member ~Allocator; see the API overview for its contract. / Returns non-null aligned storage or throws; returning null is unsupported.
 
virtual voidallocate (size_t aSize, size_t aAlignment, AllocationKind aKind)=0
 Public API member allocate; see the API overview for its contract. / Releases a non-null allocation using its original size, alignment, and kind.
 
virtual void deallocate (void *aPtr, size_t aSize, size_t aAlignment, AllocationKind aKind) noexcept=0
 Public API member member; see the API overview for its contract.
 

Detailed Description

Runtime allocator for persistent DOM storage. The allocator is non-owning and must outlive every pjson value that refers to it. Allocation covers pjson child/root nodes plus the std::string, array, and object wrapper objects. Storage used internally by those standard-library objects and transient parser/algorithm scratch space continues to use the standard allocator.

Runtime allocation interface for persistent pjson DOM storage.

The allocator is borrowed and must outlive every bound value. allocate() must return non-null storage honoring the requested size and alignment or throw; deallocate() receives matching metadata and must not throw. The interface covers pjson nodes and string/array/object wrapper objects, not their internal standard-library allocations or transient algorithm scratch space.

Definition at line 83 of file pjson.h.

Member Enumeration Documentation

◆ AllocationKind

Selects one of the public JSON policies.

Enumerator
NodeAllocation 

JSON value or policy constant.

StringAllocation 

JSON value or policy constant.

ArrayAllocation 

JSON value or policy constant.

ObjectAllocation 

JSON value or policy constant.

Definition at line 85 of file pjson.h.

Constructor & Destructor Documentation

◆ ~Allocator()

virtual ByteDance::pjson::Allocator::~Allocator ( )
virtual

Public API member ~Allocator; see the API overview for its contract. / Returns non-null aligned storage or throws; returning null is unsupported.

Member Function Documentation

◆ allocate()

virtual void * ByteDance::pjson::Allocator::allocate ( size_t  aSize,
size_t  aAlignment,
AllocationKind  aKind 
)
pure virtual

Public API member allocate; see the API overview for its contract. / Releases a non-null allocation using its original size, alignment, and kind.

◆ deallocate()

virtual void ByteDance::pjson::Allocator::deallocate ( void aPtr,
size_t  aSize,
size_t  aAlignment,
AllocationKind  aKind 
)
pure virtualnoexcept

Public API member member; see the API overview for its contract.


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