Corrade::Utility::JsonTokenData class new in Git master

Data of a single JSON token.

Storage for the actual JSON token data inside a Json, internally referenced from JsonToken instances and accessible through JsonToken::token(). Is not usable on its own, pass it to JsonToken::JsonToken(const Json&, const JsonTokenData&) to access the data it references.

Together with JsonTokenOffsetSize can be also used to create a Json instance directly from individual tokens, such as when it's desirable to make externally parsed data available through a JSON-compatible interface. See Creating an instance from externally parsed tokens for more information and a detailed usage example.

Constructors, destructors, conversion operators

JsonTokenData(JsonToken::Type type, std::uint64_t childCountOrStringIndex, bool stringIsKey = false) explicit
Construct a parsed object, array or string token.
JsonTokenData(std::nullptr_t) explicit
Construct a parsed null token.
JsonTokenData(bool value) explicit
Construct a parsed bool token.
JsonTokenData(double value, JsonTokenOffsetSize& offsetSize) explicit
Construct a parsed 64-bit floating-point token.
JsonTokenData(float value) explicit
Construct a parsed 32-bit floating-point token.
JsonTokenData(std::uint32_t value) explicit
Construct a parsed unsigned 32-bit integer token.
JsonTokenData(std::int32_t value) explicit
Construct a parsed signed 32-bit integer token.
JsonTokenData(std::uint64_t value, JsonTokenOffsetSize& offsetSize) explicit
Construct a parsed unsigned 52-bit integer token.
JsonTokenData(std::int64_t value, JsonTokenOffsetSize& offsetSize) explicit
Construct a parsed signed 52-bit integer token.

Function documentation

Corrade::Utility::JsonTokenData::JsonTokenData(JsonToken::Type type, std::uint64_t childCountOrStringIndex, bool stringIsKey = false) explicit

Construct a parsed object, array or string token.

Parameters
type Token type. Expected to be JsonToken::Type::Object, JsonToken::Type::Array or JsonToken::Type::String.
childCountOrStringIndex Child token count for an object or array or escaped string index for a string. Set to ~std::uint64_t{} for a non-escaped string that's referenced directly from the input data.
stringIsKey Set to true if it's a string token that's an object key. Expected to be false otherwise.

Corrade::Utility::JsonTokenData::JsonTokenData(std::nullptr_t) explicit

Construct a parsed null token.

Results in a JsonToken::Type::Null token.

Corrade::Utility::JsonTokenData::JsonTokenData(bool value) explicit

Construct a parsed bool token.

Results in a JsonToken::Type::Bool token.

Corrade::Utility::JsonTokenData::JsonTokenData(double value, JsonTokenOffsetSize& offsetSize) explicit

Construct a parsed 64-bit floating-point token.

Parameters
value The numeric value
offsetSize Matching token offset and size instance where to store the token type.

Results in a JsonToken::Type::Number token with JsonToken::ParsedType::Double. The value is expected to not be a NaN or an infinity, as the internal representation relies on JSON format restrictions for efficient data packing.

Corrade::Utility::JsonTokenData::JsonTokenData(float value) explicit

Construct a parsed 32-bit floating-point token.

Results in a JsonToken::Type::Number token with JsonToken::ParsedType::Float. The value is expected to not be a NaN or an infinity, as the internal representation relies on JSON format restrictions for efficient data packing.

Corrade::Utility::JsonTokenData::JsonTokenData(std::uint32_t value) explicit

Construct a parsed unsigned 32-bit integer token.

Results in a JsonToken::Type::Number token with JsonToken::ParsedType::UnsignedInt.

Corrade::Utility::JsonTokenData::JsonTokenData(std::int32_t value) explicit

Construct a parsed signed 32-bit integer token.

Results in a JsonToken::Type::Number token with JsonToken::ParsedType::Int.

Corrade::Utility::JsonTokenData::JsonTokenData(std::uint64_t value, JsonTokenOffsetSize& offsetSize) explicit

Construct a parsed unsigned 52-bit integer token.

Parameters
value The numeric value
offsetSize Matching token offset and size instance where to store the token type.

Results in a JsonToken::Type::Number token with JsonToken::ParsedType::UnsignedLong. The value is expected to fit into 52 bits, as the internal representation relies on JSON format restrictions for efficient data packing.

Corrade::Utility::JsonTokenData::JsonTokenData(std::int64_t value, JsonTokenOffsetSize& offsetSize) explicit

Construct a parsed signed 52-bit integer token.

Parameters
value The numeric value
offsetSize Matching token offset and size instance where to store the token type.

Results in a JsonToken::Type::Number token with JsonToken::ParsedType::Long. The value is expected to fit into 52 bits, excluding the sign, as the internal representation relies on JSON format restrictions for efficient data packing.