|
| BaseStream () |
| Initializes the status to false . More...
|
|
StreamClass & | Open (const char *file_name) |
| Opens a file for serialization. More...
|
|
StreamClass & | Open (const char *file_name, const char *access) |
| Opens a file for serialization. More...
|
|
StreamClass & | Close () |
| Closes the file of the serialization and finish the serialization. More...
|
|
StreamClass & | SerializeBytes (void *ptr, int num_bytes) |
| Serializes a number of bytes. More...
|
|
template<typename T > |
StreamClass & | operator& (T &var) |
| This operator overloading is the key of the serialization mechanism. More...
|
|
bool | result () const |
| Returns the internal serialization status. More...
|
|
| operator bool () const |
| Return the internal serialization status. More...
|
|
virtual | ~BaseStream () |
| The destructor automatically closes the file-. More...
|
|
template<typename StreamClass, typename StreamOperator>
class data::BaseStream< StreamClass, StreamOperator >
This template is used as the base for the input/output stream classes.
Contains the basic functionality for the serialization with files, composed by a file object and an internal status. This status is updated with each operation and, in a sequence of serialization, this is stopped just after this status is set to false
.
In order to have a type serializable, it must comply with one of these requirements: i) to have implemented a "serializer" with the class Serializer
, or ii) to have defined a member method called SerializeWith
.
The first option is useful for the basic types (int, float, etc.) and for those classes already defined and that can not be modified. The second option is more elegant for those classes that can be modified specifically for serialization.
The SerializeWith
method must be defined as follows:
template<typename T> T& SerializeWith(T& stream) { return (stream & member1 & member2 & ...); }
- See Also
- Serializer
-
InputStream
-
OutputStream