Menu
Lumberyard
C++ API Reference (Version 1.10)

Represents a node in the tree of serialized data. More...

Public Member Functions

 DataElementNode ()
 A constructor. More...
 
template<typename T >
bool GetData (T &value)
 Gets the value of a DataElementNode. More...
 
template<typename T >
bool GetChildData (u32 childNameCrc, T &value)
 Gets the value of the specified subelement of a DataElementNode. More...
 
template<typename T >
bool SetData (SerializeContext &sc, const T &value, ErrorHandler *errorHandler=nullptr)
 Sets the value of a DataElementNode. More...
 
bool Convert (SerializeContext &sc, const char *name, const Uuid &id)
 Converts the current DataElementNode to the specified type and changes the name to the specified name. More...
 
bool Convert (SerializeContext &sc, const Uuid &id)
 Converts the current DataElementNode to the specified type. More...
 
template<typename T >
bool Convert (SerializeContext &sc, const char *name)
 Converts the current DataElementNode to the type that is specified by the template argument and changes the name to the specified name. More...
 
template<typename T >
bool Convert (SerializeContext &sc)
 Converts the current DataElementNode to the type that is specified by the template argument. More...
 
DataElementGetRawDataElement ()
 Gets the DataElement that corresponds to this DataElementNode. More...
 
const DataElementGetRawDataElement () const
 Gets the DataElement that corresponds to this DataElementNode. More...
 
u32 GetName () const
 Gets the CRC32 of the name of the DataElement that corresponds to this DataElementNode. More...
 
const char * GetNameString () const
 Gets the name of the DataElement that corresponds to this DataElementNode. More...
 
void SetName (const char *newName)
 Sets the name of the DataElement that corresponds to this DataElementNode. More...
 
unsigned int GetVersion () const
 Gets the version of the DataElement that corresponds to this DataElementNode. More...
 
const Uuid & GetId () const
 Gets the unique ID of the DataElement type that corresponds to this DataElementNode. More...
 
int GetNumSubElements () const
 Gets the number of subelements that belong to this DataElementNode. More...
 
DataElementNodeGetSubElement (int index)
 Gets the specified subelement (subnode) of this DataElementNode. More...
 
int FindElement (u32 crc)
 Finds the index of the specified subelement of this DataElementNode. More...
 
DataElementNodeFindSubElement (u32 crc)
 Gets a pointer to the specified subelement of this DataElementNode. More...
 
void RemoveElement (int index)
 Removes a subelement with the specified index from this DataElementNode. More...
 
bool RemoveElementByName (u32 crc)
 Removes a subelement with the specified name from this DataElementNode. More...
 
int AddElement (const DataElementNode &elem)
 Adds a subelement to this DataElementNode. More...
 
int AddElement (SerializeContext &sc, const char *name, const Uuid &id)
 Adds a subelement with the specified name and unique type ID to this DataElementNode. More...
 
int AddElement (SerializeContext &sc, const char *name, const ClassData &classData)
 Adds a subelement with the specified name and class data to this DataElementNode. More...
 
template<typename T >
int AddElement (SerializeContext &sc, const char *name)
 Adds a subelement with the specified name to this DataElementNode. More...
 
template<typename T >
int AddElementWithData (SerializeContext &sc, const char *name, const T &dataToSet)
 Adds a subelement with the specified name and data to the DataElement of this DataElementNode. More...
 
int ReplaceElement (SerializeContext &sc, int index, const char *name, const Uuid &id)
 Replaces the subelement of this DataElementNode with a subelement with the specified name and unique type ID. More...
 
template<typename T >
int ReplaceElement (SerializeContext &sc, int index, const char *name)
 Replaces the subelement of this DataElementNode with a subelement with the specified name. More...
 

Protected Types

typedef AZStd::vector< DataElementNodeNodeArray
 A list of data element nodes. More...
 

Protected Member Functions

bool SetDataHierarchy (SerializeContext &sc, const void *objectPtr, const Uuid &classId, ErrorHandler *errorHandler=nullptr)
 Resets the data hierarchy after new data is added to a DataElementNode. More...
 

