|
pjson 2.0.0
A small, owning JSON value for C++11
|
Owning, mutable JSON value with deep-copy semantics. More...
#include <pjson.h>
Classes | |
| struct | Allocator |
| Runtime allocator for persistent DOM storage. More... | |
| struct | PatchError |
| Structured JSON Patch (RFC 6902) / Merge Patch (RFC 7396) failure. More... | |
| struct | PatchOptions |
| Bounds transactional patch amplification. More... | |
| struct | PointerError |
| Structured JSON Pointer (RFC 6901) lookup failure. More... | |
| struct | SerializeError |
| Structured outcome for the non-throwing serialization APIs. More... | |
| struct | SerializeOptions |
| Controls JSON serialization. More... | |
| class | StringView |
| Minimal C++11-compatible, non-owning view of a JSON string. More... | |
Public Types | |
| enum | jsonType : int64_t { jsonNull = 0 , jsonString , jsonNumberInt , jsonNumberDouble , jsonBoolean , jsonArray , jsonObject , jsonNumberUInt } |
| JSON value kind. More... | |
| typedef bool(* | ConstMemberVisitor) (StringView aKey, const pjson &aValue, void *aContext) |
| Callback for read-only object-member traversal. | |
| typedef bool(* | MemberVisitor) (StringView aKey, pjson &aValue, void *aContext) |
| Callback for mutable object-member traversal. | |
| typedef bool(* | ConstElementVisitor) (const pjson &aValue, void *aContext) |
| Callback for read-only array-element traversal. | |
| typedef bool(* | ElementVisitor) (pjson &aValue, void *aContext) |
| Callback for mutable array-element traversal. | |
Public Member Functions | |
| pjson () noexcept | |
| Constructs null using the process-lifetime default allocator. | |
| pjson (Allocator &aAlloc) noexcept | |
| Constructs null bound to borrowed aAlloc, which must outlive this tree. | |
| ~pjson () | |
| Destroys this value and its complete owned subtree. | |
| pjson (const pjson &aFrom) | |
| Deep-copies aFrom using aFrom's borrowed allocator. | |
| pjson (const pjson &aFrom, Allocator &aAlloc) | |
| Deep-copies aFrom into borrowed aAlloc. | |
| pjson (pjson &&aFrom) noexcept | |
| Transfers aFrom's storage and allocator in O(1), leaving aFrom null. | |
| pjson (pjson &&aFrom, Allocator &aAlloc) | |
| Transfers in O(1) when allocators match; otherwise deep-copies then clears aFrom. | |
| pjson & | operator= (const pjson &aFrom) |
| Deep-copies aFrom while preserving this value's allocator. | |
| pjson & | operator= (pjson &&aFrom) |
| Moves aFrom while preserving this allocator; cross-allocator moves may allocate. | |
| void | copyFrom (const pjson &aFrom) |
| Deep-copies aFrom while preserving this value's allocator. | |
| void | reset () |
| Destroys the current contents and becomes null. | |
| void | resetTo (jsonType aeType) |
| Replaces the value with the empty/default value of a valid jsonType. | |
| void | resetIfNeeded (jsonType aeType) |
| Calls resetTo() only when the type differs, otherwise preserving contents. | |
| void | swap (pjson &aOther) noexcept |
| Exchanges compatible, non-overlapping contents; otherwise does nothing. | |
| Allocator & | getAllocator () const noexcept |
| Returns the borrowed allocator bound to this value. | |
| bool | canSwap (const pjson &aOther) const noexcept |
| Returns whether swap(aOther) can exchange contents safely. | |
| std::string | toString () const |
| Returns compact JSON using the default serialization options. | |
| std::string | toString (const SerializeOptions &aOpts) const |
| Returns JSON serialized according to aOpts. | |
| bool | toString (std::string &aOut, SerializeError &aError, const SerializeOptions &aOpts=SerializeOptions()) const noexcept |
| Serializes into aOut transactionally and reports failure without throwing. | |
| void | write (std::ostream &aOut) const |
| Writes compact JSON to aOut using the default serialization options. | |
| void | write (std::ostream &aOut, const SerializeOptions &aOpts) const |
| Writes JSON configured by aOpts to aOut. | |
| bool | write (std::ostream &aOut, SerializeError &aError, const SerializeOptions &aOpts=SerializeOptions()) const noexcept |
| Writes JSON and reports logical or physical failure without throwing. | |
| jsonType | getType () const |
| Returns this node's stored JSON representation. | |
| bool | isNull () const |
| Returns whether this node is null. | |
| bool | isString () const |
| Returns whether this node stores a string. | |
| bool | isNumber () const |
| Returns whether this node stores any numeric representation. | |
| bool | isInt () const |
| Returns whether this node stores a signed-integer representation. | |
| bool | isUInt () const |
| Returns whether this node stores an unsigned-integer representation. | |
| bool | isInteger () const |
| Returns whether this node stores any integer representation (signed or unsigned). | |
| bool | isDouble () const |
| Returns whether this node stores a floating-point representation. | |
| bool | isBool () const |
| Returns whether this node stores a boolean. | |
| bool | isArray () const |
| Returns whether this node stores an array. | |
| bool | isObject () const |
| Returns whether this node stores an object. | |
| bool | tryGet (int64_t &aResult) const noexcept |
| Extracts a signed integer; an unsigned value must fit in int64_t. | |
| bool | tryGet (uint64_t &aResult) const noexcept |
| Extracts an unsigned integer; a signed value must be non-negative. | |
| bool | tryGet (double &aResult) const noexcept |
| Extracts a numeric value, widening a stored integer when necessary. | |
| bool | tryGet (bool &aResult) const noexcept |
| Extracts a boolean only when this node stores jsonBoolean. | |
| bool | tryGet (std::string &aResult) const |
| Copies a string only when this node stores jsonString. | |
| bool | tryGet (StringView &aResult) const noexcept |
| Borrows a string view only when this node stores jsonString. | |
| size_t | size () const |
| Returns the element/member count for containers, or zero for scalars. | |
| bool | empty () const |
| Returns whether size() is zero; consequently all scalar values are empty. | |
| void | clear () |
| Empties a container without changing its type, or resets a scalar to null. | |
| std::vector< std::string > | keys () const |
| Returns copied object keys in unspecified storage order, or an empty vector otherwise. | |
| bool | forEachMember (ConstMemberVisitor aVisitor, void *aContext) const |
| Traversal copies no object names and performs no per-member lookup. Object members are visited in unspecified storage order and array elements in index order. Borrowed arguments are valid only for the callback. The opaque context is forwarded unchanged. Returning false stops early. A callback must not resize the traversed container. Calling a traversal method on the wrong container type is a no-op that returns true. Visits each object member as (key view, const value); false stops early. | |
| bool | forEachMember (MemberVisitor aVisitor, void *aContext) |
| Visits each object member as (key view, mutable value); false stops early. | |
| bool | forEachElement (ConstElementVisitor aVisitor, void *aContext) const |
| Visits each array element as a const value; false stops early. | |
| bool | forEachElement (ElementVisitor aVisitor, void *aContext) |
| Visits each array element as a mutable value; false stops early. | |
| bool | hasKey (const std::string &aKey) const |
| Returns whether this object contains aKey. | |
| bool | hasKey (const char *aKey) const |
| Returns whether this object contains non-null aKey; null returns false. | |
| bool | contains (const std::string &aKey) const |
| Alias for hasKey(aKey); reads more naturally at call sites. | |
| bool | contains (const char *aKey) const |
| Alias for hasKey(aKey); reads more naturally at call sites. | |
| bool | hasIndex (int aIndex) const noexcept |
| Returns whether this array contains aIndex; negative indexes count from the end. | |
| pjson * | find (const std::string &aKey) |
| Returns the borrowed child at aKey, or null when absent or not an object. | |
| pjson * | find (const char *aKey) |
| Returns the borrowed child at non-null aKey, or null on failure. | |
| const pjson * | find (const std::string &aKey) const |
| Returns the read-only borrowed child at aKey, or null on failure. | |
| const pjson * | find (const char *aKey) const |
| Returns the read-only borrowed child at non-null aKey, or null on failure. | |
| pjson * | find (int aIndex) noexcept |
| Returns the borrowed array child at aIndex, or null on failure. | |
| const pjson * | find (int aIndex) const noexcept |
| Returns the read-only borrowed array child at aIndex, or null on failure. | |
| pjson * | findIndex (size_t aIndex) noexcept |
| Returns the borrowed array child at a non-negative index, or null on failure. | |
| const pjson * | findIndex (size_t aIndex) const noexcept |
| Returns the read-only borrowed array child at a non-negative index, or null. | |
| pjson * | findPointer (const std::string &aPointer) |
| Resolves aPointer and returns the borrowed target, or null on failure. | |
| const pjson * | findPointer (const std::string &aPointer) const |
| Resolves aPointer and returns the read-only borrowed target, or null. | |
| pjson * | findPointer (const std::string &aPointer, PointerError &aError) |
| Resolves aPointer and reports lookup failure in aError. | |
| const pjson * | findPointer (const std::string &aPointer, PointerError &aError) const |
| Resolves aPointer read-only and reports lookup failure in aError. | |
| pjson * | findPointer (const char *aPointer) |
| Resolves a non-null pointer string; null returns failure. | |
| const pjson * | findPointer (const char *aPointer) const |
| Resolves a non-null pointer string read-only; null returns failure. | |
| pjson * | findPointer (const char *aPointer, PointerError &aError) |
| Resolves a non-null pointer string and reports failure in aError. | |
| const pjson * | findPointer (const char *aPointer, PointerError &aError) const |
| Resolves a non-null pointer string read-only and reports failure in aError. | |
| bool | tryGet (const std::string &aKey, int64_t &aResult) const |
| Extracts the integer child at aKey without mutating this object. | |
| bool | tryGet (const std::string &aKey, uint64_t &aResult) const |
| Extracts the unsigned-integer child at aKey without mutating this object. | |
| bool | tryGet (const std::string &aKey, double &aResult) const |
| Extracts the numeric child at aKey as a double. | |
| bool | tryGet (const std::string &aKey, bool &aResult) const |
| Extracts the boolean child at aKey. | |
| bool | tryGet (const std::string &aKey, std::string &aResult) const |
| Copies the string child at aKey. | |
| bool | tryGet (const std::string &aKey, StringView &aResult) const |
| Borrows a view of the string child at aKey. | |
| bool | tryGet (const char *aKey, int64_t &aResult) const |
| Extracts the integer child at non-null aKey. | |
| bool | tryGet (const char *aKey, uint64_t &aResult) const |
| Extracts the unsigned-integer child at non-null aKey. | |
| bool | tryGet (const char *aKey, double &aResult) const |
| Extracts the numeric child at non-null aKey as a double. | |
| bool | tryGet (const char *aKey, bool &aResult) const |
| Extracts the boolean child at non-null aKey. | |
| bool | tryGet (const char *aKey, std::string &aResult) const |
| Copies the string child at non-null aKey. | |
| bool | tryGet (const char *aKey, StringView &aResult) const |
| Borrows a view of the string child at non-null aKey. | |
| bool | tryGet (int aIndex, int64_t &aResult) const noexcept |
| Extracts the integer array child at aIndex. | |
| bool | tryGet (int aIndex, uint64_t &aResult) const noexcept |
| Extracts the unsigned-integer array child at aIndex. | |
| bool | tryGet (int aIndex, double &aResult) const noexcept |
| Extracts the numeric array child at aIndex as a double. | |
| bool | tryGet (int aIndex, bool &aResult) const noexcept |
| Extracts the boolean array child at aIndex. | |
| bool | tryGet (int aIndex, std::string &aResult) const |
| Copies the string array child at aIndex. | |
| bool | tryGet (int aIndex, StringView &aResult) const noexcept |
| Borrows a view of the string array child at aIndex. | |
| pjson & | operator[] (const std::string &aString) |
| Returns or creates the child at aString. | |
| pjson & | operator[] (const char *aSkey) |
| Returns or creates the child at aSkey; throws std::invalid_argument for null. | |
| pjson & | operator[] (int index) |
| Returns or creates the child at index under the auto-growth rules above. | |
| pjson & | operator[] (size_t index) |
| Returns or creates the child at a non-negative index. | |
| pjson & | operator= (std::nullptr_t) |
| Replaces this value with JSON null (std::nullptr_t assignment). | |
| pjson & | at (const std::string &aKey) |
| Returns the existing child at aKey or throws std::out_of_range. | |
| const pjson & | at (const std::string &aKey) const |
| Returns the read-only child at aKey or throws std::out_of_range. | |
| pjson & | at (size_t aIndex) |
| Returns the existing element at aIndex or throws std::out_of_range. | |
| const pjson & | at (size_t aIndex) const |
| Returns the read-only element at aIndex or throws std::out_of_range. | |
| pjson & | pushBack (const pjson &aValue) |
| Appends a deep copy of aValue, promoting this node to an array. | |
| pjson & | pushBack (pjson &&aValue) |
| Moves an independent same-allocator value; otherwise deep-copies it. | |
| pjson & | insertOrAssign (const std::string &aKey, const pjson &aValue) |
| Inserts or replaces the member aKey with a deep copy of aValue. | |
| pjson & | insertOrAssign (const std::string &aKey, pjson &&aValue) |
| Moves an independent same-allocator value; otherwise deep-copies it. | |
| pjson & | reserve (size_t aCount) |
| Reserves capacity for at least aCount array elements (no-op for non-arrays unless this node is first made an array); returns *this for chaining. | |
| pjson & | operator= (const std::string &aString) |
| Replaces this value with a copy of aString. | |
| pjson & | operator= (const char *aCString) |
| Replaces this value with aCString; throws std::invalid_argument for null. | |
| pjson & | operator= (const bool aBool) |
| Replaces this value with aBool. | |
| pjson & | operator= (const int aInt) |
| Replaces this value with a signed integer. | |
| pjson & | operator= (const unsigned int aUInt) |
| Replaces this value with an unsigned integer. | |
| pjson & | operator= (const short aInt) |
| Replaces this value with a signed short integer. | |
| pjson & | operator= (const unsigned short aUInt) |
| Replaces this value with an unsigned short integer. | |
| pjson & | operator= (const long aInt) |
| Replaces this value with a signed long integer. | |
| pjson & | operator= (const unsigned long aUInt) |
| Replaces this value with an unsigned long integer. | |
| pjson & | operator= (const long long aInt) |
| Replaces this value with a signed long-long integer. | |
| pjson & | operator= (const unsigned long long aUInt) |
| Replaces this value with an unsigned long-long integer. | |
| pjson & | operator= (const float aFloat) |
| Replaces this value with a floating-point number. | |
| pjson & | operator= (const double aDouble) |
| Replaces this value with aDouble; the non-finite policy governs output. | |
| pjson & | operator= (const long double aDouble) |
| Narrows a long double to the library's binary64 number representation. | |
| pjson & | operator= (const std::vector< std::string > &aValueArray) |
| Replaces this value with a copied string array. | |
| pjson & | operator= (const std::vector< bool > &aValueArray) |
| Replaces this value with a copied boolean array. | |
| pjson & | operator= (const std::vector< int > &aValueArray) |
| Replaces this value with a copied native-integer array. | |
| pjson & | operator= (const std::vector< unsigned int > &aValueArray) |
| Replaces this value with a copied native unsigned-integer array. | |
| pjson & | operator= (const std::vector< short > &aValueArray) |
| Replaces this value with a copied signed-short array. | |
| pjson & | operator= (const std::vector< unsigned short > &aValueArray) |
| Replaces this value with a copied unsigned-short array. | |
| pjson & | operator= (const std::vector< long > &aValueArray) |
| Replaces this value with a copied signed-long array. | |
| pjson & | operator= (const std::vector< unsigned long > &aValueArray) |
| Replaces this value with a copied unsigned-long array. | |
| pjson & | operator= (const std::vector< long long > &aValueArray) |
| Replaces this value with a copied signed-long-long array. | |
| pjson & | operator= (const std::vector< unsigned long long > &aValueArray) |
| Replaces this value with a copied unsigned-long-long array. | |
| pjson & | operator= (const std::vector< float > &aValueArray) |
| Replaces this value with a copied float array. | |
| pjson & | operator= (const std::vector< double > &aValueArray) |
| Replaces this value with a copied double array. | |
| pjson & | operator= (const std::vector< long double > &aValueArray) |
| Replaces this value with a copied long-double array, narrowing each value to double. | |
| pjson & | operator+= (const std::string &aValue) |
| Appends a copy of aValue as a string child. | |
| pjson & | operator+= (const char *aValue) |
| Appends aValue as a string child; throws std::invalid_argument for null. | |
| pjson & | operator+= (const bool aValue) |
| Appends aValue as a boolean child. | |
| pjson & | operator+= (const int aValue) |
| Appends aValue as a signed integer child. | |
| pjson & | operator+= (const unsigned int aValue) |
| Appends aValue as an unsigned integer child. | |
| pjson & | operator+= (const short aValue) |
| Appends aValue as a signed-short child. | |
| pjson & | operator+= (const unsigned short aValue) |
| Appends aValue as an unsigned-short child. | |
| pjson & | operator+= (const long aValue) |
| Appends aValue as a signed-long child. | |
| pjson & | operator+= (const unsigned long aValue) |
| Appends aValue as an unsigned-long child. | |
| pjson & | operator+= (const long long aValue) |
| Appends aValue as a signed-long-long child. | |
| pjson & | operator+= (const unsigned long long aValue) |
| Appends aValue as an unsigned-long-long child. | |
| pjson & | operator+= (const float aValue) |
| Appends aValue as a floating-point child. | |
| pjson & | operator+= (const double aValue) |
| Appends aValue as a double child. | |
| pjson & | operator+= (const long double aValue) |
| Narrows aValue to the library's binary64 number representation and appends it. | |
| pjson & | operator+= (const std::vector< std::string > &aValueArray) |
| Appends every string in aValueArray. | |
| pjson & | operator+= (const std::vector< bool > &aValueArray) |
| Appends every boolean in aValueArray. | |
| pjson & | operator+= (const std::vector< int > &aValueArray) |
| Appends every native integer in aValueArray. | |
| pjson & | operator+= (const std::vector< unsigned int > &aValueArray) |
| Appends every native unsigned integer in aValueArray. | |
| pjson & | operator+= (const std::vector< short > &aValueArray) |
| Appends every signed short in aValueArray. | |
| pjson & | operator+= (const std::vector< unsigned short > &aValueArray) |
| Appends every unsigned short in aValueArray. | |
| pjson & | operator+= (const std::vector< long > &aValueArray) |
| Appends every signed long in aValueArray. | |
| pjson & | operator+= (const std::vector< unsigned long > &aValueArray) |
| Appends every unsigned long in aValueArray. | |
| pjson & | operator+= (const std::vector< long long > &aValueArray) |
| Appends every signed long long in aValueArray. | |
| pjson & | operator+= (const std::vector< unsigned long long > &aValueArray) |
| Appends every unsigned long long in aValueArray. | |
| pjson & | operator+= (const std::vector< float > &aValueArray) |
| Appends every float in aValueArray. | |
| pjson & | operator+= (const std::vector< double > &aValueArray) |
| Appends every double in aValueArray. | |
| pjson & | operator+= (const std::vector< long double > &aValueArray) |
| Narrows and appends every long double in aValueArray. | |
| bool | erase (const std::string &aKey) |
| Erases aKey and returns whether an object member was removed. | |
| bool | erase (const char *aKey) |
| Erases non-null aKey; null or a non-object returns false. | |
| bool | erase (size_t aIndex) |
| Erases aIndex and returns whether an array element was removed. | |
| bool | applyPatch (const pjson &aPatch, const PatchOptions &aOpts=PatchOptions()) noexcept |
| Atomically applies an RFC 6902 patch document. | |
| bool | applyPatch (const pjson &aPatch, PatchError &aError, const PatchOptions &aOpts=PatchOptions()) noexcept |
| Atomically applies RFC 6902 and reports failure details in aError. | |
| bool | applyMergePatch (const pjson &aPatch, const PatchOptions &aOpts=PatchOptions()) noexcept |
| Atomically applies an RFC 7396 Merge Patch document. | |
| bool | applyMergePatch (const pjson &aPatch, PatchError &aError, const PatchOptions &aOpts=PatchOptions()) noexcept |
| Atomically applies RFC 7396 and reports failure details in aError. | |
| bool | operator== (const pjson &aOther) const |
| Returns whether this value and aOther are structurally equal. | |
| bool | operator!= (const pjson &aOther) const |
| Returns the negation of operator==. | |
| bool | tryCompareNumber (const pjson &aOther, int &aOrder) const noexcept |
| Compares two stored numbers exactly; false when non-numeric/unordered. | |
Static Public Member Functions | |
| static const char * | getVersion () |
| Returns the process-lifetime semantic-version string for this library. | |
| static std::string | escapePointerToken (const std::string &aToken) |
| Escapes one decoded reference token for inclusion in a JSON Pointer. | |
| static pjson | null () |
| Returns a JSON null value. | |
| static pjson | object () |
| Returns an empty JSON object value. | |
| static pjson | array () |
| Returns an empty JSON array value. | |
Owning, mutable JSON value with deep-copy semantics.
An owning, mutable value that represents every JSON type.
Child pointers and string views exposed by lookup/access APIs are borrowed from the owning tree. They become invalid when the child or an ancestor is destroyed, replaced, reset, erased, moved, swapped, cleared, or successfully patched. Unless an operation is noexcept or explicitly reports failures, allocation and standard-library exceptions may escape.
A pjson owns its complete subtree. Copies are deep, and pointers returned by find() or findPointer(), along with string views returned by tryGet(), remain borrowed from their owning tree. Parsing is provided by the independent ByteDance::pJsonParser class rather than by pjson members.
Every value is bound to a runtime allocator. Default construction uses the built-in allocator; allocator-aware construction and pJsonParser use a borrowed pjson::Allocator that must outlive the complete tree. Copy and move assignment preserve the destination allocator. Storage transfer and swap are O(1) only between values with the same allocator; use canSwap() when allocator provenance may differ. Every pJsonParser DOM operation returns the parsed document by value, bound to the chosen allocator and freed on destruction; pass a pJsonParser::Error to distinguish failure from a successfully parsed literal null.
operator[] is the auto-vivifying builder API. For observation without mutation, use find(), findIndex(), findPointer(), hasKey(), hasIndex(), at(), contains(), forEachMember()/forEachElement(), or tryGet(). tryGet() requires the requested stored type and leaves its output unchanged on failure; integer-to-double widening and exact signed/unsigned integer reads are permitted. Containers expose query and child-lookup operations rather than their raw storage types.
getType() distinguishes jsonNumberInt, jsonNumberUInt, and jsonNumberDouble and reports objects as jsonObject. Numeric assignment and append overloads accept the standard non-character integral and floating-point types. Configure serialization through SerializeOptions; the compact toString() and write() overloads take no formatting boolean, and SerializeOptions::maxOutputBytes bounds generated output. A stored non-finite double fails serialization by default; select an explicit SerializeOptions::NonFinitePolicy to map it. PatchOptions bounds transactional JSON Patch and Merge Patch amplification. Invalid UTF-8 and logical output-size failures are detected before write() emits bytes.
| typedef bool(* ByteDance::pjson::ConstElementVisitor) (const pjson &aValue, void *aContext) |
| typedef bool(* ByteDance::pjson::ConstMemberVisitor) (StringView aKey, const pjson &aValue, void *aContext) |
| typedef bool(* ByteDance::pjson::ElementVisitor) (pjson &aValue, void *aContext) |
| typedef bool(* ByteDance::pjson::MemberVisitor) (StringView aKey, pjson &aValue, void *aContext) |
| enum ByteDance::pjson::jsonType : int64_t |
JSON value kind.
Numbers are stored in one of three representations: signed whole numbers as a 64-bit signed integer (jsonNumberInt), explicitly unsigned whole numbers as a 64-bit unsigned integer (jsonNumberUInt), and fractional/exponent values as a double (jsonNumberDouble).
|
noexcept |
Constructs null using the process-lifetime default allocator.
|
explicitnoexcept |
Constructs null bound to borrowed aAlloc, which must outlive this tree.
| ByteDance::pjson::~pjson | ( | ) |
Destroys this value and its complete owned subtree.
| ByteDance::pjson::pjson | ( | const pjson & | aFrom | ) |
Deep-copies aFrom using aFrom's borrowed allocator.
Deep-copies aFrom into borrowed aAlloc.
|
noexcept |
Transfers aFrom's storage and allocator in O(1), leaving aFrom null.
Transfers in O(1) when allocators match; otherwise deep-copies then clears aFrom.
|
noexcept |
Atomically applies an RFC 7396 Merge Patch document.
|
noexcept |
Atomically applies RFC 7396 and reports failure details in aError.
|
noexcept |
Atomically applies an RFC 6902 patch document.
|
noexcept |
Atomically applies RFC 6902 and reports failure details in aError.
|
static |
Returns an empty JSON array value.
| pjson & ByteDance::pjson::at | ( | const std::string & | aKey | ) |
Returns the existing child at aKey or throws std::out_of_range.
| const pjson & ByteDance::pjson::at | ( | const std::string & | aKey | ) | const |
Returns the read-only child at aKey or throws std::out_of_range.
| pjson & ByteDance::pjson::at | ( | size_t | aIndex | ) |
Returns the existing element at aIndex or throws std::out_of_range.
| const pjson & ByteDance::pjson::at | ( | size_t | aIndex | ) | const |
Returns the read-only element at aIndex or throws std::out_of_range.
|
noexcept |
Returns whether swap(aOther) can exchange contents safely.
| void ByteDance::pjson::clear | ( | ) |
Empties a container without changing its type, or resets a scalar to null.
| bool ByteDance::pjson::contains | ( | const char * | aKey | ) | const |
Alias for hasKey(aKey); reads more naturally at call sites.
| bool ByteDance::pjson::contains | ( | const std::string & | aKey | ) | const |
Alias for hasKey(aKey); reads more naturally at call sites.
| void ByteDance::pjson::copyFrom | ( | const pjson & | aFrom | ) |
Deep-copies aFrom while preserving this value's allocator.
| bool ByteDance::pjson::empty | ( | ) | const |
Returns whether size() is zero; consequently all scalar values are empty.
| bool ByteDance::pjson::erase | ( | const char * | aKey | ) |
Erases non-null aKey; null or a non-object returns false.
| bool ByteDance::pjson::erase | ( | const std::string & | aKey | ) |
Erases aKey and returns whether an object member was removed.
| bool ByteDance::pjson::erase | ( | size_t | aIndex | ) |
Erases aIndex and returns whether an array element was removed.
|
static |
Escapes one decoded reference token for inclusion in a JSON Pointer.
| pjson * ByteDance::pjson::find | ( | const char * | aKey | ) |
Returns the borrowed child at non-null aKey, or null on failure.
| const pjson * ByteDance::pjson::find | ( | const char * | aKey | ) | const |
Returns the read-only borrowed child at non-null aKey, or null on failure.
| pjson * ByteDance::pjson::find | ( | const std::string & | aKey | ) |
Returns the borrowed child at aKey, or null when absent or not an object.
| const pjson * ByteDance::pjson::find | ( | const std::string & | aKey | ) | const |
Returns the read-only borrowed child at aKey, or null on failure.
|
noexcept |
Returns the read-only borrowed array child at aIndex, or null on failure.
|
noexcept |
Returns the borrowed array child at aIndex, or null on failure.
|
noexcept |
Returns the read-only borrowed array child at a non-negative index, or null.
|
noexcept |
Returns the borrowed array child at a non-negative index, or null on failure.
| pjson * ByteDance::pjson::findPointer | ( | const char * | aPointer | ) |
Resolves a non-null pointer string; null returns failure.
| const pjson * ByteDance::pjson::findPointer | ( | const char * | aPointer | ) | const |
Resolves a non-null pointer string read-only; null returns failure.
| pjson * ByteDance::pjson::findPointer | ( | const char * | aPointer, |
| PointerError & | aError | ||
| ) |
Resolves a non-null pointer string and reports failure in aError.
| const pjson * ByteDance::pjson::findPointer | ( | const char * | aPointer, |
| PointerError & | aError | ||
| ) | const |
Resolves a non-null pointer string read-only and reports failure in aError.
| pjson * ByteDance::pjson::findPointer | ( | const std::string & | aPointer | ) |
Resolves aPointer and returns the borrowed target, or null on failure.
| const pjson * ByteDance::pjson::findPointer | ( | const std::string & | aPointer | ) | const |
Resolves aPointer and returns the read-only borrowed target, or null.
| pjson * ByteDance::pjson::findPointer | ( | const std::string & | aPointer, |
| PointerError & | aError | ||
| ) |
Resolves aPointer and reports lookup failure in aError.
| const pjson * ByteDance::pjson::findPointer | ( | const std::string & | aPointer, |
| PointerError & | aError | ||
| ) | const |
Resolves aPointer read-only and reports lookup failure in aError.
| bool ByteDance::pjson::forEachElement | ( | ConstElementVisitor | aVisitor, |
| void * | aContext | ||
| ) | const |
Visits each array element as a const value; false stops early.
| bool ByteDance::pjson::forEachElement | ( | ElementVisitor | aVisitor, |
| void * | aContext | ||
| ) |
Visits each array element as a mutable value; false stops early.
| bool ByteDance::pjson::forEachMember | ( | ConstMemberVisitor | aVisitor, |
| void * | aContext | ||
| ) | const |
Traversal copies no object names and performs no per-member lookup. Object members are visited in unspecified storage order and array elements in index order. Borrowed arguments are valid only for the callback. The opaque context is forwarded unchanged. Returning false stops early. A callback must not resize the traversed container. Calling a traversal method on the wrong container type is a no-op that returns true. Visits each object member as (key view, const value); false stops early.
| bool ByteDance::pjson::forEachMember | ( | MemberVisitor | aVisitor, |
| void * | aContext | ||
| ) |
Visits each object member as (key view, mutable value); false stops early.
|
noexcept |
Returns the borrowed allocator bound to this value.
| jsonType ByteDance::pjson::getType | ( | ) | const |
Returns this node's stored JSON representation.
|
static |
Returns the process-lifetime semantic-version string for this library.
|
noexcept |
Returns whether this array contains aIndex; negative indexes count from the end.
| bool ByteDance::pjson::hasKey | ( | const char * | aKey | ) | const |
Returns whether this object contains non-null aKey; null returns false.
| bool ByteDance::pjson::hasKey | ( | const std::string & | aKey | ) | const |
Returns whether this object contains aKey.
Inserts or replaces the member aKey with a deep copy of aValue.
Moves an independent same-allocator value; otherwise deep-copies it.
| bool ByteDance::pjson::isArray | ( | ) | const |
Returns whether this node stores an array.
| bool ByteDance::pjson::isBool | ( | ) | const |
Returns whether this node stores a boolean.
| bool ByteDance::pjson::isDouble | ( | ) | const |
Returns whether this node stores a floating-point representation.
| bool ByteDance::pjson::isInt | ( | ) | const |
Returns whether this node stores a signed-integer representation.
| bool ByteDance::pjson::isInteger | ( | ) | const |
Returns whether this node stores any integer representation (signed or unsigned).
| bool ByteDance::pjson::isNull | ( | ) | const |
Returns whether this node is null.
| bool ByteDance::pjson::isNumber | ( | ) | const |
Returns whether this node stores any numeric representation.
| bool ByteDance::pjson::isObject | ( | ) | const |
Returns whether this node stores an object.
| bool ByteDance::pjson::isString | ( | ) | const |
Returns whether this node stores a string.
| bool ByteDance::pjson::isUInt | ( | ) | const |
Returns whether this node stores an unsigned-integer representation.
| std::vector< std::string > ByteDance::pjson::keys | ( | ) | const |
Returns copied object keys in unspecified storage order, or an empty vector otherwise.
|
static |
Returns a JSON null value.
|
static |
Returns an empty JSON object value.
| bool ByteDance::pjson::operator!= | ( | const pjson & | aOther | ) | const |
Returns the negation of operator==.
| pjson & ByteDance::pjson::operator+= | ( | const bool | aValue | ) |
Appends aValue as a boolean child.
| pjson & ByteDance::pjson::operator+= | ( | const char * | aValue | ) |
Appends aValue as a string child; throws std::invalid_argument for null.
| pjson & ByteDance::pjson::operator+= | ( | const double | aValue | ) |
Appends aValue as a double child.
| pjson & ByteDance::pjson::operator+= | ( | const float | aValue | ) |
Appends aValue as a floating-point child.
| pjson & ByteDance::pjson::operator+= | ( | const int | aValue | ) |
Appends aValue as a signed integer child.
| pjson & ByteDance::pjson::operator+= | ( | const long | aValue | ) |
Appends aValue as a signed-long child.
| pjson & ByteDance::pjson::operator+= | ( | const long double | aValue | ) |
Narrows aValue to the library's binary64 number representation and appends it.
| pjson & ByteDance::pjson::operator+= | ( | const long long | aValue | ) |
Appends aValue as a signed-long-long child.
| pjson & ByteDance::pjson::operator+= | ( | const short | aValue | ) |
Appends aValue as a signed-short child.
| pjson & ByteDance::pjson::operator+= | ( | const std::string & | aValue | ) |
Appends a copy of aValue as a string child.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< bool > & | aValueArray | ) |
Appends every boolean in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< double > & | aValueArray | ) |
Appends every double in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< float > & | aValueArray | ) |
Appends every float in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< int > & | aValueArray | ) |
Appends every native integer in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< long > & | aValueArray | ) |
Appends every signed long in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< long double > & | aValueArray | ) |
Narrows and appends every long double in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< long long > & | aValueArray | ) |
Appends every signed long long in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< short > & | aValueArray | ) |
Appends every signed short in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< std::string > & | aValueArray | ) |
Appends every string in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< unsigned int > & | aValueArray | ) |
Appends every native unsigned integer in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< unsigned long > & | aValueArray | ) |
Appends every unsigned long in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< unsigned long long > & | aValueArray | ) |
Appends every unsigned long long in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const std::vector< unsigned short > & | aValueArray | ) |
Appends every unsigned short in aValueArray.
| pjson & ByteDance::pjson::operator+= | ( | const unsigned int | aValue | ) |
Appends aValue as an unsigned integer child.
| pjson & ByteDance::pjson::operator+= | ( | const unsigned long | aValue | ) |
Appends aValue as an unsigned-long child.
| pjson & ByteDance::pjson::operator+= | ( | const unsigned long long | aValue | ) |
Appends aValue as an unsigned-long-long child.
| pjson & ByteDance::pjson::operator+= | ( | const unsigned short | aValue | ) |
Appends aValue as an unsigned-short child.
| pjson & ByteDance::pjson::operator= | ( | const bool | aBool | ) |
Replaces this value with aBool.
| pjson & ByteDance::pjson::operator= | ( | const char * | aCString | ) |
Replaces this value with aCString; throws std::invalid_argument for null.
| pjson & ByteDance::pjson::operator= | ( | const double | aDouble | ) |
Replaces this value with aDouble; the non-finite policy governs output.
| pjson & ByteDance::pjson::operator= | ( | const float | aFloat | ) |
Replaces this value with a floating-point number.
| pjson & ByteDance::pjson::operator= | ( | const int | aInt | ) |
Replaces this value with a signed integer.
| pjson & ByteDance::pjson::operator= | ( | const long | aInt | ) |
Replaces this value with a signed long integer.
| pjson & ByteDance::pjson::operator= | ( | const long double | aDouble | ) |
Narrows a long double to the library's binary64 number representation.
| pjson & ByteDance::pjson::operator= | ( | const long long | aInt | ) |
Replaces this value with a signed long-long integer.
Deep-copies aFrom while preserving this value's allocator.
| pjson & ByteDance::pjson::operator= | ( | const short | aInt | ) |
Replaces this value with a signed short integer.
| pjson & ByteDance::pjson::operator= | ( | const std::string & | aString | ) |
Replaces this value with a copy of aString.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< bool > & | aValueArray | ) |
Replaces this value with a copied boolean array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< double > & | aValueArray | ) |
Replaces this value with a copied double array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< float > & | aValueArray | ) |
Replaces this value with a copied float array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< int > & | aValueArray | ) |
Replaces this value with a copied native-integer array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< long > & | aValueArray | ) |
Replaces this value with a copied signed-long array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< long double > & | aValueArray | ) |
Replaces this value with a copied long-double array, narrowing each value to double.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< long long > & | aValueArray | ) |
Replaces this value with a copied signed-long-long array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< short > & | aValueArray | ) |
Replaces this value with a copied signed-short array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< std::string > & | aValueArray | ) |
Replaces this value with a copied string array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< unsigned int > & | aValueArray | ) |
Replaces this value with a copied native unsigned-integer array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< unsigned long > & | aValueArray | ) |
Replaces this value with a copied unsigned-long array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< unsigned long long > & | aValueArray | ) |
Replaces this value with a copied unsigned-long-long array.
| pjson & ByteDance::pjson::operator= | ( | const std::vector< unsigned short > & | aValueArray | ) |
Replaces this value with a copied unsigned-short array.
| pjson & ByteDance::pjson::operator= | ( | const unsigned int | aUInt | ) |
Replaces this value with an unsigned integer.
| pjson & ByteDance::pjson::operator= | ( | const unsigned long | aUInt | ) |
Replaces this value with an unsigned long integer.
| pjson & ByteDance::pjson::operator= | ( | const unsigned long long | aUInt | ) |
Replaces this value with an unsigned long-long integer.
| pjson & ByteDance::pjson::operator= | ( | const unsigned short | aUInt | ) |
Replaces this value with an unsigned short integer.
Moves aFrom while preserving this allocator; cross-allocator moves may allocate.
| pjson & ByteDance::pjson::operator= | ( | std::nullptr_t | ) |
Replaces this value with JSON null (std::nullptr_t assignment).
| bool ByteDance::pjson::operator== | ( | const pjson & | aOther | ) | const |
Returns whether this value and aOther are structurally equal.
| pjson & ByteDance::pjson::operator[] | ( | const char * | aSkey | ) |
Returns or creates the child at aSkey; throws std::invalid_argument for null.
| pjson & ByteDance::pjson::operator[] | ( | const std::string & | aString | ) |
Returns or creates the child at aString.
| pjson & ByteDance::pjson::operator[] | ( | int | index | ) |
Returns or creates the child at index under the auto-growth rules above.
| pjson & ByteDance::pjson::operator[] | ( | size_t | index | ) |
Returns or creates the child at a non-negative index.
Appends a deep copy of aValue, promoting this node to an array.
Moves an independent same-allocator value; otherwise deep-copies it.
| pjson & ByteDance::pjson::reserve | ( | size_t | aCount | ) |
Reserves capacity for at least aCount array elements (no-op for non-arrays unless this node is first made an array); returns *this for chaining.
| void ByteDance::pjson::reset | ( | ) |
Destroys the current contents and becomes null.
| void ByteDance::pjson::resetIfNeeded | ( | jsonType | aeType | ) |
Calls resetTo() only when the type differs, otherwise preserving contents.
| void ByteDance::pjson::resetTo | ( | jsonType | aeType | ) |
Replaces the value with the empty/default value of a valid jsonType.
| size_t ByteDance::pjson::size | ( | ) | const |
Returns the element/member count for containers, or zero for scalars.
|
noexcept |
Exchanges compatible, non-overlapping contents; otherwise does nothing.
| std::string ByteDance::pjson::toString | ( | ) | const |
Returns compact JSON using the default serialization options.
| std::string ByteDance::pjson::toString | ( | const SerializeOptions & | aOpts | ) | const |
Returns JSON serialized according to aOpts.
|
noexcept |
Serializes into aOut transactionally and reports failure without throwing.
|
noexcept |
Compares two stored numbers exactly; false when non-numeric/unordered.
|
noexcept |
Extracts a boolean only when this node stores jsonBoolean.
| bool ByteDance::pjson::tryGet | ( | const char * | aKey, |
| bool & | aResult | ||
| ) | const |
Extracts the boolean child at non-null aKey.
| bool ByteDance::pjson::tryGet | ( | const char * | aKey, |
| double & | aResult | ||
| ) | const |
Extracts the numeric child at non-null aKey as a double.
| bool ByteDance::pjson::tryGet | ( | const char * | aKey, |
| int64_t & | aResult | ||
| ) | const |
Extracts the integer child at non-null aKey.
| bool ByteDance::pjson::tryGet | ( | const char * | aKey, |
| std::string & | aResult | ||
| ) | const |
Copies the string child at non-null aKey.
| bool ByteDance::pjson::tryGet | ( | const char * | aKey, |
| StringView & | aResult | ||
| ) | const |
Borrows a view of the string child at non-null aKey.
| bool ByteDance::pjson::tryGet | ( | const char * | aKey, |
| uint64_t & | aResult | ||
| ) | const |
Extracts the unsigned-integer child at non-null aKey.
| bool ByteDance::pjson::tryGet | ( | const std::string & | aKey, |
| bool & | aResult | ||
| ) | const |
Extracts the boolean child at aKey.
| bool ByteDance::pjson::tryGet | ( | const std::string & | aKey, |
| double & | aResult | ||
| ) | const |
Extracts the numeric child at aKey as a double.
| bool ByteDance::pjson::tryGet | ( | const std::string & | aKey, |
| int64_t & | aResult | ||
| ) | const |
Extracts the integer child at aKey without mutating this object.
| bool ByteDance::pjson::tryGet | ( | const std::string & | aKey, |
| std::string & | aResult | ||
| ) | const |
Copies the string child at aKey.
| bool ByteDance::pjson::tryGet | ( | const std::string & | aKey, |
| StringView & | aResult | ||
| ) | const |
Borrows a view of the string child at aKey.
| bool ByteDance::pjson::tryGet | ( | const std::string & | aKey, |
| uint64_t & | aResult | ||
| ) | const |
Extracts the unsigned-integer child at aKey without mutating this object.
|
noexcept |
Extracts a numeric value, widening a stored integer when necessary.
|
noexcept |
Extracts the boolean array child at aIndex.
|
noexcept |
Extracts the numeric array child at aIndex as a double.
|
noexcept |
Extracts the integer array child at aIndex.
| bool ByteDance::pjson::tryGet | ( | int | aIndex, |
| std::string & | aResult | ||
| ) | const |
Copies the string array child at aIndex.
|
noexcept |
Borrows a view of the string array child at aIndex.
|
noexcept |
Extracts the unsigned-integer array child at aIndex.
|
noexcept |
Extracts a signed integer; an unsigned value must fit in int64_t.
| bool ByteDance::pjson::tryGet | ( | std::string & | aResult | ) | const |
Copies a string only when this node stores jsonString.
|
noexcept |
Borrows a string view only when this node stores jsonString.
|
noexcept |
Extracts an unsigned integer; a signed value must be non-negative.
| void ByteDance::pjson::write | ( | std::ostream & | aOut | ) | const |
Writes compact JSON to aOut using the default serialization options.
| void ByteDance::pjson::write | ( | std::ostream & | aOut, |
| const SerializeOptions & | aOpts | ||
| ) | const |
Writes JSON configured by aOpts to aOut.
|
noexcept |
Writes JSON and reports logical or physical failure without throwing.