pjson 2.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. More...

#include <pjson.h>

Public Types

enum  AllocationKind {
  NodeAllocation = 0 , StringAllocation = 1 , ArrayAllocation = 2 , ObjectAllocation = 3 ,
  ImplementationAllocation = 4
}
 Identifies the purpose and matching deallocation contract of storage. More...
 

Public Member Functions

virtual ~Allocator ()
 Enables destruction through an Allocator base pointer.
 
virtual void * allocate (size_t aSize, size_t aAlignment, AllocationKind aKind)=0
 Returns non-null aligned storage or throws; returning null is unsupported.
 
virtual void deallocate (void *aPtr, size_t aSize, size_t aAlignment, AllocationKind aKind) noexcept=0
 Releases a non-null allocation using its original size, alignment, and kind.
 

Detailed Description

Runtime allocator for persistent DOM storage.

Runtime allocation interface for persistent pjson DOM storage.

The allocator is non-owning and must outlive every pjson value that refers to it. Allocation covers pjson child/root nodes, non-null private implementations, and 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.

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, non-null opaque implementation objects, and string/array/object wrapper objects, not their internal standard-library allocations or transient algorithm scratch space.

Definition at line 101 of file pjson.h.

Member Enumeration Documentation

◆ AllocationKind

Identifies the purpose and matching deallocation contract of storage.

Enumerator
NodeAllocation 

Storage for a child or allocator-created root.

StringAllocation 

Storage for a std::string wrapper.

ArrayAllocation 

Storage for an array-container wrapper.

ObjectAllocation 

Storage for an object-container wrapper.

ImplementationAllocation 

Opaque state of one non-null pjson value.

Definition at line 103 of file pjson.h.

Constructor & Destructor Documentation

◆ ~Allocator()

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

Enables destruction through an Allocator base pointer.

Member Function Documentation

◆ allocate()

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

Returns non-null aligned storage or throws; returning null is unsupported.

◆ deallocate()

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

Releases a non-null allocation using its original size, alignment, and kind.


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