williamr@2: /* williamr@4: * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. williamr@4: * williamr@4: * Copyright (c) 1999 williamr@4: * Silicon Graphics Computer Systems, Inc. williamr@4: * williamr@4: * Copyright (c) 1999 williamr@4: * Boris Fomitchev williamr@4: * williamr@4: * This material is provided "as is", with absolutely no warranty expressed williamr@4: * or implied. Any use is at your own risk. williamr@4: * williamr@4: * Permission to use or copy this software for any purpose is hereby granted williamr@4: * without fee, provided the above notices are retained on all copies. williamr@4: * Permission to modify the code and to distribute modified code is granted, williamr@4: * provided the above notices are retained, and a notice that the code was williamr@4: * modified is included with the above copyright notice. williamr@4: * williamr@4: */ williamr@4: #ifndef _STLP_INTERNAL_STRSTREAM williamr@4: #define _STLP_INTERNAL_STRSTREAM williamr@2: williamr@2: #ifndef _STLP_INTERNAL_STREAMBUF williamr@4: # include williamr@2: #endif williamr@4: williamr@4: #ifndef _STLP_INTERNAL_ISTREAM williamr@4: # include // Includes , , williamr@2: #endif williamr@4: williamr@4: #ifndef _STLP_INTERNAL_STRING_H williamr@4: # include williamr@2: #endif williamr@2: williamr@2: _STLP_BEGIN_NAMESPACE williamr@2: williamr@2: #ifndef _STLP_USE_NAMESPACES williamr@4: # define strstream _STLP_strstream williamr@4: # define ostrstream _STLP_ostrstream williamr@4: # define istrstream _STLP_istrstream williamr@4: # define strstreambuf _STLP_strstreambuf williamr@2: #endif williamr@2: williamr@2: //---------------------------------------------------------------------- williamr@2: // Class strstreambuf, a streambuf class that manages an array of char. williamr@2: // Note that this class is not a template. williamr@4: williamr@4: class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf > { williamr@2: public: // Types. williamr@2: typedef char_traits _Traits; williamr@2: typedef basic_streambuf > _Base; williamr@2: typedef void* (*__alloc_fn)(size_t); williamr@2: typedef void (*__free_fn)(void*); williamr@2: public: // Constructor, destructor williamr@2: williamr@4: _STLP_DECLSPEC explicit strstreambuf(streamsize _Initial_capacity = 0); williamr@2: williamr@2: _STLP_DECLSPEC strstreambuf(__alloc_fn, __free_fn); williamr@2: williamr@2: _STLP_DECLSPEC strstreambuf(char* __get, streamsize __n, char* __put = 0); williamr@2: _STLP_DECLSPEC strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0); williamr@2: _STLP_DECLSPEC strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0); williamr@2: williamr@2: _STLP_DECLSPEC strstreambuf(const char* __get, streamsize __n); williamr@2: _STLP_DECLSPEC strstreambuf(const signed char* __get, streamsize __n); williamr@2: _STLP_DECLSPEC strstreambuf(const unsigned char* __get, streamsize __n); williamr@2: williamr@4: _STLP_DECLSPEC virtual ~strstreambuf(); williamr@2: williamr@2: public: // strstreambuf operations. williamr@2: _STLP_DECLSPEC void freeze(bool = true); williamr@2: _STLP_DECLSPEC char* str(); williamr@2: _STLP_DECLSPEC int pcount() const; williamr@2: williamr@2: protected: // Overridden virtual member functions. williamr@4: _STLP_DECLSPEC virtual int_type overflow(int_type __c = _Traits::eof()); williamr@4: _STLP_DECLSPEC virtual int_type pbackfail(int_type __c = _Traits::eof()); williamr@4: _STLP_DECLSPEC virtual int_type underflow(); williamr@4: _STLP_DECLSPEC virtual _Base* setbuf(char* __buf, streamsize __n); williamr@4: _STLP_DECLSPEC virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir, williamr@4: ios_base::openmode __mode williamr@2: = ios_base::in | ios_base::out); williamr@4: _STLP_DECLSPEC virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode williamr@2: = ios_base::in | ios_base::out); williamr@2: williamr@2: private: // Helper functions. williamr@2: // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun. williamr@2: char* _M_alloc(size_t); williamr@4: void _M_free(char*); williamr@2: williamr@2: // Helper function used in constructors. williamr@2: void _M_setup(char* __get, char* __put, streamsize __n); williamr@2: private: // Data members. williamr@2: __alloc_fn _M_alloc_fun; williamr@2: __free_fn _M_free_fun; williamr@2: bool _M_dynamic : 1; williamr@2: bool _M_frozen : 1; williamr@2: bool _M_constant : 1; williamr@2: }; williamr@2: williamr@2: //---------------------------------------------------------------------- williamr@2: // Class istrstream, an istream that manages a strstreambuf. williamr@2: williamr@4: class _STLP_CLASS_DECLSPEC istrstream : public basic_istream > { williamr@2: public: williamr@2: _STLP_DECLSPEC explicit istrstream(char*); williamr@2: _STLP_DECLSPEC explicit istrstream(const char*); williamr@2: _STLP_DECLSPEC istrstream(char* , streamsize); williamr@2: _STLP_DECLSPEC istrstream(const char*, streamsize); williamr@4: _STLP_DECLSPEC virtual ~istrstream(); williamr@4: williamr@2: _STLP_DECLSPEC strstreambuf* rdbuf() const; williamr@2: _STLP_DECLSPEC char* str(); williamr@2: williamr@2: private: williamr@2: strstreambuf _M_buf; williamr@2: }; williamr@2: williamr@2: //---------------------------------------------------------------------- williamr@2: // Class ostrstream williamr@4: williamr@2: class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream > williamr@2: { williamr@2: public: williamr@2: _STLP_DECLSPEC ostrstream(); williamr@2: _STLP_DECLSPEC ostrstream(char*, int, ios_base::openmode = ios_base::out); williamr@4: _STLP_DECLSPEC virtual ~ostrstream(); williamr@2: williamr@2: _STLP_DECLSPEC strstreambuf* rdbuf() const; williamr@2: _STLP_DECLSPEC void freeze(bool = true); williamr@2: _STLP_DECLSPEC char* str(); williamr@2: _STLP_DECLSPEC int pcount() const; williamr@2: williamr@2: private: williamr@2: strstreambuf _M_buf; williamr@2: }; williamr@2: williamr@2: //---------------------------------------------------------------------- williamr@2: // Class strstream williamr@4: williamr@4: class _STLP_CLASS_DECLSPEC strstream : public basic_iostream > { williamr@2: public: williamr@2: typedef char char_type; williamr@2: typedef char_traits::int_type int_type; williamr@2: typedef char_traits::pos_type pos_type; williamr@2: typedef char_traits::off_type off_type; williamr@2: williamr@2: _STLP_DECLSPEC strstream(); williamr@2: _STLP_DECLSPEC strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out); williamr@4: _STLP_DECLSPEC virtual ~strstream(); williamr@2: williamr@2: _STLP_DECLSPEC strstreambuf* rdbuf() const; williamr@2: _STLP_DECLSPEC void freeze(bool = true); williamr@2: _STLP_DECLSPEC int pcount() const; williamr@2: _STLP_DECLSPEC char* str(); williamr@2: williamr@2: private: williamr@2: strstreambuf _M_buf; williamr@4: williamr@4: //explicitely defined as private to avoid warnings: williamr@4: strstream(strstream const&); williamr@4: strstream& operator = (strstream const&); williamr@2: }; williamr@2: williamr@2: _STLP_END_NAMESPACE williamr@4: williamr@4: #endif /* _STLP_INTERNAL_STRSTREAM */