Macros | Functions
vsl_binary_io.cxx File Reference

Functions to perform consistent binary IO within vsl. More...

#include <cstddef>
#include <map>
#include <cstdlib>
#include "vsl_binary_io.h"
#include <cassert>
#include <vsl/vsl_binary_explicit_io.h>

Go to the source code of this file.

Macros

#define MACRO_MAKE_INTEGER_READ_WRITE(TYPEIN)
 

Functions

template<typename TYPE >
void local_vsl_b_write (vsl_b_ostream &os, const TYPE n)
 
template<typename TYPE >
void local_vsl_b_read (vsl_b_istream &is, TYPE &n)
 
 MACRO_MAKE_INTEGER_READ_WRITE (int)
 
 MACRO_MAKE_INTEGER_READ_WRITE (unsigned int)
 
 MACRO_MAKE_INTEGER_READ_WRITE (short)
 
 MACRO_MAKE_INTEGER_READ_WRITE (unsigned short)
 
 MACRO_MAKE_INTEGER_READ_WRITE (long)
 
 MACRO_MAKE_INTEGER_READ_WRITE (unsigned long)
 
void vsl_b_write (vsl_b_ostream &os, char n)
 Write char to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, char &n)
 Read char from vsl_b_istream. More...
 
void vsl_b_write (vsl_b_ostream &os, signed char n)
 Write signed char to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, signed char &n)
 Read signed char from vsl_b_istream. More...
 
void vsl_b_write (vsl_b_ostream &os, unsigned char n)
 Write to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, unsigned char &n)
 Read from vsl_b_istream. More...
 
void vsl_b_write (vsl_b_ostream &os, const std::string &str)
 Write to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, std::string &str)
 Read from vsl_b_istream. More...
 
void vsl_b_write (vsl_b_ostream &os, const char *s)
 Write to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, char *s)
 Read from vsl_b_istream. More...
 
void vsl_b_write (vsl_b_ostream &os, bool b)
 Write bool to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, bool &b)
 Read bool from vsl_b_istream. More...
 
void vsl_b_write (vsl_b_ostream &os, float n)
 Write to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, float &n)
 Read from vsl_b_istream. More...
 
void vsl_b_write (vsl_b_ostream &os, double n)
 Write to vsl_b_ostream. More...
 
void vsl_b_read (vsl_b_istream &is, double &n)
 Read from vsl_b_istream. More...
 
bool vsl_b_istream_test (std::istream &is)
 Test to see if a stream really is a binary vsl file. More...
 

Detailed Description

Functions to perform consistent binary IO within vsl.

Author
Tim Cootes and Ian Scott

Definition in file vsl_binary_io.cxx.

Macro Definition Documentation

◆ MACRO_MAKE_INTEGER_READ_WRITE

#define MACRO_MAKE_INTEGER_READ_WRITE (   TYPEIN)
Value:
void vsl_b_write(vsl_b_ostream& os,TYPEIN n ) \
{ \
local_vsl_b_write<TYPEIN>(os,n); \
} \
\
void vsl_b_read(vsl_b_istream &is,TYPEIN& n ) \
{ \
local_vsl_b_read<TYPEIN>(is,n); \
}
A binary output adaptor for any std::ostream.
Definition: vsl_binary_io.h:37
void vsl_b_write(vsl_b_ostream &os, char n)
Write char to vsl_b_ostream.
std::istream & is() const
A reference to the adaptor's stream.
void vsl_b_read(vsl_b_istream &is, char &n)
Read char from vsl_b_istream.
An adaptor for any std::istream to make it suitable for binary input.

Definition at line 51 of file vsl_binary_io.cxx.

Function Documentation

◆ local_vsl_b_read()

template<typename TYPE >
void local_vsl_b_read ( vsl_b_istream is,
TYPE &  n 
)

Definition at line 27 of file vsl_binary_io.cxx.

◆ local_vsl_b_write()

template<typename TYPE >
void local_vsl_b_write ( vsl_b_ostream os,
const TYPE  n 
)

Definition at line 18 of file vsl_binary_io.cxx.

◆ MACRO_MAKE_INTEGER_READ_WRITE() [1/6]

MACRO_MAKE_INTEGER_READ_WRITE ( int  )

◆ MACRO_MAKE_INTEGER_READ_WRITE() [2/6]

MACRO_MAKE_INTEGER_READ_WRITE ( unsigned int  )

◆ MACRO_MAKE_INTEGER_READ_WRITE() [3/6]

MACRO_MAKE_INTEGER_READ_WRITE ( short  )

