Go to the documentation of this file.
32 #include <itpp/itexports.h>
39 #pragma warning( disable : 4250 )
49 bool exist(
const std::string& name);
89 if (switch_endianity) {
90 if (native_endianity == l_endian)
96 return native_endianity;
111 if (native_endianity == e)
112 switch_endianity =
false;
114 switch_endianity =
true;
130 namespace binfile_details
161 std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary);
165 void open (
const char * filename,
166 std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary )
167 {_str->open(filename,mode);}
173 {_str->
write(c,n);
return *
this;}
176 {_str->
put(c);
return *
this;};
179 {
return _str->tellp();}
182 {_str->
seekp(pos);
return *
this;}
185 {_str->
seekp(pos,way);
return *
this;}
188 {_str->
flush();
return *
this;}
191 bool good()
const {
return _str->good();}
193 bool eof()
const {
return _str->eof();}
195 bool fail()
const {
return _str->fail();}
197 bool bad()
const {
return _str->bad();}
202 operator bool()
const {
return _str->good();}
205 std::ios_base::iostate
rdstate()
const {
return _str->rdstate();}
207 void setstate (std::ios_base::iostate state) {_str->setstate(state);}
209 void clear (std::ios_base::iostate state = std::ios_base::goodbit) {_str->clear(state);}
211 std::ios_base::iostate
exceptions()
const {
return _str->exceptions();}
213 void exceptions (std::ios_base::iostate except) {_str->exceptions(except);}
251 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::binary);
254 {
return _str->is_open();}
256 void open (
const char * filename,
257 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::binary)
258 {_str->open(filename,mode);}
262 std::streamsize
gcount()
const {
return _str->gcount();}
264 int get() {
return _str->get();}
269 {_str->
get(s,n);
return *
this;}
272 {_str->
get(s,n,delim);
return *
this;}
275 {_str->
getline(s,n);
return *
this;}
277 {_str->
getline(s,n,delim);
return *
this;}
280 {_str->
ignore(n,delim);
return *
this;}
282 int peek() {
return _str->peek();}
285 {_str->
read(s,n);
return *
this;}
287 std::streamsize
readsome (
char* s, std::streamsize n)
288 {
return _str->readsome(s,n);}
291 {_str->
putback(c);
return *
this;}
295 std::streampos
tellg() {
return _str->tellg();}
298 {_str->
seekg(pos);
return *
this;}
301 {_str->
seekg(pos,way);
return *
this;}
304 bool good()
const {
return _str->good();}
306 bool eof()
const {
return _str->eof();}
308 bool fail()
const {
return _str->fail();}
310 bool bad()
const {
return _str->bad();}
315 operator bool()
const {
return _str->good();}
318 std::ios_base::iostate
rdstate()
const {
return _str->rdstate();}
320 void setstate (std::ios_base::iostate state) {_str->setstate(state);}
322 void clear (std::ios_base::iostate state = std::ios_base::goodbit) {_str->clear(state);}
324 std::ios_base::iostate
exceptions()
const {
return _str->exceptions();}
326 void exceptions (std::ios_base::iostate except) {_str->exceptions(except);}
365 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out | std::ios_base::binary);
369 void open (
const char * filename,
370 std::ios_base::openmode mode = std::ios_base::in | std::ios_base::out | std::ios_base::binary)
371 {_str->open(filename,mode);}
377 {_str->
write(c,n);
return *
this;};
380 {_str->
put(c);
return *
this;};
382 std::streampos
tellp() {
return _str->tellp();}
385 {_str->
seekp(pos);
return *
this;}
388 {_str->
seekp(pos,way);
return *
this;}
392 std::streamsize
gcount()
const {
return _str->gcount();}
394 int get() {
return _str->get();}
399 {_str->
get(s,n);
return *
this;}
402 {_str->
get(s,n,delim);
return *
this;}
405 {_str->
getline(s,n);
return *
this;}
407 {_str->
getline(s,n,delim);
return *
this;}
410 {_str->
ignore(n,delim);
return *
this;}
412 int peek() {
return _str->peek();}
415 {_str->
read(s,n);
return *
this;}
417 std::streamsize
readsome (
char* s, std::streamsize n)
418 {
return _str->readsome(s,n);}
421 {_str->
putback(c);
return *
this;}
424 {_str->
unget();
return *
this;}
426 std::streampos
tellg() {
return _str->tellg();}
429 {_str->
seekg(pos);
return *
this;}
432 {_str->
seekg(pos,way);
return *
this;}
435 bool good()
const {
return _str->good();}
437 bool eof()
const {
return _str->eof();}
439 bool fail()
const {
return _str->fail();}
441 bool bad()
const {
return _str->bad();}
446 operator bool()
const {
return _str->good();}
449 std::ios_base::iostate
rdstate()
const {
return _str->rdstate();}
451 void setstate (std::ios_base::iostate state) {_str->setstate(state);}
453 void clear (std::ios_base::iostate state = std::ios_base::goodbit)
454 {_str->clear(state);}
456 std::ios_base::iostate
exceptions()
const {
return _str->exceptions();}
458 void exceptions (std::ios_base::iostate except) {_str->exceptions(except);}
502 void open(
const std::string& name,
bool trunc =
false, endian e = b_endian);
564 void open(
const std::string& name, endian e = b_endian);
630 void open(
const std::string& name,
bool trunc =
false, endian e = b_endian);
639 void open_readonly(
const std::string& name, endian e = b_endian);
706 #endif // #ifndef BINFILE_H
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
Ifstream_Binfile_Facade & get(char *s, std::streamsize n, char delim)
Get multiple chars to c-string without trailing 0.
std::ios_base::iostate rdstate() const
Method to read stream state flags.
Fstream_Binfile_Facade & put(const char c)
Output single char.
std::streamsize gcount() const
Last extracted chars count.
std::streampos tellp()
Get position.
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::out|std::ios_base::binary)
Method to open corresponding file.
std::streampos tellp()
Get position.
void set_native_endianity()
Set the endianity of this class to the native endianity for this computer architecture.
Base class for binary file classes.
Fstream_Binfile_Facade & getline(char *s, std::streamsize n)
Get multiple chars to c-string without trailing 0.
Fstream_Binfile_Facade & flush()
Flushes stream buffer.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
bool fail() const
This method returns true if either failbit or badbit is set.
int get()
Get single char.
bool good() const
This method returns true is stream state is good.
Binary arithmetic (boolean) class.
void setstate(std::ios_base::iostate state)
Method to set the stream state (combines already set flags with flags provide by user)
Fstream_Binfile_Facade & read(char *s, std::streamsize n)
Read n chars from stream.
std::streampos tellg()
Get position.
bool is_open()
Open state.
int peek()
Peak single char from the top of the buffer.
Ifstream_Binfile_Facade & ignore(std::streamsize n=1, int delim=EOF)
Extract and ignore chars.
bool bad() const
This method returns true if badbit is set.
Binary in/out-file Class.
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.
Ifstream_Binfile_Facade & get(char &c)
Get single char.
Ofstream_Binfile_Facade & seekp(std::streamoff pos, std::ios_base::seekdir way)
Set relative position.
void clear(std::ios_base::iostate state=std::ios_base::goodbit)
Method to set stream state (overwrites stream state flags)
void set_endianity(endian e)
Set the endianity for this class.
bool eof() const
This method returns true if eof is reached.
std::streamsize readsome(char *s, std::streamsize n)
Read up to n available chars from stream.
Ifstream_Binfile_Facade & read(char *s, std::streamsize n)
Read n chars from stream.
std::ifstream * stream()
Access to internal stream for derived classes.
Ifstream_Binfile_Facade & getline(char *s, std::streamsize n)
Get multiple chars to c-string without trailing 0.
Ifstream_Binfile_Facade & seekg(std::streampos pos)
Set position.
Ifstream_Binfile_Facade & unget()
Unget last extracted char.
bool bad() const
This method returns true if 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.
std::ios_base::iostate exceptions() const
Method to get the exceptions mask.
Fstream_Binfile_Facade & seekp(std::streamoff pos, std::ios_base::seekdir way)
Set relative position.
Fstream_Binfile_Facade & get(char *s, std::streamsize n)
Get multiple chars to c-string and add trailing 0.
bool switch_endianity
Indicates if the endianity of the processed data needs to be changed.
std::ios_base::iostate exceptions() const
Method to get the exceptions mask.
Fstream_Binfile_Facade & get(char &c)
Get single char.
bool operator!() const
Unary not operator to check the stream state.
Ofstream Interface Facade for Binary Streams.
Ofstream_Binfile_Facade & flush()
Flushes stream buffer.
void exceptions(std::ios_base::iostate except)
Method to set the exceptions mask.
int length(const Vec< T > &v)
Length of vector.
Ifstream Interface Facade for Binary Streams.
void clear(std::ios_base::iostate state=std::ios_base::goodbit)
Method to set stream state (overwrites stream state flags)
Fstream_Binfile_Facade & write(const char *c, std::streamsize n)
Output multiple characters.
Ofstream_Binfile_Facade & put(const char c)
Output single char.
std::streamsize gcount() const
Last extracted chars count.
std::streampos tellg()
Get position.
std::ofstream * stream()
Access to internal stream for derived classes.
Fstream_Binfile_Facade & seekg(std::streampos pos)
Set position.
void close()
Method to close corresponding file.
Fstream_Binfile_Facade & seekp(std::streampos pos)
Set position.
int peek()
Peak single char from the top of the buffer.
void exceptions(std::ios_base::iostate except)
Method to set the exceptions mask.
Ofstream_Binfile_Facade & seekp(std::streampos pos)
Set position.
std::ios_base::iostate rdstate() const
Method to read stream state flags.
void close()
Method to close corresponding file.
bool eof() const
This method returns true if eof is reached.
Fstream_Binfile_Facade & get(char *s, std::streamsize n, char delim)
Get multiple chars to c-string without trailing 0.
endian
Definition of the endian data type.
bool is_open()
Open state.
std::fstream * stream()
Access to internal stream for derived classes.
std::ios_base::iostate exceptions() const
Method to get the exceptions mask.
bool is_open()
Open state.
void close()
Method to close corresponding file.
endian get_endianity() const
Returns the endianity of the class.
void setstate(std::ios_base::iostate state)
Method to set the stream state (combines already set flags with flags provide by user)
endian native_endianity
The native endianity for this computer architecture.
bool fail() const
This method returns true if either failbit or badbit is set.
int get()
Get single char.
Fstream Interface Facade for Binary Streams.
bool good() const
This method returns true is stream state is good.
bool operator!() const
Unary not operator to check the stream state.
bool fail() const
This method returns true if either failbit or badbit is set.
std::streamsize readsome(char *s, std::streamsize n)
Read up to n available chars from stream.
endian get_native_endianity() const
Returns the native endianity for this computer architecture.
Ifstream_Binfile_Facade & get(char *s, std::streamsize n)
Get multiple chars to c-string and add trailing 0.
std::ios_base::iostate rdstate() const
Method to read stream state flags.
Ofstream_Binfile_Facade & write(const char *c, std::streamsize n)
Output multiple characters.
~bfstream()
Class Destructor.
~bifstream()
Class Destructor.
Fstream_Binfile_Facade & ignore(std::streamsize n=1, int delim=EOF)
Extract and ignore chars.
Fstream_Binfile_Facade & seekg(std::streamoff pos, std::ios_base::seekdir way)
Set relative position.
Ifstream_Binfile_Facade & putback(char c)
This method attempts to put back single char.
void clear(std::ios_base::iostate state=std::ios_base::goodbit)
Method to set stream state (overwrites 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)
Fstream_Binfile_Facade & unget()
Unget last extracted char.
void exceptions(std::ios_base::iostate except)
Method to set the exceptions mask.
~bofstream()
Class Destructor.
bool exist(const std::string &name)
Checks if a file named name already exists on the disk.
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::out|std::ios_base::binary)
Method to open corresponding file.
Fstream_Binfile_Facade & putback(char c)
This method attempts to put back single char.
void open(const char *filename, std::ios_base::openmode mode=std::ios_base::in|std::ios_base::binary)
Method to open corresponding file.
Generated on Sun Jan 3 2021 11:31:33 for IT++ by Doxygen 1.8.20