Protected Attributes

DataElement m_element
 The serialized data within this DataElementNode. More...
 
const ClassDatam_classData
 The reflected class data for the data in this DataElementNode. More...
 
NodeArray m_subElements
 A list of subelements of this DataElementNode. More...
 

Friends

class ObjectStreamInternal::ObjectStreamImpl
 
class DataOverlayTarget
 

Detailed Description

Represents a node in the tree of serialized data.

The node consists of a DataElement, a pointer to the ClassData that describes the data element, and a list of the element's subnodes (subelements). For example, a class is represented as a parent node with its member variables as subnodes.

You need to use this class if you are writing a VersionConverter function.

Member Typedef Documentation

◆ NodeArray

A list of data element nodes.

Each DataElementNode contains its subelements in a list of this type.

Constructor & Destructor Documentation

◆ DataElementNode()

AZ::SerializeContext::DataElementNode::DataElementNode ( )
inline

A constructor.

Member Function Documentation

◆ AddElement() [1/4]

int AZ::SerializeContext::DataElementNode::AddElement ( const DataElementNode elem)

Adds a subelement to this DataElementNode.

Parameters
elemA reference to the subelement to add.
Returns
The index of the subelement that was added. Returns -1 if the subelement could not be added.

◆ AddElement() [2/4]

int AZ::SerializeContext::DataElementNode::AddElement ( SerializeContext sc,
const char *  name,
const Uuid &  id 
)

Adds a subelement with the specified name and unique type ID to this DataElementNode.

Parameters
scA reference to the serialize context.
nameA name for the added subelement.
idThe unique type ID of the type of subelement to add.
Returns
The index of the subelement that was added. Returns -1 if the subelement could not be added.

◆ AddElement() [3/4]

int AZ::SerializeContext::DataElementNode::AddElement ( SerializeContext sc,
const char *  name,
const ClassData classData 
)

Adds a subelement with the specified name and class data to this DataElementNode.

Parameters
scA reference to the serialize context.
nameA name for the added subelement.
classDataA reference to a ClassData object that contains the reflected information of the type to add.
Returns
The index of the subelement that was added. Returns -1 if the subelement could not be added.

◆ AddElement() [4/4]

template<typename T >
int AZ::SerializeContext::DataElementNode::AddElement ( SerializeContext sc,
const char *  name 
)

Adds a subelement with the specified name to this DataElementNode.

Gets the type from the template argument.

Template Parameters
TThe type of subelement to add.
Parameters
scA reference to the serialize context.
nameA name for the added subelement.
Returns
The index of the subelement that was added. Returns -1 if the subelement could not be added.

◆ AddElementWithData()

template<typename T >
int AZ::SerializeContext::DataElementNode::AddElementWithData ( SerializeContext sc,
const char *  name,
const T &  dataToSet 
)

Adds a subelement with the specified name and data to the DataElement of this DataElementNode.

Gets the type from the template argument.

Template Parameters
TThe type of subelement to add.
Parameters
scA reference to the serialize context.
nameA name for the added subelement.
dataToSetA reference to the data to assign to the DataElement of this DataElementNode.
Returns
The index of the subelement that was added. Returns -1 if the subelement could not be added.

◆ Convert() [1/4]

bool AZ::SerializeContext::DataElementNode::Convert ( SerializeContext sc,
const char *  name,
const Uuid &  id 
)

Converts the current DataElementNode to the specified type and changes the name to the specified name.

If the new type has subelements (that is, it is not a leaf node), you must add those elements to the DataElementNode after the conversion.

Parameters
scA reference to the serialize context.
nameA name for the converted DataElementNode. The name must be unique within the current scope.
idThe unique ID of the type to convert the DataElementNode to.
Returns
Returns true if the conversion succeeded. Otherwise, false.

◆ Convert() [2/4]

bool AZ::SerializeContext::DataElementNode::Convert ( SerializeContext sc,
const Uuid &  id 
)

Converts the current DataElementNode to the specified type.

If the new type has subelements (that is, it is not a leaf node), you must add those elements to the DataElementNode after the conversion.

