Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Dom::Visitor Class Reference

#include <DomVisitor.h>

Inherited by AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

Public Types

using Result = AZ::Outcome< void, VisitorError >
 

Public Member Functions

virtual VisitorFlags GetVisitorFlags () const
 
bool SupportsRawValues () const
 
bool SupportsRawKeys () const
 
bool SupportsObjects () const
 
bool SupportsArrays () const
 
bool SupportsNodes () const
 
bool SupportsOpaqueValues () const
 
virtual Result Null ()
 Operates on an empty null value.
 
virtual Result Bool (bool value)
 Operates on a bool value.
 
virtual Result Int64 (AZ::s64 value)
 Operates on a signed, 64 bit integer value.
 
virtual Result Uint64 (AZ::u64 value)
 Operates on an unsigned, 64 bit integer value.
 
virtual Result Double (double value)
 Operates on a double precision, 64 bit floating point value.
 
virtual Result String (AZStd::string_view value, Lifetime lifetime)
 
virtual Result RefCountedString (AZStd::shared_ptr< const AZStd::vector< char > > value, Lifetime lifetime)
 
virtual Result OpaqueValue (OpaqueType &value)
 
virtual Result RawValue (AZStd::string_view value, Lifetime lifetime)
 
virtual Result StartObject ()
 
virtual Result EndObject (AZ::u64 attributeCount)
 
virtual Result Key (AZ::Name key)
 
virtual Result RawKey (AZStd::string_view key, Lifetime lifetime)
 
virtual Result StartArray ()
 
virtual Result EndArray (AZ::u64 elementCount)
 
virtual Result StartNode (AZ::Name name)
 
virtual Result RawStartNode (AZStd::string_view name, Lifetime lifetime)
 
virtual Result EndNode (AZ::u64 attributeCount, AZ::u64 elementCount)
 

Static Protected Member Functions

static Result VisitorFailure (VisitorErrorCode code)
 Helper method, constructs a failure Result with the specified code.
 
static Result VisitorFailure (VisitorErrorCode code, AZStd::string additionalInfo)
 Helper method, constructs a failure Result with the specified code and supplemental info.
 
static Result VisitorFailure (VisitorError error)
 Helper method, constructs a failure Result with the specified error.
 
static Result VisitorSuccess ()
 Helper method, constructs a success Result.
 

Detailed Description

An interface for performing operations on elements of a generic DOM (Document Object Model). A Document Object Model is defined here as a tree structure comprised of one of the following values:

  • Primitives: plain data types, including
    • Int64: 64 bit signed integer
    • Uint64: 64 bit unsigned integer
    • Bool: boolean value
    • Double: 64 bit double precision float
    • Null: sentinel "empty" type with no value representation
  • String: UTF8 encoded string
  • Object: an ordered container of key/value pairs where keys are AZ::Name and values may be any DOM type (including Object)
  • Array: an ordered container of values, in which values are any DOM value type (including Array)
  • Node: a container
  • OpaqueValue: An arbitrary value stored in an AZStd::any. This is a non-serializable representation of an entry useful for in-memory options. This is intended to be used as an intermediate value over the course of DOM transformation and as a proxy to pass through types of which the DOM has no knowledge to other systems.

    Opaque values are rejected by the default VisitorInterface implementation.

    Care should be ensured that DOMs representing opaque types are only visited by consumers that understand them.

Member Typedef Documentation

◆ Result

The result of a Visitor operation. A failure indicates a non-recoverable issue and signals that no further visit calls may be made in the current state.

Member Function Documentation

◆ Bool()

virtual Result AZ::Dom::Visitor::Bool ( bool  value)
virtual

Operates on a bool value.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ Double()

virtual Result AZ::Dom::Visitor::Double ( double  value)
virtual

Operates on a double precision, 64 bit floating point value.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ EndArray()

virtual Result AZ::Dom::Visitor::EndArray ( AZ::u64  elementCount)
virtual

Finishes operating on an Array. Callers must provide the number of elements that were provided to the array, i.e. the number of value calls made within the direct context of this array (but not any nested arrays / nodes).

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ EndNode()

virtual Result AZ::Dom::Visitor::EndNode ( AZ::u64  attributeCount,
AZ::u64  elementCount 
)
virtual

Finishes operating on a Node. Callers must provide both the number of attributes the were provided and the number of elements that were provided to the node, attributes being values prefaced by a call to Key.

Reimplemented in AZ::Dom::ValueWriter.

◆ EndObject()

virtual Result AZ::Dom::Visitor::EndObject ( AZ::u64  attributeCount)
virtual

Finishes operating on an Object. Callers must provide the number of attributes that were provided to the object, i.e. the number of key and value calls made within the direct context of this object (but not any nested objects / nodes).

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ GetVisitorFlags()

virtual VisitorFlags AZ::Dom::Visitor::GetVisitorFlags ( ) const
virtual

Returns a set of flags representing the operations this Visitor supports. The base implementation supports raw keys (

See also
VisitorFlags::SupportsRawKeys) and arrays (
VisitorFlags::SupportsArrays), objects (
VisitorFlags::SupportsObjects), and nodes (
VisitorFlags::SupportsNodes). Raw (
VisitorFlags::SupportsRawValues) and opaque values (
VisitorFlags::SupportsOpaqueValues) are disallowed by default, as their handling is intended to be implementation-specific.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ Int64()

