Disable all code related to libXp
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / utility / c_streambuf.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: streambuf.h /main/4 1996/06/11 17:39:15 cde-hal $ */
24
25
26 #ifndef _x_streambuf_h
27 #define _x_streambuf_h
28
29 #ifdef EOF
30 #if EOF!=-1
31 #define EOF (-1)
32 #endif
33 #else
34 #define EOF (-1)
35 #endif
36
37
38 typedef long streampos;
39
40
41 #ifdef STREAM_DEBUG
42 #define form x_form 
43 #define streambuf x_streambuf
44 #define filebuf x_filebuf
45 #define ios x_ios
46 #define iostream x_iostream
47 #define istream x_istream
48 #define ostream x_ostream
49 #define fstream x_fstream
50 #define istrstream x_istrstream
51 #define ostrstream x_ostrstream
52 #endif
53
54
55 class streambuf
56 {
57 protected:
58    char* base;
59    char* end;
60    char* put_ptr;
61    char* get_ptr;
62
63    int _size;
64    int _capacity;
65    int _alloc;
66
67    int _pcount;
68    int _gcount;
69
70 protected:
71    enum notify_action_t { GET, PUT };
72    virtual void notify(int) {}; 
73
74    virtual int overflow() { return EOF;};
75    virtual int underflow() { return EOF; };
76
77    int full() { return ( _size == _capacity ) ? 1 : 0 ; };
78    int empty() { return ( _size == 0 ) ? 1 : 0 ; };
79
80    void empty_buffer() {
81       _size = 0;
82       put_ptr = get_ptr = base;
83    };
84
85    int move_get_ptr(int);
86    int move_put_ptr(int);
87
88 public:
89    streambuf();
90    streambuf(char* p, int l, int pHasContent = 0);
91    virtual ~streambuf();
92
93    virtual int examine() ; // EOF: no char available. Otherwise, 
94                                   // return 0.The get_ptr pointer does 
95                                   // not move.
96
97    virtual int get() ; // EOF: can't get a char. Otherwise, 
98                               // return 0. The get_ptr pointer does move.
99
100    virtual int putback(char c) ; // EOF: can't put back. Otherwise, 
101                                 // putback operation is ok.
102    virtual int put(char c) ; // EOF: can't put. Otherwise, 
103                             // put operation is ok.
104
105    int gcount() { return _gcount; };
106    void clear_gcount() { _gcount = 0; };
107
108    int pcount() { return _pcount; };
109    void clear_pcount() { _pcount = 0; };
110
111    virtual int flush() { return EOF; };
112    virtual int seekg(streampos) { return EOF; };
113
114    char* get_buf() { return base; };
115 };
116
117 #endif