◆ MACRO_MAKE_INTEGER_READ_WRITE() [4/6]

MACRO_MAKE_INTEGER_READ_WRITE ( unsigned short  )

◆ MACRO_MAKE_INTEGER_READ_WRITE() [5/6]

MACRO_MAKE_INTEGER_READ_WRITE ( long  )

◆ MACRO_MAKE_INTEGER_READ_WRITE() [6/6]

MACRO_MAKE_INTEGER_READ_WRITE ( unsigned long  )

◆ vsl_b_istream_test()

bool vsl_b_istream_test ( std::istream &  is)

Test to see if a stream really is a binary vsl file.

Returns
false if we can't find magic numbers and correct version number. The file pointer is reset to the beginning on leaving this function.

Definition at line 471 of file vsl_binary_io.cxx.

◆ vsl_b_read() [1/8]

void vsl_b_read ( vsl_b_istream is,
char &  n 
)

Read char from vsl_b_istream.

Definition at line 87 of file vsl_binary_io.cxx.

◆ vsl_b_read() [2/8]

void vsl_b_read ( vsl_b_istream is,
signed char &  n 
)

Read signed char from vsl_b_istream.

Definition at line 98 of file vsl_binary_io.cxx.

◆ vsl_b_read() [3/8]

void vsl_b_read ( vsl_b_istream is,
unsigned char &  n 
)

Read from vsl_b_istream.

Definition at line 110 of file vsl_binary_io.cxx.

◆ vsl_b_read() [4/8]

void vsl_b_read ( vsl_b_istream is,
std::string &  str 
)

Read from vsl_b_istream.

Definition at line 126 of file vsl_binary_io.cxx.

◆ vsl_b_read() [5/8]

void vsl_b_read ( vsl_b_istream is,
char *  s 
)

Read from vsl_b_istream.

Deprecated:
in favour of std::string version.
Note
You must preallocate enough space at s for expected length of string. This function is easy to crash mith a malformed data file.

Definition at line 150 of file vsl_binary_io.cxx.

◆ vsl_b_read() [6/8]

void vsl_b_read ( vsl_b_istream is,
bool &  b 
)

Read bool from vsl_b_istream.

Definition at line 168 of file vsl_binary_io.cxx.

◆ vsl_b_read() [7/8]

void vsl_b_read ( vsl_b_istream is,
float &  n 
)

Read from vsl_b_istream.

Definition at line 181 of file vsl_binary_io.cxx.

◆ vsl_b_read() [8/8]

void vsl_b_read ( vsl_b_istream is,
double &  n 
)

Read from vsl_b_istream.

Definition at line 193 of file vsl_binary_io.cxx.

◆ vsl_b_write() [1/8]

void vsl_b_write ( vsl_b_ostream os,
char  n 
)

Write char to vsl_b_ostream.

Definition at line 82 of file vsl_binary_io.cxx.

◆ vsl_b_write() [2/8]

void vsl_b_write ( vsl_b_ostream os,
signed char  n 
)

Write signed char to vsl_b_ostream.

Definition at line 93 of file vsl_binary_io.cxx.

◆ vsl_b_write() [3/8]

void vsl_b_write ( vsl_b_ostream os,
unsigned char  n 
)

Write to vsl_b_ostream.

Definition at line 105 of file vsl_binary_io.cxx.

◆ vsl_b_write() [4/8]

void vsl_b_write ( vsl_b_ostream os,
const std::string &  str 
)

Write to vsl_b_ostream.

Definition at line 117 of file vsl_binary_io.cxx.

◆ vsl_b_write() [5/8]

void vsl_b_write ( vsl_b_ostream os,
const char *  s 
)

Write to vsl_b_ostream.

Deprecated:
in favour of std::string version.

Definition at line 138 of file vsl_binary_io.cxx.

◆ vsl_b_write() [6/8]

void vsl_b_write ( vsl_b_ostream os,
bool  b 
)

Write bool to vsl_b_ostream.

Definition at line 160 of file vsl_binary_io.cxx.

◆ vsl_b_write() [7/8]

void vsl_b_write ( vsl_b_ostream os,
float  n 
)

Write to vsl_b_ostream.

Number is saved with ANSI/IEEE Standard 754-1985 single precision.

Definition at line 175 of file vsl_binary_io.cxx.

◆ vsl_b_write() [8/8]

void vsl_b_write ( vsl_b_ostream os,
double  n 
)

Write to vsl_b_ostream.

Number is saved with ANSI/IEEE Standard 754-1985 double precision.

Definition at line 187 of file vsl_binary_io.cxx.