#include <stdiobuf.defs.hh>
Public Member Functions | |
stdiobuf (FILE *file) | |
Constructor. | |
Protected Member Functions | |
virtual int_type | underflow () |
Gets a character in case of underflow. | |
virtual int_type | uflow () |
In case of underflow, gets a character and advances the next pointer. | |
virtual std::streamsize | xsgetn (char_type *s, std::streamsize n) |
Gets a sequence of characters. | |
virtual int_type | pbackfail (int_type c=traits_type::eof()) |
Puts character back in case of backup underflow. | |
virtual std::streamsize | xsputn (const char_type *s, std::streamsize n) |
Writes a sequence of characters. | |
virtual int_type | overflow (int_type c) |
Writes a character in case of overflow. | |
virtual int | sync () |
Synchronizes the stream buffer. | |
Private Types | |
typedef char | char_type |
Character type of the streambuf. | |
typedef std::char_traits < char_type > | traits_type |
Traits type of the streambuf. | |
typedef traits_type::int_type | int_type |
Integer type of the streambuf. | |
Private Attributes | |
FILE * | fp |
The encapsulated stdio file. | |
int_type | ungetc_buf |
Buffer for the last character read. |
Definition at line 30 of file stdiobuf.defs.hh.
typedef char Parma_Polyhedra_Library::stdiobuf::char_type [private] |
typedef std::char_traits<char_type> Parma_Polyhedra_Library::stdiobuf::traits_type [private] |
typedef traits_type::int_type Parma_Polyhedra_Library::stdiobuf::int_type [private] |
Parma_Polyhedra_Library::stdiobuf::stdiobuf | ( | FILE * | file | ) | [inline] |
Constructor.
Definition at line 29 of file stdiobuf.inlines.hh.
00030 : fp(file), ungetc_buf(traits_type::eof()) { 00031 }
stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::underflow | ( | ) | [protected, virtual] |
stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::uflow | ( | ) | [protected, virtual] |
In case of underflow, gets a character and advances the next pointer.
Definition at line 30 of file stdiobuf.cc.
References fp, and ungetc_buf.
00030 { 00031 ungetc_buf = getc(fp); 00032 return ungetc_buf; 00033 }
std::streamsize Parma_Polyhedra_Library::stdiobuf::xsgetn | ( | char_type * | s, | |
std::streamsize | n | |||
) | [protected, virtual] |
Gets a sequence of characters.
Definition at line 42 of file stdiobuf.cc.
References fp, and ungetc_buf.
00042 { 00043 std::streamsize r = fread(s, 1, n, fp); 00044 if (s > 0) 00045 ungetc_buf = traits_type::to_int_type(s[r - 1]); 00046 else 00047 ungetc_buf = traits_type::eof(); 00048 return r; 00049 }
stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::pbackfail | ( | int_type | c = traits_type::eof() |
) | [protected, virtual] |
Puts character back in case of backup underflow.
Definition at line 52 of file stdiobuf.cc.
References fp, and ungetc_buf.
00052 { 00053 const int_type eof = traits_type::eof(); 00054 int_type u = traits_type::eq_int_type(c, eof) ? ungetc_buf : c; 00055 ungetc_buf = eof; 00056 return traits_type::eq_int_type(u, eof) ? eof : ungetc(u, fp); 00057 }
std::streamsize Parma_Polyhedra_Library::stdiobuf::xsputn | ( | const char_type * | s, | |
std::streamsize | n | |||
) | [protected, virtual] |
Writes a sequence of characters.
Definition at line 60 of file stdiobuf.cc.
References fp.
00060 { 00061 return fwrite(s, 1, n, fp); 00062 }
stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::overflow | ( | int_type | c | ) | [protected, virtual] |
Writes a character in case of overflow.
Specified by ISO/IEC 14882:1998: 27.5.2.4.5.
Definition at line 65 of file stdiobuf.cc.
References fp.
00065 { 00066 const int_type eof = traits_type::eof(); 00067 if (traits_type::eq_int_type(c, eof)) 00068 return fflush(fp) ? eof : traits_type::not_eof(c); 00069 else 00070 return putc(c, fp); 00071 }
int Parma_Polyhedra_Library::stdiobuf::sync | ( | ) | [protected, virtual] |
Synchronizes the stream buffer.
Specified by ISO/IEC 14882:1998: 27.5.2.4.2.
Definition at line 74 of file stdiobuf.cc.
References fp.
00074 { 00075 return fflush(fp); 00076 }
FILE* Parma_Polyhedra_Library::stdiobuf::fp [private] |
The encapsulated stdio file.
Definition at line 102 of file stdiobuf.defs.hh.
Referenced by overflow(), pbackfail(), sync(), uflow(), underflow(), xsgetn(), and xsputn().
Buffer for the last character read.
Definition at line 105 of file stdiobuf.defs.hh.
Referenced by pbackfail(), uflow(), and xsgetn().