Binary Infile 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 | |
bifstream (const std::string &name, endian e=b_endian) | |
Class constructor that opens a file and sets the endianity. | |
bifstream () | |
Class Constructor. | |
~bifstream () | |
Class Destructor. | |
void | open (const std::string &name, endian e=b_endian) |
Open a file for reading and set the endianity. | |
int | length () |
Returns the length in bytes of the file. | |
bifstream & | operator>> (char &a) |
Reads a signed char variable from the binary input file. | |
bifstream & | operator>> (int8_t &a) |
Reads a 8-bit signed integer variable from the binary input file. | |
bifstream & | operator>> (uint8_t &a) |
Reads a 8-bit unsigned integer variable from the binary input file. | |
bifstream & | operator>> (int16_t &a) |
Reads a 16-bit signed integer variable from the binary input file. | |
bifstream & | operator>> (uint16_t &a) |
Reads a 16-bit unsigned integer variable from the binary input file. | |
bifstream & | operator>> (int32_t &a) |
Reads a 32-bit signed integer variable from the binary input file. | |
bifstream & | operator>> (uint32_t &a) |
Reads a 32-bit unsigned integer variable from the binary input file. | |
bifstream & | operator>> (int64_t &a) |
Reads a 64-bit signed integer variable from the binary input file. | |
bifstream & | operator>> (uint64_t &a) |
Reads a 64-bit unsigned ingeger variable from the binary input file. | |
bifstream & | operator>> (float &a) |
Reads a float variable from the binary input file. | |
bifstream & | operator>> (double &a) |
Reads a double variable from the binary input file. | |
bifstream & | operator>> (bin &a) |
Reads a binary variable from the binary input file. | |
bifstream & | operator>> (char *a) |
Reads a char* string from the binary input file. | |
bifstream & | operator>> (std::string &a) |
Reads a string variable from the binary input 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::in|std::ios_base::binary) |
Method to open corresponding file. | |
void | close () |
Method to close corresponding file. | |
std::streamsize | gcount () const |
Last extracted chars count. | |
int | get () |
Get single char. | |
Ifstream_Binfile_Facade & | get (char &c) |
Get single char. | |
Ifstream_Binfile_Facade & | get (char *s, std::streamsize n) |
Get multiple chars to c-string and add trailing 0. | |
Ifstream_Binfile_Facade & | get (char *s, std::streamsize n, char delim) |
Get multiple chars to c-string without trailing 0. | |
Ifstream_Binfile_Facade & | getline (char *s, std::streamsize n) |
Get multiple chars to c-string without trailing 0. | |
Ifstream_Binfile_Facade & | getline (char *s, std::streamsize n, char delim) |
Ifstream_Binfile_Facade & | ignore (std::streamsize n=1, int delim=EOF) |
Extract and ignore chars. | |
int | peek () |
Peak single char from the top of the buffer. | |
Ifstream_Binfile_Facade & | read (char *s, std::streamsize n) |
Read n chars from stream. | |
std::streamsize | readsome (char *s, std::streamsize n) |
Read up to n available chars from stream. | |
Ifstream_Binfile_Facade & | putback (char c) |
This method attempts to put back single char. | |
Ifstream_Binfile_Facade & | unget () |
Unget last extracted char. | |
std::streampos | tellg () |
Get position. | |
Ifstream_Binfile_Facade & | seekg (std::streampos pos) |
Set position. | |
Ifstream_Binfile_Facade & | seekg (std::streamoff pos, std::ios_base::seekdir way) |
Set relative position. | |
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::ifstream * | 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::bifstream::bifstream | ( | 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 . |
Definition at line 231 of file binfile.cpp.
itpp::bifstream::bifstream | ( | ) |
Class Constructor.
Definition at line 234 of file binfile.cpp.
void itpp::bifstream::open | ( | const std::string & | name, |
endian | e = b_endian ) |
Open a file for reading and set the endianity.
name | The name of the file to open |
e | Defines the endianity of the class (default value is b_endian ) |
Definition at line 236 of file binfile.cpp.
References itpp::bfstream_base::native_endianity, itpp::binfile_details::Ifstream_Binfile_Facade::open(), and itpp::bfstream_base::switch_endianity.
int itpp::bifstream::length | ( | ) |
Returns the length in bytes of the file.
Definition at line 245 of file binfile.cpp.
References itpp::binfile_details::Ifstream_Binfile_Facade::seekg(), and itpp::binfile_details::Ifstream_Binfile_Facade::tellg().
bifstream & itpp::bifstream::operator>> | ( | char & | a | ) |
Reads a signed char variable from the binary input file.
Definition at line 255 of file binfile.cpp.
References itpp::binfile_details::Ifstream_Binfile_Facade::get().
bifstream & itpp::bifstream::operator>> | ( | int8_t & | a | ) |
Reads a 8-bit signed integer variable from the binary input file.
Definition at line 261 of file binfile.cpp.
References itpp::binfile_details::Ifstream_Binfile_Facade::get(), and it_assert.
bifstream & itpp::bifstream::operator>> | ( | uint8_t & | a | ) |
Reads a 8-bit unsigned integer variable from the binary input file.
Definition at line 270 of file binfile.cpp.
References itpp::binfile_details::Ifstream_Binfile_Facade::get(), and it_assert.
bifstream & itpp::bifstream::operator>> | ( | int16_t & | a | ) |
Reads a 16-bit signed integer variable from the binary input file.
Definition at line 279 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | uint16_t & | a | ) |
Reads a 16-bit unsigned integer variable from the binary input file.
Definition at line 285 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | int32_t & | a | ) |
Reads a 32-bit signed integer variable from the binary input file.
Definition at line 291 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | uint32_t & | a | ) |
Reads a 32-bit unsigned integer variable from the binary input file.
Definition at line 297 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | int64_t & | a | ) |
Reads a 64-bit signed integer variable from the binary input file.
Definition at line 303 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | uint64_t & | a | ) |
Reads a 64-bit unsigned ingeger variable from the binary input file.
Definition at line 309 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | float & | a | ) |
Reads a float variable from the binary input file.
Definition at line 315 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | double & | a | ) |
Reads a double variable from the binary input file.
Definition at line 321 of file binfile.cpp.
References itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
Reads a binary variable from the binary input file.
Definition at line 327 of file binfile.cpp.
References it_assert, itpp::read_endian(), and itpp::bfstream_base::switch_endianity.
bifstream & itpp::bifstream::operator>> | ( | char * | a | ) |
Reads a char* string from the binary input file.
Definition at line 337 of file binfile.cpp.
References itpp::binfile_details::Ifstream_Binfile_Facade::getline().
bifstream & itpp::bifstream::operator>> | ( | std::string & | a | ) |
Reads a string variable from the binary input file.
Definition at line 343 of file binfile.cpp.
References itpp::binfile_details::Ifstream_Binfile_Facade::stream().
|
inlineinherited |
|
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().
|
inlineinherited |
Set the endianity for this class.
Definition at line 110 of file binfile.h.
Referenced by itpp::it_ifile_old::read_data_header(), and itpp::it_file_old::write_data_header_here().
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Get single char.
Definition at line 264 of file binfile.h.
Referenced by itpp::binfile_details::Ifstream_Binfile_Facade::get(), itpp::binfile_details::Ifstream_Binfile_Facade::get(), itpp::binfile_details::Ifstream_Binfile_Facade::get(), operator>>(), operator>>(), and operator>>().
|
inlineinherited |
Get single char.
Definition at line 266 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::get().
|
inlineinherited |
Get multiple chars to c-string and add trailing 0.
Definition at line 268 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::get().
|
inlineinherited |
Get multiple chars to c-string without trailing 0.
Definition at line 271 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::get().
|
inlineinherited |
Get multiple chars to c-string without trailing 0.
Definition at line 274 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::getline().
Referenced by itpp::binfile_details::Ifstream_Binfile_Facade::getline(), and operator>>().
|
inlineinherited |
|
inlineinherited |
Extract and ignore chars.
Definition at line 279 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::ignore().
Referenced by itpp::binfile_details::Ifstream_Binfile_Facade::ignore().
|
inlineinherited |
|
inlineinherited |
Read n chars from stream.
Definition at line 284 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::read().
Referenced by itpp::binfile_details::Ifstream_Binfile_Facade::read().
|
inlineinherited |
|
inlineinherited |
This method attempts to put back single char.
Definition at line 290 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::putback().
Referenced by itpp::binfile_details::Ifstream_Binfile_Facade::putback().
|
inlineinherited |
Unget last extracted char.
Definition at line 293 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::unget().
Referenced by itpp::binfile_details::Ifstream_Binfile_Facade::unget().
|
inlineinherited |
|
inlineinherited |
Set position.
Definition at line 297 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::seekg().
Referenced by length(), itpp::binfile_details::Ifstream_Binfile_Facade::seekg(), and itpp::binfile_details::Ifstream_Binfile_Facade::seekg().
|
inlineinherited |
Set relative position.
Definition at line 300 of file binfile.h.
References itpp::binfile_details::Ifstream_Binfile_Facade::seekg().
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineprotectedinherited |
Access to internal stream for derived classes.
Definition at line 332 of file binfile.h.
Referenced by operator>>().
|
protectedinherited |
Indicates if the endianity of the processed data needs to be changed.
Definition at line 125 of file binfile.h.
Referenced by itpp::bfstream_base::bfstream_base(), itpp::bfstream::open(), open(), itpp::bofstream::open(), itpp::bfstream::open_readonly(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bfstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bofstream::operator<<(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), itpp::bfstream::operator>>(), operator>>(), operator>>(), operator>>(), operator>>(), operator>>(), operator>>(), operator>>(), operator>>(), and operator>>().
|
protectedinherited |
The native endianity for this computer architecture.
Definition at line 127 of file binfile.h.
Referenced by itpp::bfstream_base::bfstream_base(), itpp::bfstream::open(), open(), itpp::bofstream::open(), and itpp::bfstream::open_readonly().
Generated on Tue Dec 10 2024 04:49:37 for IT++ by Doxygen 1.12.0