omni::structuredlog::JsonNode

Defined in omni/structuredlog/JsonTree.h

struct JsonNode

A node in a JSON structure.

This is a standard layout type for ABI safety . Do not directly write this struct; use JsonBuilder to set the members to ensure the layout is as-expected by the consumers of this struct.

Subclassed by omni::structuredlog::TempJsonNode

Public Types

using EnumBase = uint16_t

The base type to be used for enums.

using Flag = uint8_t

The type of the flags member.

Public Members

NodeType type = NodeType::eNull

The type of this node.

This and len decide which member of data is in use.

Flag flags = 0

Behavioral flags for this node.

uint16_t len = 0

The length of the data array.

This is ignored for non-array and non-object types. For NodeType::eString, this is the length of the stored string (as an optimization). For other values of type, this is the length of the array stored in data.

uint16_t nameLen = 0

The length of name in bytes.

char *name = nullptr

The JSON node name.

This will be nullptr when type is NodeType::eObjectArray.

bool boolVal

This is in use when type is NodeType::eBool.

int64_t intVal

This is in use when type is NodeType::eInt32 or NodeType::eInt64.

uint64_t uintVal

This is in use when type is NodeType::eUint32 or NodeType::eUint64.

double floatVal

This is in use when type is NodeType::eFloat32 or NodeType::eFloat64.

uint8_t *binaryVal

This is used when type is NodeType::eBinary.

char *strVal

This is in use when type is NodeType::eString.

bool *boolArrayVal

This is in use when type is NodeType::eBoolArray.

int32_t *int32ArrayVal

This is in use when type is NodeType::eInt32Array.

int64_t *int64ArrayVal

This is in use when type is NodeType::eInt64Array.

uint32_t *uint32ArrayVal

This is in use when type is NodeType::eUint32Array.

uint64_t *uint64ArrayVal

This is in use when type is NodeType::eUint64Array.

float *float32ArrayVal

This is in use when type is NodeType::eFloat32Array.

double *float64ArrayVal

This is in use when type is NodeType::eFloat64Array.

char **strArrayVal

This is in use when type is NodeType::eStringArray.

JsonNode *objVal

This is in use when type is NodeType::eObject or NodeType::eObjectArray.

In the case where type is NodeType::eObject, this node is an object and each element in objVal is a property of that object. In the case where type is NodeType::eObjectArray, this node is an object array and each element is an entry in the object array (each entry should have type NodeType::eObject).

union omni::structuredlog::JsonNode::[anonymous] data

The union of possible values that can be used.

This may not be accessed if type is NodeType::eNull.

Public Static Attributes

static constexpr uint32_t kVersion = 0

The version of the structure.

Headers that use this struct should static assert on its version. Do not modify the layout of this struct without incrementing this.

static constexpr Flag fFlagConst = 0x01

This specifies that the value is constant.

This is used for schemas to specify whether a property is constant. This flag has no meaning when type is NodeType::eObject or NodeType::eObjectArray; for an object to be constant, each property of that object must be constant.

static constexpr Flag fFlagFixedLength = 0x02

This specifies that an array has a fixed length.

This is used for a schema node in a tree to specify that an array in the tree has a fixed length (that length is specified by len). This is only valid for array types and string. This is ignored if combined with fFlagConst.

static constexpr Flag fFlagEnum = 0x04

This specifies that the parameter is an enum type.

An enum type is stored in the data blob as an EnumBase. The EnumBase is used as an index into the array of values stored in this node. This flag is only valid for a NodeType that is an array type other than NodeType::eObjectArray.