34        result.
SetError(
"Failed to read type hash");
 
   42        result.
SetError(
"Failed to create instance of type");
 
   48    (
object->*inRestoreBinaryStateFunction)(inStream);
 
   51        result.
SetError(
"Failed to restore object");
 
   63    if (ioObjectToIDMap == 
nullptr || inObject == 
nullptr)
 
   71        if (
id != ioObjectToIDMap->end())
 
   74            inStream.
Write(id->second);
 
   80            (*ioObjectToIDMap)[inObject] = new_id;
 
   81            inStream.
Write(new_id);
 
   84            inObject->SaveBinaryState(inStream);
 
  107    if (
id >= ioIDToObjectMap.size())
 
  110        result = Type::sRestoreFromBinaryState(inStream);
 
  114        ioIDToObjectMap.push_back(result.
Get());
 
  119        result.
Set(ioIDToObjectMap[
id].GetPtr());
 
  126template <
class ArrayType, 
class ValueType>
 
  129    inStream.
Write(
size_t(inArray.size()));
 
  130    for (
const ValueType *value: inArray)
 
  135template <
class ArrayType, 
class ValueType>
 
  144        result.
SetError(
"Failed to read stream");
 
  150    for (
size_t i = 0; i < len; ++i)
 
  158        values.push_back(std::move(value.
Get()));
 
#define JPH_NAMESPACE_END
Definition: Core.h:354
 
std::uint32_t uint32
Definition: Core.h:429
 
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:348
 
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
 
std::vector< T, STLAllocator< T > > Array
Definition: STLAllocator.h:81
 
std::unordered_map< Key, T, Hash, KeyEqual, STLAllocator< pair< const Key, T > > > UnorderedMap
Definition: UnorderedMap.h:13
 
const RTTI * Find(const char *inName)
Find type info for a specific class by name.
Definition: Factory.cpp:19
 
static Factory * sInstance
Singleton factory instance.
Definition: Factory.h:40
 
void * CreateObject() const
Create an object of this type (returns nullptr if the object is abstract)
Definition: RTTI.cpp:53
 
Definition: Reference.h:101
 
Helper class that either contains a valid result or an error.
Definition: Result.h:15
 
void SetError(const char *inError)
Set an error value.
Definition: Result.h:155
 
void Set(const Type &inResult)
Set the result value.
Definition: Result.h:143
 
bool HasError() const
Check if we had an error.
Definition: Result.h:149
 
const String & GetError() const
Get the error value.
Definition: Result.h:152
 
const Type & Get() const
Get the result value.
Definition: Result.h:140
 
Simple binary input stream.
Definition: StreamIn.h:13
 
void Read(T &outT)
Read a primitive (e.g. float, int, etc.) from the binary stream.
Definition: StreamIn.h:29
 
virtual bool IsEOF() const =0
Returns true when an attempt has been made to read past the end of the file.
 
virtual bool IsFailed() const =0
Returns true if there was an IO failure.
 
Simple binary output stream.
Definition: StreamOut.h:13
 
void Write(const T &inT)
Write a primitive (e.g. float, int, etc.) to the binary stream.
Definition: StreamOut.h:26
 
Definition: StreamUtils.h:15
 
Array< Ref< Type > > IDToObjectMap
Definition: StreamUtils.h:21
 
Result< ArrayType > RestoreObjectArray(StreamIn &inStream, IDToObjectMap< ValueType > &ioIDToObjectMap)
Definition: StreamUtils.h:136
 
Result< Ref< Type > > RestoreObject(StreamIn &inStream, void(Type::*inRestoreBinaryStateFunction)(StreamIn &))
Definition: StreamUtils.h:25
 
Result< Ref< Type > > RestoreObjectReference(StreamIn &inStream, IDToObjectMap< Type > &ioIDToObjectMap)
Restore an object reference from stream.
Definition: StreamUtils.h:91
 
void SaveObjectArray(StreamOut &inStream, const ArrayType &inArray, ObjectToIDMap< ValueType > *ioObjectToIDMap)
Definition: StreamUtils.h:127
 
UnorderedMap< const Type *, uint32 > ObjectToIDMap
Definition: StreamUtils.h:18
 
void SaveObjectReference(StreamOut &inStream, const Type *inObject, ObjectToIDMap< Type > *ioObjectToIDMap)
Save an object reference to a stream. Uses a map to map objects to IDs which is also used to prevent ...
Definition: StreamUtils.h:61