virtual Result AZ::Dom::Visitor::Int64 ( AZ::s64  value)
virtual

Operates on a signed, 64 bit integer value.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ Key()

virtual Result AZ::Dom::Visitor::Key ( AZ::Name  key)
virtual

Specifies a key for a key/value pair. Key must be called subsequent to a call to StartObject or StartNode and immediately followed by calls representing the key's associated value.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ Null()

virtual Result AZ::Dom::Visitor::Null ( )
virtual

Operates on an empty null value.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ OpaqueValue()

virtual Result AZ::Dom::Visitor::OpaqueValue ( OpaqueType value)
virtual

Operates on an opaque value. As opaque values are a reference type, storage semantics are provided to indicate where the value may be stored persistently or requires a copy. The base implementation of OpaqueValue rejects the operation, as opaque values are meant for special cases with specific implementations, not generic usage.

Reimplemented in AZ::Dom::ValueWriter.

◆ RawKey()

virtual Result AZ::Dom::Visitor::RawKey ( AZStd::string_view  key,
Lifetime  lifetime 
)
virtual

Specifies a key for a key/value pair using a raw string instead of AZ::Name.

See also
Key

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ RawStartNode()

virtual Result AZ::Dom::Visitor::RawStartNode ( AZStd::string_view  name,
Lifetime  lifetime 
)
virtual

Operates on a Node using a raw string instead of AZ::Name.

See also
StartNode

Reimplemented in AZ::Dom::ValueWriter.

◆ RawValue()

virtual Result AZ::Dom::Visitor::RawValue ( AZStd::string_view  value,
Lifetime  lifetime 
)
virtual

Operates on a raw value encoded as a UTF-8 string that hasn't had its type deduced. Visitors that support raw values (

See also
VisitorFlags::SupportsRawValues) may parse the raw value and forward it to the corresponding value call or calls of their choice. The base implementation of RawValue rejects the operation, as raw values are meant to be handled on a per-implementation basis.

◆ RefCountedString()

virtual Result AZ::Dom::Visitor::RefCountedString ( AZStd::shared_ptr< const AZStd::vector< char > >  value,
Lifetime  lifetime 
)
virtual

Operates on a ref-counted string value. S

Parameters
lifetimeSpecifies the lifetime of this string. If the string has a temporary lifetime, it may not be safely stored as a reference, but may still be safely stored as a ref-counted shared_ptr.

Reimplemented in AZ::Dom::ValueWriter.

◆ StartArray()

virtual Result AZ::Dom::Visitor::StartArray ( )
virtual

Operates on an Array. Callers may make any number of subsequent value calls to represent the elements of the array, and then must call EndArray.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ StartNode()

virtual Result AZ::Dom::Visitor::StartNode ( AZ::Name  name)
virtual

Operates on a Node. Callers may make any number of Key calls followed by value calls or value calls not prefixed with a Key call, and then must call EndNode. See StartObject and StartArray as Node types combine the functionality of both structures into a named Node structure.

Reimplemented in AZ::Dom::ValueWriter.

◆ StartObject()

virtual Result AZ::Dom::Visitor::StartObject ( )
virtual

Operates on an Object. Callers may make any number of Key calls, followed by calls representing a value (including a nested StartObject call) and then must call EndObject.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ String()

virtual Result AZ::Dom::Visitor::String ( AZStd::string_view  value,
Lifetime  lifetime 
)
virtual

Operates on a string value. As strings are a reference type, storage semantics are provided to indicate where the value may be stored persistently or requires a copy.

Parameters
lifetimeSpecifies the lifetime of this string - if the string has a temporary lifetime, it cannot safely be stored as a reference.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.

◆ SupportsArrays()

bool AZ::Dom::Visitor::SupportsArrays ( ) const
See also
VisitorFlags::SupportsArrays

◆ SupportsNodes()

bool AZ::Dom::Visitor::SupportsNodes ( ) const
See also
VisitorFlags::SupportsNodes

◆ SupportsObjects()

bool AZ::Dom::Visitor::SupportsObjects ( ) const
See also
VisitorFlags::SupportsObjects

◆ SupportsOpaqueValues()

bool AZ::Dom::Visitor::SupportsOpaqueValues ( ) const
See also
VisitorFlags::SupportsOpaqueValues

◆ SupportsRawKeys()

bool AZ::Dom::Visitor::SupportsRawKeys ( ) const
See also
VisitorFlags::SupportsRawKeys

◆ SupportsRawValues()

bool AZ::Dom::Visitor::SupportsRawValues ( ) const
See also
VisitorFlags::SupportsRawValues

◆ Uint64()

virtual Result AZ::Dom::Visitor::Uint64 ( AZ::u64  value)
virtual

Operates on an unsigned, 64 bit integer value.

Reimplemented in AZ::Dom::Json::RapidJsonValueWriter, and AZ::Dom::ValueWriter.


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