-
Notifications
You must be signed in to change notification settings - Fork 1
/
cdsSStream.hh
116 lines (87 loc) · 2.65 KB
/
cdsSStream.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef __cdsSStream_hh__
#define __cdsSStream_hh__
#include <iostream>
#include <cstdio>
#include <cdsString.hh>
using namespace std;
// stream based on CDSString class
//
// FIX: currently only works with CHAR==char
//
//
template <class CHAR>
class CDSStringStreamBuf : public streambuf
{
public:
CDSStringStreamBuf();
CDSStringStreamBuf(const CDSString<CHAR>& s);
virtual ~CDSStringStreamBuf();
CDSString<CHAR> str() { return str_; }
private:
CDSString<CHAR> str_;
void setup(CDSString<CHAR> get,
CDSString<CHAR> put);
protected: // Overridden virtual member functions.
virtual int underflow();
//virtual int_type uflow();
virtual int pbackfail(int __c = EOF);
virtual int overflow(int __c = EOF);
virtual streambuf* setbuf(char* __buf, int len);
// virtual streampos seekoff(streamoff __off, ios::seek_dir __dir,
// int openmode= ios::in|ios::out);
// virtual streampos seekpos(streampos __pos, int openmode=ios::in | ios::out);
};
////----------------------------------------------------------------------
//// CDSIStreamString: istream that manages a CDSStringStreamBuf.
template<class CHAR>
class CDSIStringStream : public istream
{
public:
explicit CDSIStringStream( const CDSString<CHAR>& );
explicit CDSIStringStream(const CHAR*);
//CDSIStringStream(CHAR* , streamsize);
//CDSIStringStream(const CHAR*, streamsize);
virtual ~CDSIStringStream();
//CDSStringStreamBuf<CHAR>* rdbuf() const;
CDSString<CHAR> str() { return buf.str(); }
private:
CDSStringStreamBuf<CHAR> buf;
};
//----------------------------------------------------------------------
// CDSOStreamString: Ostream that manages a CDSStringStreamBuf.
template<class CHAR>
class CDSOStringStream : public ostream
{
public:
CDSOStringStream();
//ostrstream(char*, int, ios_base::openmode = ios_base::out);
virtual ~CDSOStringStream();
//CDSStringStreamBuf<CHAR>* rdbuf() const;
CDSString<CHAR> str() { return buf.str(); }
private:
CDSStringStreamBuf<CHAR> buf;
};
template<class CHAR>
class CDSStringStream : public iostream
{
public:
CDSStringStream();
// CDSStringStream(CDSString<CHAR>&, int,
// std::ios_base::openmode =
// std::ios_base::in | std::ios_base::out);
virtual ~CDSStringStream();
//CDSStringStreamBuf<CHAR>* rdbuf() const;
//void freeze(bool = true);
//int pcount() const;
CDSString<CHAR> str() { return buf.str(); }
private:
CDSStringStreamBuf<CHAR> buf;
#ifdef TESTING
public:
static int test();
#endif
};
typedef CDSStringStream<char> StringStream;
typedef CDSOStringStream<char> OStringStream;
typedef CDSIStringStream<char> IStringStream;
#endif /* __cdsSStream_hh__ */