BloombergLP::baljsn::JsonTokenizer

This class implements a mechanism that makes the organization and values of a non-scalar bdljsn::Json object available as a series of tokens. Some tokens have associated values. See .

Synopsis

Declared in <baljsn_jsontokenizer.h>

class JsonTokenizer;

Type Aliases

NameDescription
allocator_type Type of the allocator used to supply memory.

Enums

NameDescription
TokenType Enumeration of tokenizer token types.

Member Functions

NameDescription
JsonTokenizer [constructor]Constructors
~JsonTokenizer [destructor]Destroy this object.
advanceToNextToken Move to the next token in the source object. Return 0 on success and a non-zero value otherwise. The return value is non-zero when there are no more tokens in the source object. The behavior is undefined unless a source object was specified on construction and/or a call to reset.
get_allocator Return the allocator used by this object to supply memory. Note that if no allocator was supplied at construction the default allocator in effect at construction is used.
reset Reset this tokenizer to use the specified json as a source object for tokens. All state associated with a previously specified source object (if any) is discarded. The behavior is undefined unless json->isArray() or json->isObject().
tokenType Return the type of the current token.
value value overloads

Static Member Functions

NameDescription
print Write the string representation of the specified enumeration value to the specified output stream, and return a reference to stream. Optionally specify an initial indentation level, whose absolute value is incremented recursively for nested objects. If level is specified, optionally specify spacesPerLevel, whose absolute value indicates the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level). See toAscii for what constitutes the string representation of a JsonTokenizer::TokenType value.
toAscii Return the non-modifiable string representation corresponding to the specified enumeration value, if it exists, and a unique (error) string otherwise. The string representation of value matches its corresponding enumerator name with the "e_" prefix elided. For example: ` bsl::cout << DstPolicy::toAscii(JsonTokenizer::e_ELEMENT_VALUE); ` will print the following on standard output: ` ELEMENT_VALUE ` Note that specifying a value that does not match any of the enumerators will result in a string representation that is distinct from any of those corresponding to the enumerators, but is otherwise unspecified.

Friends

NameDescription
BloombergLP::baljsn::JsonTokenizer_VisitorThis class provides a mechanism for extracting token information from a bdljsn::Json object, transferring that information to a parent baljsn::JsonTokenizer object (which considers this visitor a friend), and, if appropriate, arranging for the visiting of a subordinate bdljsn::Json object.