Binary Outfile Class. More...
#include <itpp/base/binfile.h>
Public Types | |
enum | endian { l_endian, b_endian } |
Definition of the endian data type. More... | |
Public Member Functions | |
bofstream (const std::string &name, endian e=b_endian) | |
Class constructor that opens a file and sets the endianity. | |
bofstream () | |
Class Constructor. | |
~bofstream () | |
Class Destructor. | |
void | open (const std::string &name, bool trunc=false, endian e=b_endian) |
Open a file for writing and set the endianity. | |
bofstream & | operator<< (char a) |
Writes a signed char variable to the binary output file. | |
bofstream & | operator<< (int8_t a) |
Writes a 8-bit signed integer variable to the binary file. | |
bofstream & | operator<< (uint8_t a) |
Writes a 8-bit unsigned integer variable to the binary file. | |
bofstream & | operator<< (int16_t a) |
Writes a 16-bit signed integer variable to the binary output file. | |
bofstream & | operator<< (uint16_t a) |
Writes a 16-bit unsigned integer variable to the binary output file. | |
bofstream & | operator<< (int32_t a) |
Writes a 32-bit signed integer variable to the binary output file. | |
bofstream & | operator<< (uint32_t a) |
Writes a 32-bit unsigned integer variable to the binary output file. | |
bofstream & | operator<< (int64_t a) |
Writes a 64-bit signed integer variable to the binary output file. | |
bofstream & | operator<< (uint64_t a) |
Writes a 64-bit unsigned ingeger variable to the binary output file. | |
bofstream & | operator<< (float a) |
Writes a float variable to the binary output file. | |
bofstream & | operator<< (double a) |
Writes a double variable to the binary output file. | |
bofstream & | operator<< (bin a) |
Writes a binary variable to the binary output file. | |
bofstream & | operator<< (const char *a) |
Writes a char* string to the binary output file. | |
bofstream & | operator<< (const std::string &a) |
Writes a string variable to 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. | |
bool | is_open () |
Open state. | |
void | open (const char *filename, std::ios_base::openmode mode=std::ios_base::out|std::ios_base::binary) |
Method to open corresponding file. | |
void | close () |
Method to close corresponding file. | |
Ofstream_Binfile_Facade & | write (const char *c, std::streamsize n) |
Output multiple characters. | |
Ofstream_Binfile_Facade & | put (const char c) |
Output single char. | |
std::streampos | tellp () |
Get position. | |
Ofstream_Binfile_Facade & | seekp (std::streampos pos) |
Set position. | |
Ofstream_Binfile_Facade & | seekp (std::streamoff pos, std::ios_base::seekdir way) |
Set relative position. | |
Ofstream_Binfile_Facade & | flush () |
Flushes stream buffer. | |
bool | good () const |
This method returns true is stream state is good. | |
bool | eof () const |
This method returns true if eof is reached. | |
bool | fail () const |
This method returns true if either failbit or badbit is set. | |
bool | bad () const |
This method returns true if badbit is set. | |
bool | operator! () const |
Unary not operator to check the stream state. | |
operator bool () const | |
Conversion to bool to validate stream state. | |
std::ios_base::iostate | rdstate () const |
Method to read stream state flags. | |
void | setstate (std::ios_base::iostate state) |
Method to set the stream state (combines already set flags with flags provide by user) | |
void | clear (std::ios_base::iostate state=std::ios_base::goodbit) |
Method to set stream state (overwrites stream state flags) | |
std::ios_base::iostate | exceptions () const |
Method to get the exceptions mask. | |
void | exceptions (std::ios_base::iostate except) |
Method to set the exceptions mask. | |
Protected Member Functions | |
std::ofstream * | stream () |
Access to internal stream for derived classes. | |
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. | |
|
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)
itpp::bofstream::bofstream | ( | const std::string & | name, |
endian | e = b_endian |
||
) |
Class constructor that opens a file and sets the endianity.
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 . Set truncate to true to discard file contents. |
Definition at line 125 of file binfile.cpp.
void itpp::bofstream::open | ( | const std::string & | name, |
bool | trunc = false , |
||
endian | e = b_endian |
||
) |
Open a file for writing and set the endianity.
name | The name of the file to open |
e | Defines the endianity of the class (default value is b_endian ) Set trunc to true to discard file contents. |
Definition at line 130 of file binfile.cpp.
References itpp::bfstream_base::native_endianity, and itpp::bfstream_base::switch_endianity.
|
inlineinherited |
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.
Definition at line 105 of file binfile.h.
Referenced by itpp::it_file_old::write_data_header().
Generated on Sat Jul 6 2013 10:54:30 for IT++ by Doxygen 1.8.2