Public Member Functions | Static Public Attributes | Protected Types | Protected Attributes | Static Protected Attributes
vsl_b_ofstream Class Reference

An adapter for a vcl_ofstream to make it suitable for binary IO. More...

#include <vsl_binary_io.h>

Inheritance diagram for vsl_b_ofstream:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 vsl_b_ofstream (const vcl_string &filename, vcl_ios_openmode mode=vcl_ios_out|vcl_ios_trunc)
 Create this adaptor from a file.
 vsl_b_ofstream (const char *filename, vcl_ios_openmode mode=vcl_ios_out|vcl_ios_trunc)
 Create this adaptor from a file.
virtual ~vsl_b_ofstream ()
 Virtual destructor.
void close ()
 Close the stream.
vcl_ostream & os () const
 A reference to the adaptor's stream.
bool operator! () const
 Returns true if the underlying stream has its fail bit set.
virtual void clear_serialisation_records ()
 Clear the stream's record of any serialisation operations.
virtual unsigned long add_serialisation_record (void *pointer, int other_data=0)
 Adds an object pointer to the serialisation records.
virtual unsigned long get_serial_number (void *pointer) const
 Returns a unique identifier for the object.
virtual int get_serialisation_other_data (void *pointer) const
 Set the user-defined data associated with the object.
virtual int set_serialisation_other_data (void *pointer, int other_data)
 Modify the user-defined data associated with the object.

Static Public Attributes

static const vcl_streamoff header_length = 6
 The length of the b_stream header.

Protected Types

typedef vcl_map< void
*, vcl_pair< unsigned long,
int >, vcl_less< void * > > 
serialisation_records_type
 The type of the serialisation records.

Protected Attributes

vcl_ostream * os_
 The member stream.
serialisation_records_type serialisation_records_
 The serialisation records.

Static Protected Attributes

static const unsigned short version_no_ = 1
 The version number of the IO scheme.

Detailed Description

An adapter for a vcl_ofstream to make it suitable for binary IO.

Definition at line 119 of file vsl_binary_io.h.


Member Typedef Documentation

typedef vcl_map<void *, vcl_pair<unsigned long, int>, vcl_less<void *> > vsl_b_ostream::serialisation_records_type [protected, inherited]

The type of the serialisation records.

Definition at line 106 of file vsl_binary_io.h.


Constructor & Destructor Documentation

vsl_b_ofstream::vsl_b_ofstream ( const vcl_string &  filename,
vcl_ios_openmode  mode = vcl_ios_out | vcl_ios_trunc 
) [inline]

Create this adaptor from a file.

The adapter will delete the internal stream automatically on destruction.

Definition at line 124 of file vsl_binary_io.h.

vsl_b_ofstream::vsl_b_ofstream ( const char *  filename,
vcl_ios_openmode  mode = vcl_ios_out | vcl_ios_trunc 
) [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.

vsl_b_ofstream::~vsl_b_ofstream ( ) [virtual]

Virtual destructor.

destructor.

Definition at line 550 of file vsl_binary_io.cxx.


Member Function Documentation

unsigned long vsl_b_ostream::add_serialisation_record ( void *  pointer,
int  other_data = 0 
) [virtual, inherited]

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 488 of file vsl_binary_io.cxx.

void vsl_b_ostream::clear_serialisation_records ( ) [virtual, inherited]

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.

Definition at line 473 of file vsl_binary_io.cxx.

void vsl_b_ofstream::close ( )

Close the stream.

Definition at line 557 of file vsl_binary_io.cxx.

unsigned long vsl_b_ostream::get_serial_number ( void *  pointer) const [virtual, inherited]

Returns a unique identifier for the object.

Returns 0 if there is no record of the object.

Definition at line 500 of file vsl_binary_io.cxx.

int vsl_b_ostream::get_serialisation_other_data ( void *  pointer) const [virtual, inherited]

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 518 of file vsl_binary_io.cxx.

bool vsl_b_ostream::operator! ( ) const [inherited]

Returns true if the underlying stream has its fail bit set.

Definition at line 464 of file vsl_binary_io.cxx.

vcl_ostream & vsl_b_ostream::os ( ) const [inherited]

A reference to the adaptor's stream.

Definition at line 457 of file vsl_binary_io.cxx.

int vsl_b_ostream::set_serialisation_other_data ( void *  pointer,
int  other_data 
) [virtual, inherited]

Modify the user-defined data associated with the object.

If there is no record of the object, this function will abort.

Definition at line 535 of file vsl_binary_io.cxx.


Member Data Documentation

const vcl_streamoff vsl_b_ostream::header_length = 6 [static, inherited]

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 87 of file vsl_binary_io.h.

vcl_ostream* vsl_b_ostream::os_ [protected, inherited]

The member stream.

Definition at line 91 of file vsl_binary_io.h.

The serialisation records.

Records a pointer, a unique identifier, and an integer (user_defined data.)

Definition at line 111 of file vsl_binary_io.h.

const unsigned short vsl_b_ostream::version_no_ = 1 [static, protected, inherited]

The version number of the IO scheme.

Definition at line 114 of file vsl_binary_io.h.


The documentation for this class was generated from the following files: