Parma_Polyhedra_Library::stdiobuf Class Reference

#include <stdiobuf.defs.hh>

List of all members.

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.

Detailed Description

Definition at line 31 of file stdiobuf.defs.hh.


Member Typedef Documentation

Character type of the streambuf.

Definition at line 90 of file stdiobuf.defs.hh.

typedef traits_type::int_type Parma_Polyhedra_Library::stdiobuf::int_type [private]

Integer type of the streambuf.

Definition at line 96 of file stdiobuf.defs.hh.

typedef std::char_traits<char_type> Parma_Polyhedra_Library::stdiobuf::traits_type [private]

Traits type of the streambuf.

Definition at line 93 of file stdiobuf.defs.hh.


Constructor & Destructor Documentation

Parma_Polyhedra_Library::stdiobuf::stdiobuf ( FILE *  file  )  [inline]

Constructor.

Definition at line 30 of file stdiobuf.inlines.hh.

00031   : fp(file), ungetc_buf(traits_type::eof()) {
00032 }


Member Function Documentation

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.

00066                              {
00067   const int_type eof = traits_type::eof();
00068   if (traits_type::eq_int_type(c, eof))
00069     return fflush(fp) ? eof : traits_type::not_eof(c);
00070   else
00071     return putc(c, fp);

stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::pbackfail ( int_type  c = traits_type::eof()  )  [protected, virtual]

Puts character back in case of backup underflow.

Remarks:
Specified by ISO/IEC 14882:1998: 27.5.2.4.4.

Definition at line 52 of file stdiobuf.cc.

References fp, and ungetc_buf.

00053                               {
00054   const int_type eof = traits_type::eof();
00055   int_type u = traits_type::eq_int_type(c, eof) ? ungetc_buf : c;
00056   ungetc_buf = eof;
00057   return traits_type::eq_int_type(u, eof) ? eof : ungetc(u, fp);

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.

00075                {
00076   return fflush(fp);

stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::uflow (  )  [protected, virtual]

In case of underflow, gets a character and advances the next pointer.

Remarks:
Specified by ISO/IEC 14882:1998: 27.5.2.4.3.

Definition at line 30 of file stdiobuf.cc.

References fp, and ungetc_buf.

00031                 {
00032   ungetc_buf = getc(fp);
00033   return ungetc_buf;

stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::underflow (  )  [protected, virtual]

Gets a character in case of underflow.

Remarks:
Specified by ISO/IEC 14882:1998: 27.5.2.4.3.

Definition at line 36 of file stdiobuf.cc.

References fp.

00037                     {
00038   int_type c = getc(fp);
00039   return ungetc(c, fp);

std::streamsize Parma_Polyhedra_Library::stdiobuf::xsgetn ( char_type s,
std::streamsize  n 
) [protected, virtual]

Gets a sequence of characters.

Remarks:
Specified by ISO/IEC 14882:1998: 27.5.2.4.3.

Definition at line 42 of file stdiobuf.cc.

References fp, and ungetc_buf.

00043                                               {
00044   std::streamsize r = fread(s, 1, n, fp);
00045   if (r > 0)
00046     ungetc_buf = traits_type::to_int_type(s[r - 1]);
00047   else
00048     ungetc_buf = traits_type::eof();
00049   return r;

std::streamsize Parma_Polyhedra_Library::stdiobuf::xsputn ( const char_type s,
std::streamsize  n 
) [protected, virtual]

Writes a sequence of characters.

Remarks:
Specified by ISO/IEC 14882:1998: 27.5.2.4.5.

Definition at line 60 of file stdiobuf.cc.

References fp.

00061                                                     {
00062   return fwrite(s, 1, n, fp);


Member Data Documentation

The encapsulated stdio file.

Definition at line 99 of file stdiobuf.defs.hh.

Referenced by overflow(), pbackfail(), sync(), uflow(), underflow(), xsgetn(), and xsputn().

Buffer for the last character read.

Definition at line 102 of file stdiobuf.defs.hh.

Referenced by pbackfail(), uflow(), and xsgetn().


The documentation for this class was generated from the following files:
Generated on Sun Feb 27 16:20:22 2011 for PPL by  doxygen 1.6.3