ReactOS 0.4.15-dev-7918-g2a2556c
_strstream.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * This material is provided "as is", with absolutely no warranty expressed
9 * or implied. Any use is at your own risk.
10 *
11 * Permission to use or copy this software for any purpose is hereby granted
12 * without fee, provided the above notices are retained on all copies.
13 * Permission to modify the code and to distribute modified code is granted,
14 * provided the above notices are retained, and a notice that the code was
15 * modified is included with the above copyright notice.
16 *
17 */
18#ifndef _STLP_INTERNAL_STRSTREAM
19#define _STLP_INTERNAL_STRSTREAM
20
21#ifndef _STLP_INTERNAL_STREAMBUF
22# include <stl/_streambuf.h>
23#endif
24
25#ifndef _STLP_INTERNAL_ISTREAM
26# include <stl/_istream.h> // Includes <ostream>, <ios>, <iosfwd>
27#endif
28
29#ifndef _STLP_INTERNAL_STRING_H
30# include <stl/_string.h>
31#endif
32
34
35#ifndef _STLP_USE_NAMESPACES
36# define strstream _STLP_strstream
37# define ostrstream _STLP_ostrstream
38# define istrstream _STLP_istrstream
39# define strstreambuf _STLP_strstreambuf
40#endif
41
42//----------------------------------------------------------------------
43// Class strstreambuf, a streambuf class that manages an array of char.
44// Note that this class is not a template.
45
46class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf<char, char_traits<char> > {
47public: // Types.
50 typedef void* (*__alloc_fn)(size_t);
51 typedef void (*__free_fn)(void*);
52public: // Constructor, destructor
53
54 explicit strstreambuf(streamsize _Initial_capacity = 0);
55
56 strstreambuf(__alloc_fn, __free_fn);
57
58 strstreambuf(char* __get, streamsize __n, char* __put = 0);
59 strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0);
60 strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
61
62 strstreambuf(const char* __get, streamsize __n);
63 strstreambuf(const signed char* __get, streamsize __n);
64 strstreambuf(const unsigned char* __get, streamsize __n);
65
66 virtual ~strstreambuf();
67
68public: // strstreambuf operations.
69 void freeze(bool = true);
70 char* str();
71 int pcount() const;
72
73protected: // Overridden virtual member functions.
74 virtual int_type overflow(int_type __c = _Traits::eof());
75 virtual int_type pbackfail(int_type __c = _Traits::eof());
76 virtual int_type underflow();
77 virtual _Base* setbuf(char* __buf, streamsize __n);
78 virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
80 = ios_base::in | ios_base::out);
81 virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
82 = ios_base::in | ios_base::out);
83
84private: // Helper functions.
85 // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun.
86 char* _M_alloc(size_t);
87 void _M_free(char*);
88
89 // Helper function used in constructors.
90 void _M_setup(char* __get, char* __put, streamsize __n);
91private: // Data members.
92 __alloc_fn _M_alloc_fun;
93 __free_fn _M_free_fun;
94 bool _M_dynamic : 1;
95 bool _M_frozen : 1;
96 bool _M_constant : 1;
97};
98
99//----------------------------------------------------------------------
100// Class istrstream, an istream that manages a strstreambuf.
101
102class _STLP_CLASS_DECLSPEC istrstream : public basic_istream<char, char_traits<char> > {
103public:
104 explicit istrstream(char*);
105 explicit istrstream(const char*);
106 istrstream(char* , streamsize);
107 istrstream(const char*, streamsize);
108 virtual ~istrstream();
109
110 strstreambuf* rdbuf() const;
111 char* str();
112
113private:
115};
116
117//----------------------------------------------------------------------
118// Class ostrstream
119
120class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream<char, char_traits<char> >
121{
122public:
123 ostrstream();
124 ostrstream(char*, int, ios_base::openmode = ios_base::out);
125 virtual ~ostrstream();
126
127 strstreambuf* rdbuf() const;
128 void freeze(bool = true);
129 char* str();
130 int pcount() const;
131
132private:
134};
135
136//----------------------------------------------------------------------
137// Class strstream
138
139class _STLP_CLASS_DECLSPEC strstream : public basic_iostream<char, char_traits<char> > {
140public:
141 typedef char char_type;
145
146 strstream();
147 strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out);
148 virtual ~strstream();
149
150 strstreambuf* rdbuf() const;
151 void freeze(bool = true);
152 int pcount() const;
153 char* str();
154
155private:
157
158 //explicitely defined as private to avoid warnings:
160 strstream& operator = (strstream const&);
161};
162
164
165#endif /* _STLP_INTERNAL_STRSTREAM */
return __n
Definition: _algo.h:75
#define istrstream
Definition: _strstream.h:38
#define strstream
Definition: _strstream.h:36
#define strstreambuf
Definition: _strstream.h:39
#define ostrstream
Definition: _strstream.h:37
ptrdiff_t streamsize
Definition: char_traits.h:81
virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out)
Definition: _streambuf.c:193
virtual int_type underflow()
Definition: _streambuf.c:170
virtual int_type pbackfail(int_type=traits_type::eof())
Definition: _streambuf.c:150
virtual pos_type seekpos(pos_type, ios_base::openmode=ios_base::in|ios_base::out)
Definition: _streambuf.c:188
virtual int_type overflow(int_type=traits_type::eof())
Definition: _streambuf.c:156
virtual basic_streambuf< _CharT, _Traits > * setbuf(char_type *, streamsize)
Definition: _streambuf.c:199
int openmode
Definition: _ios_base.h:59
int seekdir
Definition: _ios_base.h:60
strstreambuf _M_buf
Definition: _strstream.h:114
strstreambuf _M_buf
Definition: _strstream.h:133
char char_type
Definition: _strstream.h:141
strstream(strstream const &)
char_traits< char >::int_type int_type
Definition: _strstream.h:142
char_traits< char >::pos_type pos_type
Definition: _strstream.h:143
strstreambuf _M_buf
Definition: _strstream.h:156
char_traits< char >::off_type off_type
Definition: _strstream.h:144
__alloc_fn _M_alloc_fun
Definition: _strstream.h:92
char_traits< char > _Traits
Definition: _strstream.h:48
bool _M_constant
Definition: _strstream.h:96
bool _M_dynamic
Definition: _strstream.h:94
bool _M_frozen
Definition: _strstream.h:95
basic_streambuf< char, char_traits< char > > _Base
Definition: _strstream.h:49
__free_fn _M_free_fun
Definition: _strstream.h:93
__kernel_size_t size_t
Definition: linux.h:237
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
const WCHAR * str
#define __c
Definition: schilyio.h:209