Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5496 | leency | 1 | /* |
2 | * Copyright (c) 1998 |
||
3 | * Silicon Graphics Computer Systems, Inc. |
||
4 | * |
||
5 | * Permission to use, copy, modify, distribute and sell this software |
||
6 | * and its documentation for any purpose is hereby granted without fee, |
||
7 | * provided that the above copyright notice appear in all copies and |
||
8 | * that both that copyright notice and this permission notice appear |
||
9 | * in supporting documentation. Silicon Graphics makes no |
||
10 | * representations about the suitability of this software for any |
||
11 | * purpose. It is provided "as is" without express or implied warranty. |
||
12 | */ |
||
13 | |||
14 | // WARNING: The classes defined in this header are DEPRECATED. This |
||
15 | // header is defined in section D.7.1 of the C++ standard, and it |
||
16 | // MAY BE REMOVED in a future standard revision. You should use the |
||
17 | // header |
||
18 | |||
19 | #ifndef __SGI_STL_STRSTREAM |
||
20 | #define __SGI_STL_STRSTREAM |
||
21 | |||
22 | #include "backward_warning.h" |
||
23 | #include |
||
24 | #include |
||
25 | #include |
||
26 | #include |
||
27 | #include |
||
28 | |||
29 | namespace std |
||
30 | { |
||
31 | |||
32 | //---------------------------------------------------------------------- |
||
33 | // Class strstreambuf, a streambuf class that manages an array of char. |
||
34 | // Note that this class is not a template. |
||
35 | |||
36 | class strstreambuf : public basic_streambuf |
||
37 | { |
||
38 | public: // Types. |
||
39 | typedef char_traits |
||
40 | typedef basic_streambuf |
||
41 | |||
42 | public: // Constructor, destructor |
||
43 | explicit strstreambuf(streamsize __initial_capacity = 0); |
||
44 | strstreambuf(void* (*__alloc)(size_t), void (*__free)(void*)); |
||
45 | |||
46 | strstreambuf(char* __get, streamsize __n, char* __put = 0); |
||
47 | strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0); |
||
48 | strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0); |
||
49 | |||
50 | strstreambuf(const char* __get, streamsize __n); |
||
51 | strstreambuf(const signed char* __get, streamsize __n); |
||
52 | strstreambuf(const unsigned char* __get, streamsize __n); |
||
53 | |||
54 | virtual ~strstreambuf(); |
||
55 | |||
56 | public: // strstreambuf operations. |
||
57 | void freeze(bool = true); |
||
58 | char* str(); |
||
59 | int pcount() const; |
||
60 | |||
61 | protected: // Overridden virtual member functions. |
||
62 | virtual int_type overflow(int_type __c = _Traits::eof()); |
||
63 | virtual int_type pbackfail(int_type __c = _Traits::eof()); |
||
64 | virtual int_type underflow(); |
||
65 | virtual _Base* setbuf(char* __buf, streamsize __n); |
||
66 | virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, |
||
67 | ios_base::openmode __mode |
||
68 | = ios_base::in | ios_base::out); |
||
69 | virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode |
||
70 | = ios_base::in | ios_base::out); |
||
71 | |||
72 | private: // Helper functions. |
||
73 | // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. |
||
74 | char* _M_alloc(size_t); |
||
75 | void _M_free(char*); |
||
76 | |||
77 | // Helper function used in constructors. |
||
78 | void _M_setup(char* __get, char* __put, streamsize __n); |
||
79 | |||
80 | private: // Data members. |
||
81 | void* (*_M_alloc_fun)(size_t); |
||
82 | void (*_M_free_fun)(void*); |
||
83 | |||
84 | bool _M_dynamic : 1; |
||
85 | bool _M_frozen : 1; |
||
86 | bool _M_constant : 1; |
||
87 | }; |
||
88 | |||
89 | //---------------------------------------------------------------------- |
||
90 | // Class istrstream, an istream that manages a strstreambuf. |
||
91 | |||
92 | class istrstream : public basic_istream |
||
93 | { |
||
94 | public: |
||
95 | explicit istrstream(char*); |
||
96 | explicit istrstream(const char*); |
||
97 | istrstream(char* , streamsize); |
||
98 | istrstream(const char*, streamsize); |
||
99 | virtual ~istrstream(); |
||
100 | |||
101 | strstreambuf* rdbuf() const; |
||
102 | char* str(); |
||
103 | |||
104 | private: |
||
105 | strstreambuf _M_buf; |
||
106 | }; |
||
107 | |||
108 | //---------------------------------------------------------------------- |
||
109 | // Class ostrstream |
||
110 | |||
111 | class ostrstream : public basic_ostream |
||
112 | { |
||
113 | public: |
||
114 | ostrstream(); |
||
115 | ostrstream(char*, int, ios_base::openmode = ios_base::out); |
||
116 | virtual ~ostrstream(); |
||
117 | |||
118 | strstreambuf* rdbuf() const; |
||
119 | void freeze(bool = true); |
||
120 | char* str(); |
||
121 | int pcount() const; |
||
122 | |||
123 | private: |
||
124 | strstreambuf _M_buf; |
||
125 | }; |
||
126 | |||
127 | //---------------------------------------------------------------------- |
||
128 | // Class strstream |
||
129 | |||
130 | class strstream : public basic_iostream |
||
131 | { |
||
132 | public: |
||
133 | typedef char char_type; |
||
134 | typedef char_traits |
||
135 | typedef char_traits |
||
136 | typedef char_traits |
||
137 | |||
138 | strstream(); |
||
139 | strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); |
||
140 | virtual ~strstream(); |
||
141 | |||
142 | strstreambuf* rdbuf() const; |
||
143 | void freeze(bool = true); |
||
144 | int pcount() const; |
||
145 | char* str(); |
||
146 | |||
147 | private: |
||
148 | strstreambuf _M_buf; |
||
149 | }; |
||
150 | |||
151 | } // namespace std |
||
152 | |||
153 | #endif /* __SGI_STL_STRSTREAM */ |
||
154 | |||
155 | // Local Variables: |
||
156 | // mode:C++ |
||
157 | // End: |
||
158 |