PPL  1.2
Parma_Polyhedra_Library::c_streambuf Class Reference

#include <c_streambuf_defs.hh>

Inheritance diagram for Parma_Polyhedra_Library::c_streambuf:
Collaboration diagram for Parma_Polyhedra_Library::c_streambuf:

Public Member Functions

 c_streambuf ()
 Constructor. More...
 
virtual ~c_streambuf ()
 Destructor. 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 Member Functions

virtual size_t cb_read (char *, size_t)
 
virtual size_t cb_write (const char *, size_t)
 
virtual int cb_sync ()
 
virtual int cb_flush ()
 

Private Attributes

int_type unget_char_buf
 Buffer for the last character read. More...
 
int_type next_char_buf
 Buffer for next character. More...
 

Detailed Description

Definition at line 31 of file c_streambuf_defs.hh.

Member Typedef Documentation

Character type of the streambuf.

Definition at line 97 of file c_streambuf_defs.hh.

typedef traits_type::int_type Parma_Polyhedra_Library::c_streambuf::int_type
private

Integer type of the streambuf.

Definition at line 103 of file c_streambuf_defs.hh.

Traits type of the streambuf.

Definition at line 100 of file c_streambuf_defs.hh.

Constructor & Destructor Documentation

Parma_Polyhedra_Library::c_streambuf::c_streambuf ( )
inline

Constructor.

Definition at line 30 of file c_streambuf_inlines.hh.

31  : unget_char_buf(traits_type::eof()), next_char_buf(traits_type::eof()) {
32 }
int_type next_char_buf
Buffer for next character.
int_type unget_char_buf
Buffer for the last character read.
Parma_Polyhedra_Library::c_streambuf::~c_streambuf ( )
virtual

Destructor.

Definition at line 31 of file c_streambuf.cc.

31  {
32 }

Member Function Documentation

virtual int Parma_Polyhedra_Library::c_streambuf::cb_flush ( )
inlineprivatevirtual

Definition at line 120 of file c_streambuf_defs.hh.

120  {
121  return 0;
122  }
virtual size_t Parma_Polyhedra_Library::c_streambuf::cb_read ( char *  ,
size_t   
)
inlineprivatevirtual

Definition at line 111 of file c_streambuf_defs.hh.

Referenced by underflow(), and xsgetn().

111  {
112  return 0;
113  }
virtual int Parma_Polyhedra_Library::c_streambuf::cb_sync ( )
inlineprivatevirtual

Definition at line 117 of file c_streambuf_defs.hh.

Referenced by sync().

117  {
118  return 0;
119  }
virtual size_t Parma_Polyhedra_Library::c_streambuf::cb_write ( const char *  ,
size_t   
)
inlineprivatevirtual

Definition at line 114 of file c_streambuf_defs.hh.

Referenced by overflow(), and xsputn().

114  {
115  return 0;
116  }
c_streambuf::int_type Parma_Polyhedra_Library::c_streambuf::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 98 of file c_streambuf.cc.

References c, cb_write(), and sync().

98  {
99  const int_type eof = traits_type::eof();
100  if (traits_type::eq_int_type(c, eof)) {
101  return (sync() != 0) ? eof : traits_type::not_eof(c);
102  }
103  else {
104  char buf = static_cast<char>(c);
105  if (cb_write(&buf, 1) == 1) {
106  return c;
107  }
108  else {
109  return eof;
110  }
111  }
112 }
virtual int sync()
Synchronizes the stream buffer.
Definition: c_streambuf.cc:115
traits_type::int_type int_type
Integer type of the streambuf.
virtual size_t cb_write(const char *, size_t)
Coefficient c
Definition: PIP_Tree.cc:64
c_streambuf::int_type Parma_Polyhedra_Library::c_streambuf::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 83 of file c_streambuf.cc.

References c, next_char_buf, and unget_char_buf.

