diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/stdapis/stlport/stl/_strstream.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/epoc32/include/stdapis/stlport/stl/_strstream.h Wed Mar 31 12:33:34 2010 +0100 @@ -0,0 +1,205 @@ +/* + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. + * + * Copyright (c) 1999 + * Silicon Graphics Computer Systems, Inc. + * + * Copyright (c) 1999 + * Boris Fomitchev + * + * This material is provided "as is", with absolutely no warranty expressed + * or implied. Any use is at your own risk. + * + * Permission to use or copy this software for any purpose is hereby granted + * without fee, provided the above notices are retained on all copies. + * Permission to modify the code and to distribute modified code is granted, + * provided the above notices are retained, and a notice that the code was + * modified is included with the above copyright notice. + * + */ + + + +#ifndef _STLP_INTERNAL_STREAMBUF +#include +#endif +#ifndef _STLP_ISTREAM +#include // Includes , , +#endif +#ifndef _STLP_STRING_H +#include +#endif + +_STLP_BEGIN_NAMESPACE + +#ifndef _STLP_USE_NAMESPACES +# define strstream _STLP_strstream +# define ostrstream _STLP_ostrstream +# define istrstream _STLP_istrstream +# define strstreambuf _STLP_strstreambuf +#endif + +//---------------------------------------------------------------------- +// Class strstreambuf, a streambuf class that manages an array of char. +// Note that this class is not a template. +#ifdef __SYMBIAN32__ +class strstreambuf : public basic_streambuf > +#else +class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf > +#endif +{ +public: // Types. + typedef char_traits _Traits; + typedef basic_streambuf > _Base; + typedef void* (*__alloc_fn)(size_t); + typedef void (*__free_fn)(void*); +public: // Constructor, destructor + + explicit strstreambuf(streamsize _Initial_capacity = 0); + + _STLP_DECLSPEC strstreambuf(__alloc_fn, __free_fn); + + _STLP_DECLSPEC strstreambuf(char* __get, streamsize __n, char* __put = 0); + _STLP_DECLSPEC strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0); + _STLP_DECLSPEC strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0); + + _STLP_DECLSPEC strstreambuf(const char* __get, streamsize __n); + _STLP_DECLSPEC strstreambuf(const signed char* __get, streamsize __n); + _STLP_DECLSPEC strstreambuf(const unsigned char* __get, streamsize __n); + + virtual ~strstreambuf(); + +public: // strstreambuf operations. + _STLP_DECLSPEC void freeze(bool = true); + _STLP_DECLSPEC char* str(); + _STLP_DECLSPEC int pcount() const; + +protected: // Overridden virtual member functions. + virtual int_type overflow(int_type __c = _Traits::eof()); + virtual int_type pbackfail(int_type __c = _Traits::eof()); + virtual int_type underflow(); + virtual _Base* setbuf(char* __buf, streamsize __n); + virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, + ios_base::openmode __mode + = ios_base::in | ios_base::out); + virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode + = ios_base::in | ios_base::out); + +private: // Helper functions. + // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. + char* _M_alloc(size_t); + inline void _M_free(char*); + + // Helper function used in constructors. + void _M_setup(char* __get, char* __put, streamsize __n); +private: // Data members. + __alloc_fn _M_alloc_fun; + __free_fn _M_free_fun; + bool _M_dynamic : 1; + bool _M_frozen : 1; + bool _M_constant : 1; +#ifdef __SYMBIAN32__ + char* _pfrozenendsave; + char* _pgetfrozenendsave; +#endif +}; + +inline strstreambuf::~strstreambuf() +{ +#ifdef __SYMBIAN32__ + if (_M_dynamic && !_M_frozen) + { + if (_M_free_fun) + _M_free_fun(eback()); + else + _M_free(eback()); + } +#else + if (_M_dynamic && !_M_frozen) + _M_free(eback()); +#endif +} + +inline void strstreambuf::_M_free(char* p) +{ + if (p) + if (_M_free_fun) + _M_free_fun(p); + else + delete[] p; +} + + +//---------------------------------------------------------------------- +// Class istrstream, an istream that manages a strstreambuf. + +#ifdef __SYMBIAN32__ +NONSHARABLE_CLASS (istrstream) : public basic_istream > +#else +class _STLP_CLASS_DECLSPEC istrstream : public basic_istream > +#endif +{ +public: + _STLP_DECLSPEC explicit istrstream(char*); + _STLP_DECLSPEC explicit istrstream(const char*); + _STLP_DECLSPEC istrstream(char* , streamsize); + _STLP_DECLSPEC istrstream(const char*, streamsize); + virtual ~istrstream(); + + _STLP_DECLSPEC strstreambuf* rdbuf() const; + _STLP_DECLSPEC char* str(); + +private: + strstreambuf _M_buf; +}; + +//---------------------------------------------------------------------- +// Class ostrstream +#ifdef __SYMBIAN32__ +NONSHARABLE_CLASS (ostrstream) : public basic_ostream > +#else +class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream > +#endif +{ +public: + _STLP_DECLSPEC ostrstream(); + _STLP_DECLSPEC ostrstream(char*, int, ios_base::openmode = ios_base::out); + virtual ~ostrstream(); + + _STLP_DECLSPEC strstreambuf* rdbuf() const; + _STLP_DECLSPEC void freeze(bool = true); + _STLP_DECLSPEC char* str(); + _STLP_DECLSPEC int pcount() const; + +private: + strstreambuf _M_buf; +}; + +//---------------------------------------------------------------------- +// Class strstream +#ifdef __SYMBIAN32__ +NONSHARABLE_CLASS (strstream) : public basic_iostream > +#else +class _STLP_CLASS_DECLSPEC strstream : public basic_iostream > +#endif +{ +public: + typedef char char_type; + typedef char_traits::int_type int_type; + typedef char_traits::pos_type pos_type; + typedef char_traits::off_type off_type; + + _STLP_DECLSPEC strstream(); + _STLP_DECLSPEC strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); + virtual ~strstream(); + + _STLP_DECLSPEC strstreambuf* rdbuf() const; + _STLP_DECLSPEC void freeze(bool = true); + _STLP_DECLSPEC int pcount() const; + _STLP_DECLSPEC char* str(); + +private: + strstreambuf _M_buf; +}; + +_STLP_END_NAMESPACE