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::ObjectStream Class Referenceabstract

#include <ObjectStream.h>

Inherits AZ::DataStream.

Classes

struct  Descriptor
 
struct  FilterDescriptor
 
class  Handle
 

Public Types

enum  FilterFlags { FILTERFLAG_STRICT = 1 << 0 , FILTERFLAG_IGNORE_UNKNOWN_CLASSES = 1 << 1 }
 
typedef AZStd::function< void(void **, const SerializeContext::ClassData **, const Uuid &, SerializeContext *)> InplaceLoadRootInfoCB
 
typedef AZStd::function< void(void *, const Uuid &, SerializeContext *) > ClassReadyCB
 Called for each root object loaded.
 
typedef AZStd::function< void(Handle, bool) > CompletionCB
 Called to indicate that loading has completed.
 
- Public Types inherited from AZ::DataStream
enum  StreamType { ST_XML , ST_JSON , ST_BINARY , ST_MAX }
 

Public Member Functions

virtual bool WriteClass (const void *classPtr, const Uuid &classId, const SerializeContext::ClassData *classData=nullptr)=0
 
virtual bool Finalize ()=0
 returns true if successfully flushed and closed the object stream, false otherwise
 
template<typename T >
bool WriteClass (const T *obj, const char *elemName=nullptr)
 Writes a root object. Call this inside the ClassWriterCB.
 
- Public Member Functions inherited from AZ::DataStream
StreamType GetType () const
 
void SetType (StreamType fmt)
 

Static Public Member Functions

static bool LoadBlocking (IO::GenericStream *stream, SerializeContext &sc, const ClassReadyCB &readyCB, const FilterDescriptor &filterDesc=FilterDescriptor(), const InplaceLoadRootInfoCB &inplaceRootInfo=InplaceLoadRootInfoCB())
 Create objects from a stream. All processing happens in the caller thread. Returns true on success.
 
static ObjectStreamCreate (IO::GenericStream *stream, SerializeContext &sc, DataStream::StreamType fmt)
 Create a new object stream for writing.
 
static bool AssetFilterDefault (const Data::AssetFilterInfo &filterInfo)
 Default asset filter obeys the Asset<> holder's load flags.
 
static bool AssetFilterSlicesOnly (const Data::AssetFilterInfo &filterInfo)
 SlicesOnly filter ignores all asset references except for slices.
 
static bool Cancel (Handle jobHandle)
 Cancel a request. To be implemented...
 
template<typename T >
static bool AssetFilterAssetTypesOnly (const Data::AssetFilterInfo &filterInfo)
 Filter ignores all asset references except for the specified classes.
 
template<typename T0 , typename T1 , typename... Args>
static bool AssetFilterAssetTypesOnly (const Data::AssetFilterInfo &filterInfo)
 

Protected Member Functions

 ObjectStream (SerializeContext *sc)
 

Protected Attributes

SerializeContextm_sc
 
- Protected Attributes inherited from AZ::DataStream
StreamType m_type
 

Detailed Description

Member Typedef Documentation

◆ InplaceLoadRootInfoCB

Allows the user to provide information about the root element for in-place loading. Can be asked to provide once of two things

Parameters
rootAddresswhen this is not null, you need to provide the address for inplace loading. If you return null the default object factory will be called (like if you did not provide the callback)
classDataif the class Uuid can't be find in the serializeContext (only in very special cases, like generics in-place loading), you will be asked to provide classData.
classIdprovided to you for information
contextprovided to you for information

Member Enumeration Documentation

◆ FilterFlags

Filter flags control the overall behavior of the serialize operation and can cause it to skip over unnecessary data (the default) or instead throw an error and fail if any error is encountered.

Enumerator
FILTERFLAG_STRICT 

If the FILTERFLAG_STRICT flag is set, the serialization operation will return false (failure to deserialize) if ANY error has occurred at all even non-fatal errors. So any kind of issue - asset missing, unknown class, non-deprecatd class, container failure, even things which it can continue reading through and ignore safely, will cause it to return false for the entire serialization. This should only be used in cases where the incoming data is EXPECTED to be 100% pristine (network payloads sent between clients of the same version for example)

Note that even in non-strict mode, if errors are encountered, they will still be emitted as errors, but the serializer will continue and not return "false" for the entire operation just becuase of a single recoverable error.

FILTERFLAG_IGNORE_UNKNOWN_CLASSES 

if FILTERFLAG_IGNORE_UNKNOWN_CLASSES is set, deprecated or unrecognized classes will be SILENTLY ignored with no error output. this is only to be rarely used, when reading data you know contains classes that you want to ignore silently, not for ignoring errors in general.


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