83  {
84  const int_type eof = traits_type::eof();
85  next_char_buf = traits_type::eq_int_type(c, eof) ? unget_char_buf : c;
86  unget_char_buf = eof;
87  return next_char_buf;
88 }
int_type next_char_buf
Buffer for next character.
traits_type::int_type int_type
Integer type of the streambuf.
int_type unget_char_buf
Buffer for the last character read.
Coefficient c
Definition: PIP_Tree.cc:64
int Parma_Polyhedra_Library::c_streambuf::sync ( )
protectedvirtual

Synchronizes the stream buffer.

Specified by ISO/IEC 14882:1998: 27.5.2.4.2.

Definition at line 115 of file c_streambuf.cc.

References cb_sync().

Referenced by overflow().

115  {
116  return cb_sync();
117 }
c_streambuf::int_type Parma_Polyhedra_Library::c_streambuf::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 35 of file c_streambuf.cc.

References c, next_char_buf, and underflow().

35  {
36  const int_type c = underflow();
37  next_char_buf = traits_type::eof();
38  return c;
39 }
int_type next_char_buf
Buffer for next character.
traits_type::int_type int_type
Integer type of the streambuf.
virtual int_type underflow()
Gets a character in case of underflow.
Definition: c_streambuf.cc:42
Coefficient c
Definition: PIP_Tree.cc:64
c_streambuf::int_type Parma_Polyhedra_Library::c_streambuf::underflow ( )
protectedvirtual

Gets a character in case of underflow.

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

Definition at line 42 of file c_streambuf.cc.

References cb_read(), and next_char_buf.

Referenced by uflow().

42  {
43  const int_type eof = traits_type::eof();
44  if (traits_type::eq_int_type(next_char_buf, eof)) {
45  char buf;
46  if (cb_read(&buf, 1) == 1) {
47  next_char_buf = buf;
48  }
49  else {
50  next_char_buf = eof;
51  }
52  }
53  return next_char_buf;
54 }
int_type next_char_buf
Buffer for next character.
traits_type::int_type int_type
Integer type of the streambuf.
virtual size_t cb_read(char *, size_t)
std::streamsize Parma_Polyhedra_Library::c_streambuf::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 57 of file c_streambuf.cc.

References cb_read(), next_char_buf, and unget_char_buf.

57  {
58  PPL_ASSERT(n >= 0);
59  if (n == 0) {
60  return n;
61  }
62  const int_type eof = traits_type::eof();
63  const size_t sz_n = static_cast<size_t>(n);
64  size_t a;
65  if (traits_type::eq_int_type(next_char_buf, eof)) {
66  a = 0;
67  }
68  else {
69  s[0] = static_cast<char_type>(next_char_buf);
70  a = 1;
71  }
72  const size_t r = cb_read(s + a, sz_n - a) + a;
73  if (r > 0) {
74  unget_char_buf = traits_type::to_int_type(s[r - 1]);
75  }
76  else {
77  unget_char_buf = traits_type::eof();
78  }
79  return static_cast<std::streamsize>(r);
80 }
int_type next_char_buf
Buffer for next character.
traits_type::int_type int_type
Integer type of the streambuf.
virtual size_t cb_read(char *, size_t)
int_type unget_char_buf
Buffer for the last character read.
char char_type
Character type of the streambuf.
std::streamsize Parma_Polyhedra_Library::c_streambuf::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 91 of file c_streambuf.cc.

References cb_write().

91  {
92  PPL_ASSERT(n >= 0);
93  const size_t r = cb_write(s, static_cast<size_t>(n));
94  return static_cast<std::streamsize>(r);
95 }
virtual size_t cb_write(const char *, size_t)

Member Data Documentation

int_type Parma_Polyhedra_Library::c_streambuf::next_char_buf
private

Buffer for next character.

Definition at line 109 of file c_streambuf_defs.hh.

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

int_type Parma_Polyhedra_Library::c_streambuf::unget_char_buf
private

Buffer for the last character read.

Definition at line 106 of file c_streambuf_defs.hh.

Referenced by pbackfail(), and xsgetn().


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