An adapter for a std::ofstream to make it suitable for binary IO. More...
#include <vsl_binary_io.h>

Public Member Functions | |
| vsl_b_ofstream (const std::string &filename, std::ios::openmode mode=std::ios::out|std::ios::trunc) | |
| Create this adaptor from a file. More... | |
| vsl_b_ofstream (const char *filename, std::ios::openmode mode=std::ios::out|std::ios::trunc) | |
| Create this adaptor from a file. More... | |
| ~vsl_b_ofstream () override | |
| Virtual destructor. More... | |
| void | close () |
| Close the stream. More... | |
| std::ostream & | os () const |
| A reference to the adaptor's stream. More... | |
| bool | operator! () const |
| Returns true if the underlying stream has its fail bit set. More... | |
| virtual void | clear_serialisation_records () |
| Clear the stream's record of any serialisation operations. More... | |
| virtual unsigned long | add_serialisation_record (void *pointer, int other_data=0) |
| Adds an object pointer to the serialisation records. More... | |
| virtual unsigned long | get_serial_number (void *pointer) const |
| Returns a unique identifier for the object. More... | |
| virtual int | get_serialisation_other_data (void *pointer) const |
| Set the user-defined data associated with the object. More... | |
| virtual int | set_serialisation_other_data (void *pointer, int other_data) |
| Modify the user-defined data associated with the object. More... | |
Static Public Attributes | |
| static constexpr std::streamoff | header_length = 6 |
| The length of the b_stream header. More... | |
Protected Types | |
| typedef std::map< void *, std::pair< unsigned long, int >, std::less< void * > > | serialisation_records_type |
| The type of the serialisation records. More... | |
Protected Attributes | |
| std::ostream * | os_ |
| The member stream. More... | |
| serialisation_records_type | serialisation_records_ |
| The serialisation records. More... | |
Static Protected Attributes | |
| static constexpr unsigned short | version_no_ = 1 |
| The version number of the IO scheme. More... | |
An adapter for a std::ofstream to make it suitable for binary IO.
Definition at line 125 of file vsl_binary_io.h.
|
protectedinherited |
The type of the serialisation records.
Definition at line 112 of file vsl_binary_io.h.
|
inline |
Create this adaptor from a file.
The adapter will delete the internal stream automatically on destruction.
Definition at line 130 of file vsl_binary_io.h.
|
inline |
Create this adaptor from a file.
The adapter will delete the internal stream automatically on destruction.
Definition at line 136 of file vsl_binary_io.h.
|
override |
|
virtualinherited |
Adds an object pointer to the serialisation records.
Returns a unique identifier for the object.
pointer must be non-null, so you should handle null pointers separately.
You can optionally add some user-defined integer with each record If error checking is on, and the object pointer is null or already in the records, this function will abort()
Definition at line 248 of file vsl_binary_io.cxx.
|
virtualinherited |
Clear the stream's record of any serialisation operations.
Calling this function while outputting serialisable things to stream, will mean that a second copy of an object may get stored to the stream. Calling this function may be required if you change the state of your program whilst you are writing to the same vsl_b_ostream. If the program is at any risk of reallocating the same memory to two different objects controlled by a smart pointer, then calling this function between writing then will prevent them being confused.
Calling this function while outputting serialisable things to stream, will mean that a second copy of an object may get stored to the stream.
Definition at line 233 of file vsl_binary_io.cxx.
| void vsl_b_ofstream::close | ( | ) |
Close the stream.
Definition at line 317 of file vsl_binary_io.cxx.
|
virtualinherited |
Returns a unique identifier for the object.
Returns 0 if there is no record of the object.
Definition at line 260 of file vsl_binary_io.cxx.
|
virtualinherited |
Set the user-defined data associated with the object.
If there is no record of the object, this function will return 0. However a retval of 0 does not necessarily imply that the object is unrecorded.
Definition at line 278 of file vsl_binary_io.cxx.
|
inherited |
Returns true if the underlying stream has its fail bit set.
Definition at line 224 of file vsl_binary_io.cxx.
|
inherited |
A reference to the adaptor's stream.
Definition at line 217 of file vsl_binary_io.cxx.
|
virtualinherited |
Modify the user-defined data associated with the object.
If there is no record of the object, this function will abort.
Definition at line 295 of file vsl_binary_io.cxx.
|
staticinherited |
The length of the b_stream header.
You can move to this offset from the start of the file to get to the first real data item.
Definition at line 93 of file vsl_binary_io.h.
|
protectedinherited |
The member stream.
Definition at line 97 of file vsl_binary_io.h.
|
protectedinherited |
The serialisation records.
Records a pointer, a unique identifier, and an integer (user_defined data.)
Definition at line 117 of file vsl_binary_io.h.
|
staticprotectedinherited |
The version number of the IO scheme.
Definition at line 120 of file vsl_binary_io.h.
1.8.15