ReactOS  0.4.15-dev-3287-gfec35dc
_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 
46 class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf<char, char_traits<char> > {
47 public: // Types.
50  typedef void* (*__alloc_fn)(size_t);
51  typedef void (*__free_fn)(void*);
52 public: // 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 
68 public: // strstreambuf operations.
69  void freeze(bool = true);
70  char* str();
71  int pcount() const;
72 
73 protected: // Overridden virtual member functions.
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,
79  ios_base::openmode __mode
81  virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
83 
84 private: // 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);
91 private: // 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 
102 class _STLP_CLASS_DECLSPEC istrstream : public basic_istream<char, char_traits<char> > {
103 public:
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 
113 private:
115 };
116 
117 //----------------------------------------------------------------------
118 // Class ostrstream
119 
120 class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream<char, char_traits<char> >
121 {
122 public:
123  ostrstream();
125  virtual ~ostrstream();
126 
127  strstreambuf* rdbuf() const;
128  void freeze(bool = true);
129  char* str();
130  int pcount() const;
131 
132 private:
134 };
135 
136 //----------------------------------------------------------------------
137 // Class strstream
138 
139 class _STLP_CLASS_DECLSPEC strstream : public basic_iostream<char, char_traits<char> > {
140 public:
141  typedef char char_type;
145 
146  strstream();
148  virtual ~strstream();
149 
150  strstreambuf* rdbuf() const;
151  void freeze(bool = true);
152  int pcount() const;
153  char* str();
154 
155 private:
157 
158  //explicitely defined as private to avoid warnings:
159  strstream(strstream const&);
161 };
162 
164 
165 #endif /* _STLP_INTERNAL_STRSTREAM */
char_traits< char > ::int_type int_type
Definition: _streambuf.h:54
char_traits< char >::pos_type pos_type
Definition: _strstream.h:143
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
virtual pos_type seekpos(pos_type, ios_base::openmode=ios_base::in|ios_base::out)
Definition: _streambuf.c:188
return __n
Definition: _algo.h:75
basic_streambuf< _CharT, _Traits > * rdbuf() const
Definition: _ios.h:72
strstreambuf _M_buf
Definition: _strstream.h:133
virtual int_type pbackfail(int_type=traits_type::eof())
Definition: _streambuf.c:150
void operator=(const ios_base &)
basic_streambuf< char, char_traits< char > > _Base
Definition: _strstream.h:49
int seekdir
Definition: _ios_base.h:60
#define __c
Definition: schilyio.h:209
#define strstreambuf
Definition: _strstream.h:39
char_traits< char >::off_type off_type
Definition: _strstream.h:144
bool _M_constant
Definition: _strstream.h:96
char_traits< char > ::pos_type pos_type
Definition: _streambuf.h:55
char_traits< char >::int_type int_type
Definition: _strstream.h:142
const WCHAR * str
__free_fn _M_free_fun
Definition: _strstream.h:93
bool _M_frozen
Definition: _strstream.h:95
virtual int_type overflow(int_type=traits_type::eof())
Definition: _streambuf.c:156
strstreambuf _M_buf
Definition: _strstream.h:156
virtual pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode=ios_base::in|ios_base::out)
Definition: _streambuf.c:193
#define strstream
Definition: _strstream.h:36
__kernel_size_t size_t
Definition: linux.h:237
__alloc_fn _M_alloc_fun
Definition: _strstream.h:92
int openmode
Definition: _ios_base.h:59
static FILE * out
Definition: regtests2xml.c:44
char char_type
Definition: _strstream.h:141
strstreambuf _M_buf
Definition: _strstream.h:114
#define _STLP_CLASS_DECLSPEC
Definition: features.h:983
_Check_return_ _CRTIMP int __cdecl __cdecl eof(_In_ int _FileHandle)
GLuint in
Definition: glext.h:9616
char_traits< char > _Traits
Definition: _strstream.h:48
virtual basic_streambuf< _CharT, _Traits > * setbuf(char_type *, streamsize)
Definition: _streambuf.c:199
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define istrstream
Definition: _strstream.h:38
ptrdiff_t streamsize
Definition: char_traits.h:81
#define ostrstream
Definition: _strstream.h:37
bool _M_dynamic
Definition: _strstream.h:94
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
char_traits< char > ::off_type off_type
Definition: _streambuf.h:56
virtual int_type underflow()
Definition: _streambuf.c:170