PPL  1.2
Parma_Polyhedra_Library::stdiobuf Class Reference

#include <stdiobuf_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::stdiobuf:
Collaboration diagram for Parma_Polyhedra_Library::stdiobuf:

Public Member Functions

 stdiobuf (FILE *file)
 Constructor. More...
 

Protected Member Functions

virtual int_type underflow ()
 Gets a character in case of underflow. More...
 
virtual int_type uflow ()
 In case of underflow, gets a character and advances the next pointer. More...
 
virtual std::streamsize xsgetn (char_type *s, std::streamsize n)
 Gets a sequence of characters. More...
 
virtual int_type pbackfail (int_type c=traits_type::eof())
 Puts character back in case of backup underflow. More...
 
virtual std::streamsize xsputn (const char_type *s, std::streamsize n)
 Writes a sequence of characters. More...
 
virtual int_type overflow (int_type c)
 Writes a character in case of overflow. More...
 
virtual int sync ()
 Synchronizes the stream buffer. More...
 

Private Types

typedef char char_type
 Character type of the streambuf. More...
 
typedef std::char_traits< char_typetraits_type
 Traits type of the streambuf. More...
 
typedef traits_type::int_type int_type
 Integer type of the streambuf. More...
 

Private Attributes

FILE * fp
 The encapsulated stdio file. More...
 
int_type unget_char_buf
 Buffer for the last character read. More...
 

Detailed Description

Definition at line 31 of file stdiobuf_defs.hh.

Member Typedef Documentation

Character type of the streambuf.

Definition at line 94 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 100 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 97 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.

31  : fp(file), unget_char_buf(traits_type::eof()) {
32 }
FILE * fp
The encapsulated stdio file.
int_type unget_char_buf
Buffer for the last character read.

Member Function Documentation

stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::overflow ( int_type  c)
protectedvirtual

Writes a character in case of overflow.

Specified by ISO/IEC 14882:1998: 27.5.2.4.5.

Definition at line 73 of file stdiobuf.cc.

References fp.

73  {
74  const int_type eof = traits_type::eof();
75  if (traits_type::eq_int_type(c, eof)) {
76  return (fflush(fp) != 0) ? eof : traits_type::not_eof(c);
77  }
78  else {
79  return putc(c, fp);
80  }
81 }
FILE * fp
The encapsulated stdio file.
Coefficient c
Definition: PIP_Tree.cc:64
traits_type::int_type int_type
Integer type of the streambuf.
stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::pbackfail ( int_type  c = traits_type::eof())
protectedvirtual

Puts character back in case of backup underflow.

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

Definition at line 58 of file stdiobuf.cc.

References c, fp, and unget_char_buf.

58  {
59  const int_type eof = traits_type::eof();
60  const int_type u = traits_type::eq_int_type(c, eof) ? unget_char_buf : c;
61  unget_char_buf = eof;
62  return traits_type::eq_int_type(u, eof) ? eof : ungetc(u, fp);
63 }
FILE * fp
The encapsulated stdio file.
int_type unget_char_buf
Buffer for the last character read.
Coefficient c
Definition: PIP_Tree.cc:64
traits_type::int_type int_type
Integer type of the streambuf.
int Parma_Polyhedra_Library::stdiobuf::sync ( )
protectedvirtual

Synchronizes the stream buffer.

Specified by ISO/IEC 14882:1998: 27.5.2.4.2.

Definition at line 84 of file stdiobuf.cc.

References fp.

84  {
85  return fflush(fp);
86 }
FILE * fp
The encapsulated stdio file.
stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::uflow ( )
protectedvirtual

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 33 of file stdiobuf.cc.

References fp, and unget_char_buf.

33  {
34  unget_char_buf = getc(fp);
35  return unget_char_buf;
36 }
FILE * fp
The encapsulated stdio file.
int_type unget_char_buf
Buffer for the last character read.
stdiobuf::int_type Parma_Polyhedra_Library::stdiobuf::underflow ( )
protectedvirtual

Gets a character in case of underflow.

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

Definition at line 39 of file stdiobuf.cc.

References c, and fp.

39  {
40  const int_type c = getc(fp);
41  return ungetc(c, fp);
42 }
FILE * fp
The encapsulated stdio file.
Coefficient c
Definition: PIP_Tree.cc:64
traits_type::int_type int_type
Integer type of the streambuf.
std::streamsize Parma_Polyhedra_Library::stdiobuf::xsgetn ( char_type s,
std::streamsize  n 
)
protectedvirtual

Gets a sequence of characters.

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

Definition at line 45 of file stdiobuf.cc.

References fp, and unget_char_buf.

45  {
46  PPL_ASSERT(n >= 0);
47  const size_t r = fread(s, 1, static_cast<size_t>(n), fp);
48  if (r > 0) {
49  unget_char_buf = traits_type::to_int_type(s[r - 1]);
50  }
51  else {
52  unget_char_buf = traits_type::eof();
53  }
54  return static_cast<std::streamsize>(r);
55 }
FILE * fp
The encapsulated stdio file.
int_type unget_char_buf
Buffer for the last character read.
std::streamsize Parma_Polyhedra_Library::stdiobuf::xsputn ( const char_type s,
std::streamsize  n 
)
protectedvirtual

Writes a sequence of characters.

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

Definition at line 66 of file stdiobuf.cc.

References fp.

66  {
67  PPL_ASSERT(n >= 0);
68  const size_t r = fwrite(s, 1, static_cast<size_t>(n), fp);
69  return static_cast<std::streamsize>(r);
70 }
FILE * fp
The encapsulated stdio file.

Member Data Documentation

FILE* Parma_Polyhedra_Library::stdiobuf::fp
private

The encapsulated stdio file.

Definition at line 103 of file stdiobuf_defs.hh.

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

int_type Parma_Polyhedra_Library::stdiobuf::unget_char_buf
private

Buffer for the last character read.

Definition at line 106 of file stdiobuf_defs.hh.

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


The documentation for this class was generated from the following files: