1 /* c_streambuf class declaration.
2    Copyright (C) 2001-2010 Roberto Bagnara <bagnara@cs.unipr.it>
3    Copyright (C) 2010-2016 BUGSENG srl (http://bugseng.com)
4 
5 This file is part of the Parma Polyhedra Library (PPL).
6 
7 The PPL is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 The PPL is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software Foundation,
19 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307, USA.
20 
21 For the most up-to-date information see the Parma Polyhedra Library
22 site: http://bugseng.com/products/ppl/ . */
23 
24 #ifndef PPL_c_streambuf_defs_hh
25 #define PPL_c_streambuf_defs_hh 1
26 
27 #include "c_streambuf_types.hh"
28 #include <streambuf>
29 #include <cstddef>
30 
31 class Parma_Polyhedra_Library::c_streambuf
32   : public std::basic_streambuf<char, std::char_traits<char> > {
33 public:
34   //! Constructor.
35   c_streambuf();
36 
37   //! Destructor.
38   virtual ~c_streambuf();
39 
40 protected:
41   /*! \brief
42     Gets a character in case of underflow.
43 
44     \remarks
45     Specified by ISO/IEC 14882:1998: 27.5.2.4.3.
46   */
47   virtual int_type underflow();
48 
49   /*! \brief
50     In case of underflow, gets a character and advances the next pointer.
51 
52     \remarks
53     Specified by ISO/IEC 14882:1998: 27.5.2.4.3.
54   */
55   virtual int_type uflow();
56 
57   /*! \brief
58     Gets a sequence of characters.
59 
60     \remarks
61     Specified by ISO/IEC 14882:1998: 27.5.2.4.3.
62   */
63   virtual std::streamsize xsgetn(char_type* s, std::streamsize n);
64 
65   /*! \brief
66     Puts character back in case of backup underflow.
67 
68     \remarks
69     Specified by ISO/IEC 14882:1998: 27.5.2.4.4.
70   */
71   virtual int_type pbackfail(int_type c = traits_type::eof());
72 
73   /*! \brief
74     Writes a sequence of characters.
75 
76     \remarks
77     Specified by ISO/IEC 14882:1998: 27.5.2.4.5.
78   */
79   virtual std::streamsize xsputn(const char_type* s, std::streamsize n);
80 
81   /*! \brief
82     Writes a character in case of overflow.
83 
84     Specified by ISO/IEC 14882:1998: 27.5.2.4.5.
85   */
86   virtual int_type overflow(int_type c);
87 
88   /*! \brief
89     Synchronizes the stream buffer.
90 
91     Specified by ISO/IEC 14882:1998: 27.5.2.4.2.
92   */
93   virtual int sync();
94 
95 private:
96   //! Character type of the streambuf.
97   typedef char char_type;
98 
99   //! Traits type of the streambuf.
100   typedef std::char_traits<char_type> traits_type;
101 
102   //! Integer type of the streambuf.
103   typedef traits_type::int_type int_type;
104 
105   //! Buffer for the last character read.
106   int_type unget_char_buf;
107 
108   //! Buffer for next character
109   int_type next_char_buf;
110 
cb_read(char *,size_t)111   virtual size_t cb_read(char *, size_t) {
112     return 0;
113   }
cb_write(const char *,size_t)114   virtual size_t cb_write(const char *, size_t) {
115     return 0;
116   }
cb_sync()117   virtual int cb_sync() {
118     return 0;
119   }
cb_flush()120   virtual int cb_flush() {
121     return 0;
122   }
123 };
124 
125 #include "c_streambuf_inlines.hh"
126 
127 #endif // !defined(PPL_c_streambuf_defs_hh)
128