1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/tools/stlport/stl/_strstream.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,165 @@
1.4 +/*
1.5 + * Copyright (c) 1999
1.6 + * Silicon Graphics Computer Systems, Inc.
1.7 + *
1.8 + * Copyright (c) 1999
1.9 + * Boris Fomitchev
1.10 + *
1.11 + * This material is provided "as is", with absolutely no warranty expressed
1.12 + * or implied. Any use is at your own risk.
1.13 + *
1.14 + * Permission to use or copy this software for any purpose is hereby granted
1.15 + * without fee, provided the above notices are retained on all copies.
1.16 + * Permission to modify the code and to distribute modified code is granted,
1.17 + * provided the above notices are retained, and a notice that the code was
1.18 + * modified is included with the above copyright notice.
1.19 + *
1.20 + */
1.21 +#ifndef _STLP_INTERNAL_STRSTREAM
1.22 +#define _STLP_INTERNAL_STRSTREAM
1.23 +
1.24 +#ifndef _STLP_INTERNAL_STREAMBUF
1.25 +# include <stl/_streambuf.h>
1.26 +#endif
1.27 +
1.28 +#ifndef _STLP_INTERNAL_ISTREAM
1.29 +# include <stl/_istream.h> // Includes <ostream>, <ios>, <iosfwd>
1.30 +#endif
1.31 +
1.32 +#ifndef _STLP_INTERNAL_STRING_H
1.33 +# include <stl/_string.h>
1.34 +#endif
1.35 +
1.36 +_STLP_BEGIN_NAMESPACE
1.37 +
1.38 +#ifndef _STLP_USE_NAMESPACES
1.39 +# define strstream _STLP_strstream
1.40 +# define ostrstream _STLP_ostrstream
1.41 +# define istrstream _STLP_istrstream
1.42 +# define strstreambuf _STLP_strstreambuf
1.43 +#endif
1.44 +
1.45 +//----------------------------------------------------------------------
1.46 +// Class strstreambuf, a streambuf class that manages an array of char.
1.47 +// Note that this class is not a template.
1.48 +
1.49 +class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf<char, char_traits<char> > {
1.50 +public: // Types.
1.51 + typedef char_traits<char> _Traits;
1.52 + typedef basic_streambuf<char, char_traits<char> > _Base;
1.53 + typedef void* (*__alloc_fn)(size_t);
1.54 + typedef void (*__free_fn)(void*);
1.55 +public: // Constructor, destructor
1.56 +
1.57 + explicit strstreambuf(streamsize _Initial_capacity = 0);
1.58 +
1.59 + strstreambuf(__alloc_fn, __free_fn);
1.60 +
1.61 + strstreambuf(char* __get, streamsize __n, char* __put = 0);
1.62 + strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0);
1.63 + strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
1.64 +
1.65 + strstreambuf(const char* __get, streamsize __n);
1.66 + strstreambuf(const signed char* __get, streamsize __n);
1.67 + strstreambuf(const unsigned char* __get, streamsize __n);
1.68 +
1.69 + virtual ~strstreambuf();
1.70 +
1.71 +public: // strstreambuf operations.
1.72 + void freeze(bool = true);
1.73 + char* str();
1.74 + int pcount() const;
1.75 +
1.76 +protected: // Overridden virtual member functions.
1.77 + virtual int_type overflow(int_type __c = _Traits::eof());
1.78 + virtual int_type pbackfail(int_type __c = _Traits::eof());
1.79 + virtual int_type underflow();
1.80 + virtual _Base* setbuf(char* __buf, streamsize __n);
1.81 + virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
1.82 + ios_base::openmode __mode
1.83 + = ios_base::in | ios_base::out);
1.84 + virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
1.85 + = ios_base::in | ios_base::out);
1.86 +
1.87 +private: // Helper functions.
1.88 + // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun.
1.89 + char* _M_alloc(size_t);
1.90 + void _M_free(char*);
1.91 +
1.92 + // Helper function used in constructors.
1.93 + void _M_setup(char* __get, char* __put, streamsize __n);
1.94 +private: // Data members.
1.95 + __alloc_fn _M_alloc_fun;
1.96 + __free_fn _M_free_fun;
1.97 + bool _M_dynamic : 1;
1.98 + bool _M_frozen : 1;
1.99 + bool _M_constant : 1;
1.100 +};
1.101 +
1.102 +//----------------------------------------------------------------------
1.103 +// Class istrstream, an istream that manages a strstreambuf.
1.104 +
1.105 +class _STLP_CLASS_DECLSPEC istrstream : public basic_istream<char, char_traits<char> > {
1.106 +public:
1.107 + explicit istrstream(char*);
1.108 + explicit istrstream(const char*);
1.109 + istrstream(char* , streamsize);
1.110 + istrstream(const char*, streamsize);
1.111 + virtual ~istrstream();
1.112 +
1.113 + strstreambuf* rdbuf() const;
1.114 + char* str();
1.115 +
1.116 +private:
1.117 + strstreambuf _M_buf;
1.118 +};
1.119 +
1.120 +//----------------------------------------------------------------------
1.121 +// Class ostrstream
1.122 +
1.123 +class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream<char, char_traits<char> >
1.124 +{
1.125 +public:
1.126 + ostrstream();
1.127 + ostrstream(char*, int, ios_base::openmode = ios_base::out);
1.128 + virtual ~ostrstream();
1.129 +
1.130 + strstreambuf* rdbuf() const;
1.131 + void freeze(bool = true);
1.132 + char* str();
1.133 + int pcount() const;
1.134 +
1.135 +private:
1.136 + strstreambuf _M_buf;
1.137 +};
1.138 +
1.139 +//----------------------------------------------------------------------
1.140 +// Class strstream
1.141 +
1.142 +class _STLP_CLASS_DECLSPEC strstream : public basic_iostream<char, char_traits<char> > {
1.143 +public:
1.144 + typedef char char_type;
1.145 + typedef char_traits<char>::int_type int_type;
1.146 + typedef char_traits<char>::pos_type pos_type;
1.147 + typedef char_traits<char>::off_type off_type;
1.148 +
1.149 + strstream();
1.150 + strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out);
1.151 + virtual ~strstream();
1.152 +
1.153 + strstreambuf* rdbuf() const;
1.154 + void freeze(bool = true);
1.155 + int pcount() const;
1.156 + char* str();
1.157 +
1.158 +private:
1.159 + strstreambuf _M_buf;
1.160 +
1.161 + //explicitely defined as private to avoid warnings:
1.162 + strstream(strstream const&);
1.163 + strstream& operator = (strstream const&);
1.164 +};
1.165 +
1.166 +_STLP_END_NAMESPACE
1.167 +
1.168 +#endif /* _STLP_INTERNAL_STRSTREAM */