Class Deserializer¶
Defined in File serialize.h
Inheritance Relationships¶
Derived Type¶
public portal::BinaryDeserializer(Class BinaryDeserializer)
Class Documentation¶
-
class Deserializer¶
Base class for sequential binary deserialization (stream-based).
Counterpart to Serializer. Reads values from a binary stream in the exact order they were written. The read order must match the write order precisely.
BinaryDeserializer deserializer(input_stream); int value; std::string text; deserializer.get_value(value); deserializer.get_value(text);
Critical: Read order must match write order exactly. No property names to match against.
See also
Serializer for writing data
Subclassed by portal::BinaryDeserializer
Public Functions
-
virtual ~Deserializer() = default¶
-
template<typename T>
inline void get_value(T &t)¶ Deserializes a scalar value (integral or floating-point).
Reads fundamental numeric types from the stream. Validates type and size metadata to catch deserialization errors in debug builds.
- Template Parameters:
T – Scalar type (integral or floating-point, excluding bool)
- Parameters:
t – Output parameter to store the deserialized value
-
template<typename T>
inline void get_value(T &t) Deserializes a 128-bit unsigned integer.
Special handling for uint128_t with PropertyType::integer128 validation.
- Parameters:
t – Output parameter to store the 128-bit integer
-
template<reflection::Vector T>
inline void get_value(T &t)¶ Deserializes a std::vector of complex elements.
Reads the vector size followed by each element. Each element is deserialized in order.
- Template Parameters:
T – Vector type with complex elements
- Parameters:
t – Output parameter to store the deserialized vector
-
template<reflection::Vector T>
inline void get_value(T &t) Deserializes a std::vector of fundamental elements.
Reads contiguous array data from the stream and constructs a vector from it. For vectors of fundamental types, see the overload that reads size first.
- Template Parameters:
T – Vector type with fundamental elements
- Parameters:
t – Output parameter to store the deserialized vector
-
template<reflection::String T>
inline void get_value(T &t)¶ Deserializes a string value.
Reads a string from the stream, handling both null-terminated and length-prefixed formats.
- Template Parameters:
T – String type (std::string, etc.)
- Parameters:
t – Output parameter to store the deserialized string
-
template<reflection::IsVec T>
inline void get_value(T &t)¶ Deserializes GLM vectors.
- Template Parameters:
T – GLM vecB type (glm::vecN, glm::ivecB, etc.)
- Parameters:
t – Output parameter to store the deserialized vector
-
template<reflection::Map T>
inline void get_value(T &t)¶ Deserializes a map (std::map, std::unordered_map, etc.).
Reads the map size followed by key-value pairs. Clears the output map and reserves space if the map type supports it.
- Template Parameters:
T – Map type
- Parameters:
t – Output parameter to store the deserialized map
-
template<typename T>
inline void get_value(T &t) Deserializes an enum from its underlying integer type.
Reads the underlying type (e.g., int, uint8_t) and casts it back to the enum type. Must match the serialization order exactly.
- Template Parameters:
T – Enum type
- Parameters:
t – Output parameter to store the deserialized enum value
-
template<DeserializableConcept T>
inline void get_value(T &t)¶ Deserializes a custom Deserializable type.
Calls the type’s static deserialize() method, which should read its members sequentially from this Serializer and construct an instance.
- Template Parameters:
T – Type satisfying the Deserializable concept
- Parameters:
t – Output parameter to store the deserialized object
-
template<ExternalDeserializable T>
inline void get_value(T &t)¶ Deserializes a type with a SerializableType<T> specialization.
Calls SerializableType<T>::deserialize() to read the object’s data sequentially. This enables non-intrusive deserialization for types you don’t control.
- Template Parameters:
T – Type satisfying the ExternalDeserializable concept
- Parameters:
t – Output parameter to store the deserialized object
-
template<typename T>
inline void get_value(T &output) Deserializes types with glaze reflection metadata (return-type version).
Fallback overload for types with glaze compile-time reflection. Automatically deserializes all reflected fields and returns a new instance. Use this for types that don’t implement deserialize() but have glaze metadata.
- Template Parameters:
T – Type with glaze reflection metadata (glz::reflect)
- Returns:
The deserialized object
-
inline void get_value(char *&t, const size_t length)¶
Deserializes a C-string into a pre-allocated buffer.
Reads character data from the stream and copies it into the provided buffer. The buffer must be large enough to hold the expected string length.
- Parameters:
t – Pointer to pre-allocated character buffer
length – Expected length of the string (including null terminator)
-
virtual ~Deserializer() = default¶