1.1 --- a/epoc32/include/stdapis/stlport/stl/_strstream.h Tue Mar 16 16:12:26 2010 +0000
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,213 +0,0 @@
1.4 -/*
1.5 -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.6 -
1.7 -* Redistribution and use in source and binary forms, with or without
1.8 -* modification, are permitted provided that the following conditions are met:
1.9 -
1.10 -* Redistributions of source code must retain the above copyright notice, this
1.11 -* list of conditions and the following disclaimer.
1.12 -* Redistributions in binary form must reproduce the above copyright notice,
1.13 -* this list of conditions and the following disclaimer in the documentation
1.14 -* and/or other materials provided with the distribution.
1.15 -* Neither the name of Nokia Corporation nor the names of its contributors
1.16 -* may be used to endorse or promote products derived from this software
1.17 -* without specific prior written permission.
1.18 -
1.19 -* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1.20 -* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.21 -* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1.22 -* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1.23 -* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.24 -* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1.25 -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1.26 -* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1.27 -* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1.28 -* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.29 -*
1.30 -* Description:
1.31 -*
1.32 -*/
1.33 -
1.34 -#ifndef _STLP_INTERNAL_STREAMBUF
1.35 -#include <stl/_streambuf.h>
1.36 -#endif
1.37 -#ifndef _STLP_ISTREAM
1.38 -#include <istream> // Includes <ostream>, <ios>, <iosfwd>
1.39 -#endif
1.40 -#ifndef _STLP_STRING_H
1.41 -#include <stl/_string.h>
1.42 -#endif
1.43 -
1.44 -_STLP_BEGIN_NAMESPACE
1.45 -
1.46 -#ifndef _STLP_USE_NAMESPACES
1.47 -# define strstream _STLP_strstream
1.48 -# define ostrstream _STLP_ostrstream
1.49 -# define istrstream _STLP_istrstream
1.50 -# define strstreambuf _STLP_strstreambuf
1.51 -#endif
1.52 -
1.53 -//----------------------------------------------------------------------
1.54 -// Class strstreambuf, a streambuf class that manages an array of char.
1.55 -// Note that this class is not a template.
1.56 -#ifdef __SYMBIAN32__
1.57 -class strstreambuf : public basic_streambuf<char, char_traits<char> >
1.58 -#else
1.59 -class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf<char, char_traits<char> >
1.60 -#endif
1.61 -{
1.62 -public: // Types.
1.63 - typedef char_traits<char> _Traits;
1.64 - typedef basic_streambuf<char, char_traits<char> > _Base;
1.65 - typedef void* (*__alloc_fn)(size_t);
1.66 - typedef void (*__free_fn)(void*);
1.67 -public: // Constructor, destructor
1.68 -
1.69 - explicit strstreambuf(streamsize _Initial_capacity = 0);
1.70 -
1.71 - _STLP_DECLSPEC strstreambuf(__alloc_fn, __free_fn);
1.72 -
1.73 - _STLP_DECLSPEC strstreambuf(char* __get, streamsize __n, char* __put = 0);
1.74 - _STLP_DECLSPEC strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0);
1.75 - _STLP_DECLSPEC strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
1.76 -
1.77 - _STLP_DECLSPEC strstreambuf(const char* __get, streamsize __n);
1.78 - _STLP_DECLSPEC strstreambuf(const signed char* __get, streamsize __n);
1.79 - _STLP_DECLSPEC strstreambuf(const unsigned char* __get, streamsize __n);
1.80 -
1.81 - virtual ~strstreambuf();
1.82 -
1.83 -public: // strstreambuf operations.
1.84 - _STLP_DECLSPEC void freeze(bool = true);
1.85 - _STLP_DECLSPEC char* str();
1.86 - _STLP_DECLSPEC int pcount() const;
1.87 -
1.88 -protected: // Overridden virtual member functions.
1.89 - virtual int_type overflow(int_type __c = _Traits::eof());
1.90 - virtual int_type pbackfail(int_type __c = _Traits::eof());
1.91 - virtual int_type underflow();
1.92 - virtual _Base* setbuf(char* __buf, streamsize __n);
1.93 - virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
1.94 - ios_base::openmode __mode
1.95 - = ios_base::in | ios_base::out);
1.96 - virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
1.97 - = ios_base::in | ios_base::out);
1.98 -
1.99 -private: // Helper functions.
1.100 - // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun.
1.101 - char* _M_alloc(size_t);
1.102 - inline void _M_free(char*);
1.103 -
1.104 - // Helper function used in constructors.
1.105 - void _M_setup(char* __get, char* __put, streamsize __n);
1.106 -private: // Data members.
1.107 - __alloc_fn _M_alloc_fun;
1.108 - __free_fn _M_free_fun;
1.109 - bool _M_dynamic : 1;
1.110 - bool _M_frozen : 1;
1.111 - bool _M_constant : 1;
1.112 -#ifdef __SYMBIAN32__
1.113 - char* _pfrozenendsave;
1.114 - char* _pgetfrozenendsave;
1.115 -#endif
1.116 -};
1.117 -
1.118 -inline strstreambuf::~strstreambuf()
1.119 -{
1.120 -#ifdef __SYMBIAN32__
1.121 - if (_M_dynamic && !_M_frozen)
1.122 - {
1.123 - if (_M_free_fun)
1.124 - _M_free_fun(eback());
1.125 - else
1.126 - _M_free(eback());
1.127 - }
1.128 -#else
1.129 - if (_M_dynamic && !_M_frozen)
1.130 - _M_free(eback());
1.131 -#endif
1.132 -}
1.133 -
1.134 -inline void strstreambuf::_M_free(char* p)
1.135 -{
1.136 - if (p)
1.137 - if (_M_free_fun)
1.138 - _M_free_fun(p);
1.139 - else
1.140 - delete[] p;
1.141 -}
1.142 -
1.143 -
1.144 -//----------------------------------------------------------------------
1.145 -// Class istrstream, an istream that manages a strstreambuf.
1.146 -
1.147 -#ifdef __SYMBIAN32__
1.148 -NONSHARABLE_CLASS (istrstream) : public basic_istream<char, char_traits<char> >
1.149 -#else
1.150 -class _STLP_CLASS_DECLSPEC istrstream : public basic_istream<char, char_traits<char> >
1.151 -#endif
1.152 -{
1.153 -public:
1.154 - _STLP_DECLSPEC explicit istrstream(char*);
1.155 - _STLP_DECLSPEC explicit istrstream(const char*);
1.156 - _STLP_DECLSPEC istrstream(char* , streamsize);
1.157 - _STLP_DECLSPEC istrstream(const char*, streamsize);
1.158 - virtual ~istrstream();
1.159 -
1.160 - _STLP_DECLSPEC strstreambuf* rdbuf() const;
1.161 - _STLP_DECLSPEC char* str();
1.162 -
1.163 -private:
1.164 - strstreambuf _M_buf;
1.165 -};
1.166 -
1.167 -//----------------------------------------------------------------------
1.168 -// Class ostrstream
1.169 -#ifdef __SYMBIAN32__
1.170 -NONSHARABLE_CLASS (ostrstream) : public basic_ostream<char, char_traits<char> >
1.171 -#else
1.172 -class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream<char, char_traits<char> >
1.173 -#endif
1.174 -{
1.175 -public:
1.176 - _STLP_DECLSPEC ostrstream();
1.177 - _STLP_DECLSPEC ostrstream(char*, int, ios_base::openmode = ios_base::out);
1.178 - virtual ~ostrstream();
1.179 -
1.180 - _STLP_DECLSPEC strstreambuf* rdbuf() const;
1.181 - _STLP_DECLSPEC void freeze(bool = true);
1.182 - _STLP_DECLSPEC char* str();
1.183 - _STLP_DECLSPEC int pcount() const;
1.184 -
1.185 -private:
1.186 - strstreambuf _M_buf;
1.187 -};
1.188 -
1.189 -//----------------------------------------------------------------------
1.190 -// Class strstream
1.191 -#ifdef __SYMBIAN32__
1.192 -NONSHARABLE_CLASS (strstream) : public basic_iostream<char, char_traits<char> >
1.193 -#else
1.194 -class _STLP_CLASS_DECLSPEC strstream : public basic_iostream<char, char_traits<char> >
1.195 -#endif
1.196 -{
1.197 -public:
1.198 - typedef char char_type;
1.199 - typedef char_traits<char>::int_type int_type;
1.200 - typedef char_traits<char>::pos_type pos_type;
1.201 - typedef char_traits<char>::off_type off_type;
1.202 -
1.203 - _STLP_DECLSPEC strstream();
1.204 - _STLP_DECLSPEC strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out);
1.205 - virtual ~strstream();
1.206 -
1.207 - _STLP_DECLSPEC strstreambuf* rdbuf() const;
1.208 - _STLP_DECLSPEC void freeze(bool = true);
1.209 - _STLP_DECLSPEC int pcount() const;
1.210 - _STLP_DECLSPEC char* str();
1.211 -
1.212 -private:
1.213 - strstreambuf _M_buf;
1.214 -};
1.215 -
1.216 -_STLP_END_NAMESPACE