Class Serializer¶
Defined in File core.h
Page Contents
Class Documentation¶
-
class
Serializer
¶ Serialization helper class.
This class can be used to store and retrieve a great variety of C++ data types using a compact binary file format. The intended purpose is to quickly save and restore the complete state of an application, e.g. to facilitate debugging sessions. This class supports all core C++ types, NanoGUI widgets, sparse and dense Eigen matrices, as well as OpenGL shaders and buffer objects.
Note that this header file just provides the basics; the files
nanogui/serializer/opengl.h
, andnanogui/serializer/sparse.h
must be included to serialize the respective data types.Public Functions
-
Serializer
(const std::string &filename, bool write)¶ Create a new serialized file for reading or writing.
-
~Serializer
()¶ Release all resources.
-
size_t
size
()¶ Return the current size of the output file.
-
void
push
(const std::string &name)¶ Push a name prefix onto the stack (use this to isolate identically-named data fields)
-
void
pop
()¶ Pop a name prefix from the stack.
-
std::vector<std::string>
keys
() const¶ Return all field names under the current name prefix.
-
void
setCompatibility
(bool compatibility)¶ Enable/disable compatibility mode.
When enabled, missing attributes cause a warning to be printed, but get() does not throw an exception.
-
bool
compatibility
()¶ Return whether compatibility mode is enabled.
Public Static Functions
-
static bool
isSerializedFile
(const std::string &filename)¶ Check whether a file contains serialized data.
-