Public Member Functions | Protected Types | Protected Attributes | List of all members
vsl_b_ifstream Class Reference

An adapter for a std::ifstream to make it suitable for binary IO. More...

#include <vsl_binary_io.h>

Inheritance diagram for vsl_b_ifstream:
Inheritance graph
[legend]

Public Member Functions

 vsl_b_ifstream (const std::string &filename, std::ios::openmode mode=std::ios::in)
 Create this adaptor from a file. More...
 
 vsl_b_ifstream (const char *filename, std::ios::openmode mode=std::ios::in)
 Create this adaptor from a file. More...
 
 ~vsl_b_ifstream () override
 Virtual destructor.so that it can be overloaded. More...
 
void close ()
 Close the stream. More...
 
std::istream & is () 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 void add_serialisation_record (unsigned long serial_number, void *pointer, int other_data=0)
 Adds record of object's unique serial number, and location in memory. More...
 
virtual void * get_serialisation_pointer (unsigned long serial_number) const
 Returns the pointer to the object identified by the unique serial number. More...
 
virtual int get_serialisation_other_data (unsigned long serial_number) const
 Returns the user defined data associated with the unique serial number. More...
 
virtual int set_serialisation_other_data (unsigned long serial_number, int other_data)
 Modify the user-defined data associated with the unique serial number. More...
 
unsigned short version_no () const
 Return the version number of the IO format of the file being read. More...
 

Protected Types

typedef std::map< unsigned long, std::pair< void *, int >, std::less< unsigned long > > serialisation_records_type
 The type of the serialisation records. More...
 

Protected Attributes

std::istream * is_
 The member stream. More...
 
serialisation_records_type serialisation_records_
 The serialisation records,. More...
 
unsigned short version_no_
 

Detailed Description

An adapter for a std::ifstream to make it suitable for binary IO.

Definition at line 238 of file vsl_binary_io.h.

Member Typedef Documentation

◆ serialisation_records_type

typedef std::map<unsigned long, std::pair<void *, int>, std::less<unsigned long> > vsl_b_istream::serialisation_records_type
protectedinherited

The type of the serialisation records.

Definition at line 224 of file vsl_binary_io.h.

Constructor & Destructor Documentation

◆ vsl_b_ifstream() [1/2]

vsl_b_ifstream::vsl_b_ifstream ( const std::string &  filename,
std::ios::openmode  mode = std::ios::in 
)
inline

Create this adaptor from a file.

The adapter will delete the stream automatically on destruction.

Definition at line 243 of file vsl_binary_io.h.

◆ vsl_b_ifstream() [2/2]

vsl_b_ifstream::vsl_b_ifstream ( const char *  filename,
std::ios::openmode  mode = std::ios::in 
)
inline

Create this adaptor from a file.

The adapter will delete the stream automatically on destruction.

Definition at line 249 of file vsl_binary_io.h.

◆ ~vsl_b_ifstream()

vsl_b_ifstream::~vsl_b_ifstream ( )
override

Virtual destructor.so that it can be overloaded.

destructor.so that it can be overloaded.

Definition at line 453 of file vsl_binary_io.cxx.

Member Function Documentation

◆ add_serialisation_record()

void vsl_b_istream::add_serialisation_record ( unsigned long  serial_number,
void *  pointer,
int  other_data = 0 
)
virtualinherited

Adds record of object's unique serial number, and location in memory.

pointer must be non-null, so you should handle null pointers separately.

Adding a null pointer or one that already exists will cause the function to abort(), if debugging is turned on;

You can also store a single integer as other data. Interpretation of this data is entirely up to the client code.

Definition at line 394 of file vsl_binary_io.cxx.

◆ clear_serialisation_records()

void vsl_b_istream::clear_serialisation_records ( )
virtualinherited

Clear the stream's record of any serialisation operations.

Calling this function while inputting serialisable things from a stream, could cause errors during loading unless the records were cleared at a similar point during output.

Definition at line 381 of file vsl_binary_io.cxx.

◆ close()

void vsl_b_ifstream::close ( )

Close the stream.

Definition at line 459 of file vsl_binary_io.cxx.

◆ get_serialisation_other_data()

int vsl_b_istream::get_serialisation_other_data ( unsigned long  serial_number) const
virtualinherited

Returns the user defined data associated with the unique serial number.

Returns 0 if no record has been added.

Definition at line 421 of file vsl_binary_io.cxx.

◆ get_serialisation_pointer()

void * vsl_b_istream::get_serialisation_pointer ( unsigned long  serial_number) const
virtualinherited

Returns the pointer to the object identified by the unique serial number.

Returns 0 if no record has been added.

Definition at line 404 of file vsl_binary_io.cxx.

◆ is()

std::istream & vsl_b_istream::is ( ) const
inherited

A reference to the adaptor's stream.

Definition at line 358 of file vsl_binary_io.cxx.

◆ operator!()

bool vsl_b_istream::operator! ( ) const
inherited

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

Definition at line 372 of file vsl_binary_io.cxx.

◆ set_serialisation_other_data()

int vsl_b_istream::set_serialisation_other_data ( unsigned long  serial_number,
int  other_data 
)
virtualinherited

Modify the user-defined data associated with the unique serial number.

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

Definition at line 438 of file vsl_binary_io.cxx.

◆ version_no()

unsigned short vsl_b_istream::version_no ( ) const
inherited

Return the version number of the IO format of the file being read.

Definition at line 366 of file vsl_binary_io.cxx.

Member Data Documentation

◆ is_

std::istream* vsl_b_istream::is_
protectedinherited

The member stream.

Definition at line 220 of file vsl_binary_io.h.

◆ serialisation_records_

serialisation_records_type vsl_b_istream::serialisation_records_
protectedinherited

The serialisation records,.

The record takes a unique identifier of the object (which would be stored on the stream) and returns the pointer to the object, and an other_data integer.

Definition at line 230 of file vsl_binary_io.h.

◆ version_no_

unsigned short vsl_b_istream::version_no_
protectedinherited

Definition at line 233 of file vsl_binary_io.h.


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