Parameters
scA reference to the serialize context.
idThe unique ID of the type to convert the DataElementNode to.
Returns
Returns true if the conversion succeeded. Otherwise, false.

◆ Convert() [3/4]

template<typename T >
bool AZ::SerializeContext::DataElementNode::Convert ( SerializeContext sc,
const char *  name 
)

Converts the current DataElementNode to the type that is specified by the template argument and changes the name to the specified name.

If the new type has subelements (that is, it is not a leaf node), you must add those elements to the DataElementNode after the conversion.

Template Parameters
TThe type to convert the DataElementNode to.
Parameters
scA reference to the serialize context.
nameA name for the converted DataElementNode. The name must be unique within the current scope.
Returns
Returns true if the conversion succeeded. Otherwise, false.

◆ Convert() [4/4]

template<typename T >
bool AZ::SerializeContext::DataElementNode::Convert ( SerializeContext sc)

Converts the current DataElementNode to the type that is specified by the template argument.

Template Parameters
TThe type to convert the DataElementNode to.
Parameters
scA reference to the serialize context.
Returns
Returns true if the conversion succeeded. Otherwise, false.

◆ FindElement()

int AZ::SerializeContext::DataElementNode::FindElement ( u32  crc)

Finds the index of the specified subelement of this DataElementNode.

Parameters
crcThe CRC32 of the name of the subelement to find.
Returns
The index of the subelement. Returns -1 if the subelement was not found.

◆ FindSubElement()

DataElementNode* AZ::SerializeContext::DataElementNode::FindSubElement ( u32  crc)

Gets a pointer to the specified subelement of this DataElementNode.

Parameters
crcThe CRC32 of the name of the subelement to find.
Returns
A pointer to the subelement. Returns a null pointer if the subelement was not found.

◆ GetChildData()

template<typename T >
bool AZ::SerializeContext::DataElementNode::GetChildData ( u32  childNameCrc,
T &  value 
)

Gets the value of the specified subelement of a DataElementNode.

Template Parameters
TThe data type.
Parameters
childNameCrcThe CRC of the name of the subelement.
[out]valueThe value of the subelement's data.
Returns
Returns true if the data is loaded. Otherwise, false.

◆ GetData()

template<typename T >
bool AZ::SerializeContext::DataElementNode::GetData ( T &  value)

Gets the value of a DataElementNode.

This function only applies to nodes that contain data (leaf nodes).

Template Parameters
TThe data type.
Parameters
[out]valueA reference to the data.
Returns
Returns true if the data is loaded. Otherwise, false.

◆ GetId()

const Uuid& AZ::SerializeContext::DataElementNode::GetId ( ) const
inline

Gets the unique ID of the DataElement type that corresponds to this DataElementNode.

Returns
The unique ID of the data element type.

◆ GetName()

u32 AZ::SerializeContext::DataElementNode::GetName ( ) const
inline

Gets the CRC32 of the name of the DataElement that corresponds to this DataElementNode.

Returns
The CRC32 of the data element name.

◆ GetNameString()

const char* AZ::SerializeContext::DataElementNode::GetNameString ( ) const
inline

Gets the name of the DataElement that corresponds to this DataElementNode.

Returns
A pointer to a string that contains the data element name.

◆ GetNumSubElements()

int AZ::SerializeContext::DataElementNode::GetNumSubElements ( ) const
inline

Gets the number of subelements that belong to this DataElementNode.

Returns
The number of subelements that belong to this DataElementNode.

◆ GetRawDataElement() [1/2]

DataElement& AZ::SerializeContext::DataElementNode::GetRawDataElement ( )
inline

Gets the DataElement that corresponds to this DataElementNode.

Returns
A reference to the retrieved data element.

◆ GetRawDataElement() [2/2]

const DataElement& AZ::SerializeContext::DataElementNode::GetRawDataElement ( ) const
inline

Gets the DataElement that corresponds to this DataElementNode.

Returns
A reference to the retrieved data element.

◆ GetSubElement()

DataElementNode& AZ::SerializeContext::DataElementNode::GetSubElement ( int  index)
inline

Gets the specified subelement (subnode) of this DataElementNode.

Parameters
indexThe index of the subelement to get.
Returns
A reference to the specified subelement.

◆ GetVersion()

unsigned int AZ::SerializeContext::DataElementNode::GetVersion ( ) const
inline

Gets the version of the DataElement that corresponds to this DataElementNode.

Returns
The version of the data element.

◆ RemoveElement()

void AZ::SerializeContext::DataElementNode::RemoveElement ( int  index)

Removes a subelement with the specified index from this DataElementNode.

Parameters
indexThe index of the subelement to remove.

◆ RemoveElementByName()

bool AZ::SerializeContext::DataElementNode::RemoveElementByName ( u32  crc)

Removes a subelement with the specified name from this DataElementNode.

Parameters
crcThe CRC32 of the name of the subelement to remove.
Returns
Returns true if the element was successfully removed. Otherwise, false.

◆ ReplaceElement() [1/2]

int AZ::SerializeContext::DataElementNode::ReplaceElement ( SerializeContext sc,
int  index,
const char *  name,
const Uuid &  id 
)

Replaces the subelement of this DataElementNode with a subelement with the specified name and unique type ID.

Parameters
scA reference to the serialize context.
indexThe index of the subelement to replace with the specified subelement.
nameA name for the new subelement.
idThe unique ID of the new subelement type.
Returns
The index at which the subelement was replaced. Returns -1 if the subelement could not be replaced.

◆ ReplaceElement() [2/2]

template<typename T >
int AZ::SerializeContext::DataElementNode::ReplaceElement ( SerializeContext sc,
int  index,
const char *  name 
)

Replaces the subelement of this DataElementNode with a subelement with the specified name.

Gets the type from the template argument.

Template Parameters
TThe type of the new subelement.
Parameters
scA reference to the serialize context.
indexThe index of the subelement to replace with the specified subelement.
nameA name for the new subelement.
Returns
The index at which the subelement was replaced. Returns -1 if the subelement could not be replaced.

◆ SetData()

template<typename T >
bool AZ::SerializeContext::DataElementNode::SetData ( SerializeContext sc,
const T &  value,
ErrorHandler errorHandler = nullptr 
)

Sets the value of a DataElementNode.

Template Parameters
TThe data type.
Parameters
scA reference to the serialize context.
valueA reference to a data value.
errorHandler(Optional) A pointer to an ErrorHandler object that reports errors and warnings as Lumberyard serializes data.
Returns
Returns true if the data is saved. Otherwise, false.

◆ SetDataHierarchy()

bool AZ::SerializeContext::DataElementNode::SetDataHierarchy ( SerializeContext sc,
const void *  objectPtr,
const Uuid &  classId,
ErrorHandler errorHandler = nullptr 
)
protected

Resets the data hierarchy after new data is added to a DataElementNode.

Parameters
scA reference to the serialize context.
objectPtrA pointer to the value of the data to add.
classIdThe unique type ID of the data that was added.
errorHandler(Optional) A pointer to an ErrorHandler object that reports errors and warnings as Lumberyard serializes data.
Returns
Returns true if the data hierarchy was set successfully. Otherwise, false.

◆ SetName()

void AZ::SerializeContext::DataElementNode::SetName ( const char *  newName)

Sets the name of the DataElement that corresponds to this DataElementNode.

Parameters
newNameA pointer to a string that contains the new name.

Friends And Related Function Documentation

◆ DataOverlayTarget

friend class DataOverlayTarget
friend

◆ ObjectStreamInternal::ObjectStreamImpl

friend class ObjectStreamInternal::ObjectStreamImpl
friend

Member Data Documentation

◆ m_classData

const ClassData* AZ::SerializeContext::DataElementNode::m_classData
protected

The reflected class data for the data in this DataElementNode.

◆ m_element

DataElement AZ::SerializeContext::DataElementNode::m_element
protected

The serialized data within this DataElementNode.

The serialized data is a DataElement.

◆ m_subElements

NodeArray AZ::SerializeContext::DataElementNode::m_subElements
protected

A list of subelements of this DataElementNode.

The subelements are of type DataElementNode also.


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