itpp::bfstream Class Reference
[IT++ File Format]

Binary in/out-file Class. More...

#include <binfile.h>

List of all members.

Public Types

enum  endian { l_endian, b_endian }
 Definition of the endian data type. More...

Public Member Functions

 bfstream (const std::string &name, endian e=b_endian)
 Class constructor that opens a file and sets the endianity.
 bfstream ()
 Class Constructor.
 ~bfstream ()
 Class Destructor.
void open (const std::string &name, bool trunc=false, endian e=b_endian)
 Open a file for reading and writing and set the endianity.
void open_readonly (const std::string &name, endian e=b_endian)
 Open a file for reading only and set the endianity.
int length ()
 Returns the length in bytes of the file.
bfstreamoperator<< (char a)
 Writes an signed char variable to the binary output file.
bfstreamoperator<< (unsigned char a)
 Writes an unsigned char variable to the binary output file.
bfstreamoperator<< (int16_t a)
 Writes a 16-bit signed integer variable to the binary output file.
bfstreamoperator<< (uint16_t a)
 Writes a 16-bit unsigned integer variable to the binary output file.
bfstreamoperator<< (int32_t a)
 Writes a 32-bit signed integer variable to the binary output file.
bfstreamoperator<< (uint32_t a)
 Writes a 32-bit unsigned integer variable to the binary output file.
bfstreamoperator<< (int64_t a)
 Writes a 64-bit signed integer variable to the binary output file.
bfstreamoperator<< (uint64_t a)
 Writes a 64-bit unsigned ingeger variable to the binary output file.
bfstreamoperator<< (float a)
 Writes a float variable to the binary output file.
bfstreamoperator<< (double a)
 Writes a double variable to the binary output file.
bfstreamoperator<< (const char *a)
 Writes a char* string to the binary output file.
bfstreamoperator<< (const std::string &a)
 Writes a string variable to the binary output file.
bfstreamoperator>> (char &a)
 Reads a char variable from the binary output file.
bfstreamoperator>> (unsigned char &a)
 Reads an unsigned char variable from the binary output file.
bfstreamoperator>> (int16_t &a)
 Reads a 16-bit signed integer variable from the binary output file.
bfstreamoperator>> (uint16_t &a)
 Reads a 16-bit unsigned integer variable from the binary output file.
bfstreamoperator>> (int32_t &a)
 Reads a 32-bit signed integer variable from the binary output file.
bfstreamoperator>> (uint32_t &a)
 Reads a 32-bit unsigned integer variable from the binary output file.
bfstreamoperator>> (int64_t &a)
 Reads a 64-bit signed integer variable from the binary output file.
bfstreamoperator>> (uint64_t &a)
 Reads a 64-bit unsigned ingeger variable from the binary output file.
bfstreamoperator>> (float &a)
 Reads a float variable from the binary output file.
bfstreamoperator>> (double &a)
 Reads a double variable from the binary output file.
bfstreamoperator>> (char *a)
 Reads a char* string from the binary output file.
bfstreamoperator>> (std::string &a)
 Reads a string variable from the binary output file.
endian get_endianity () const
 Returns the endianity of the class.
endian get_native_endianity () const
 Returns the native endianity for this computer architecture.
void set_endianity (endian e)
 Set the endianity for this class.
void set_native_endianity ()
 Set the endianity of this class to the native endianity for this computer architecture.

Protected Attributes

bool switch_endianity
 Indicates if the endianity of the processed data needs to be changed.
endian native_endianity
 The native endianity for this computer architecture.


Detailed Description

Binary in/out-file Class.

Member Enumeration Documentation

enum itpp::bfstream_base::endian [inherited]

Definition of the endian data type.

The Endianness defines the order in which multibyte numbers are stored in the file. The two orders are called "Little Endian" (l_endian ) and "Big Endian" (b_endian ).

"Little Endian" means that the low-order byte of the number is stored at the lowest address (i.e. the little end comes first). "Big Endian" means that the high-order byte of the number is stored in memory at the lowest address (i.e. the big end comes first)


Constructor & Destructor Documentation

itpp::bfstream::bfstream ( const std::string &  name,
endian  e = b_endian 
)

Class constructor that opens a file and sets the endianity.

Parameters:
name The name of the file to open
e Defines the endianity of the class. Possible values are l_endian for "Little Endian" or b_endian for "Big Endian". The default value is b_endian.


Member Function Documentation

endian itpp::bfstream_base::get_native_endianity (  )  const [inline, inherited]

Returns the native endianity for this computer architecture.

Intel processors use "Little Endian" byte ordering while e.g. Motorola processors use "Big Endian" byte ordering.

References itpp::bfstream_base::native_endianity.

Referenced by itpp::it_file_old::write_data_header().

void itpp::bfstream::open ( const std::string &  name,
bool  trunc = false,
endian  e = b_endian 
)

Open a file for reading and writing and set the endianity.

Parameters:
name The name of the file to open
trunc Rewrite the file if it exists (default value is false)
e Defines the endianity of the class (default value is b_endian )

References itpp::bfstream_base::native_endianity, and itpp::bfstream_base::switch_endianity.

Referenced by itpp::it_file_old::open(), itpp::it_file::open(), open_readonly(), and itpp::it_file::pack().

void itpp::bfstream::open_readonly ( const std::string &  name,
endian  e = b_endian 
)

Open a file for reading only and set the endianity.

Parameters:
name The name of the file to open
e Defines the endianity of the class (default value is b_endian )

References itpp::bfstream_base::native_endianity, open(), and itpp::bfstream_base::switch_endianity.

Referenced by itpp::it_ifile_old::open(), and itpp::it_ifile::open().


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

Generated on Tue Jun 2 10:02:18 2009 for mixpp by  doxygen 1.5.8