epoc32/include/stdapis/stlportv5/stl/_strstream.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /*
     2  * Portions Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     3  *
     4  * Copyright (c) 1999
     5  * Silicon Graphics Computer Systems, Inc.
     6  *
     7  * Copyright (c) 1999
     8  * Boris Fomitchev
     9  *
    10  * This material is provided "as is", with absolutely no warranty expressed
    11  * or implied. Any use is at your own risk.
    12  *
    13  * Permission to use or copy this software for any purpose is hereby granted
    14  * without fee, provided the above notices are retained on all copies.
    15  * Permission to modify the code and to distribute modified code is granted,
    16  * provided the above notices are retained, and a notice that the code was
    17  * modified is included with the above copyright notice.
    18  *
    19  */
    20 #ifndef _STLP_INTERNAL_STRSTREAM
    21 #define _STLP_INTERNAL_STRSTREAM
    22 
    23 #ifndef _STLP_INTERNAL_STREAMBUF
    24 #  include <stl/_streambuf.h>
    25 #endif
    26 
    27 #ifndef _STLP_INTERNAL_ISTREAM
    28 #  include <stl/_istream.h>              // Includes <ostream>, <ios>, <iosfwd>
    29 #endif
    30 
    31 #ifndef _STLP_INTERNAL_STRING_H
    32 #  include <stl/_string.h>
    33 #endif
    34 
    35 _STLP_BEGIN_NAMESPACE
    36 
    37 #ifndef _STLP_USE_NAMESPACES
    38 #  define strstream _STLP_strstream
    39 #  define ostrstream _STLP_ostrstream
    40 #  define istrstream _STLP_istrstream
    41 #  define strstreambuf _STLP_strstreambuf
    42 #endif
    43 
    44 //----------------------------------------------------------------------
    45 // Class strstreambuf, a streambuf class that manages an array of char.
    46 // Note that this class is not a template.
    47 
    48 class _STLP_CLASS_DECLSPEC strstreambuf : public basic_streambuf<char, char_traits<char> > {
    49 public:                         // Types.
    50   typedef char_traits<char>              _Traits;
    51   typedef basic_streambuf<char, char_traits<char> > _Base;
    52   typedef void* (*__alloc_fn)(size_t);
    53   typedef void (*__free_fn)(void*);
    54 public:                         // Constructor, destructor
    55 
    56   _STLP_DECLSPEC explicit strstreambuf(streamsize _Initial_capacity = 0);
    57 
    58   _STLP_DECLSPEC strstreambuf(__alloc_fn, __free_fn);
    59 
    60   _STLP_DECLSPEC strstreambuf(char* __get, streamsize __n, char* __put = 0);
    61   _STLP_DECLSPEC strstreambuf(signed char* __get, streamsize __n, signed char* __put = 0);
    62   _STLP_DECLSPEC strstreambuf(unsigned char* __get, streamsize __n, unsigned char* __put=0);
    63 
    64   _STLP_DECLSPEC strstreambuf(const char* __get, streamsize __n);
    65   _STLP_DECLSPEC strstreambuf(const signed char* __get, streamsize __n);
    66   _STLP_DECLSPEC strstreambuf(const unsigned char* __get, streamsize __n);
    67 
    68   _STLP_DECLSPEC virtual ~strstreambuf();
    69 
    70 public:                         // strstreambuf operations.
    71   _STLP_DECLSPEC void freeze(bool = true);
    72   _STLP_DECLSPEC char* str();
    73   _STLP_DECLSPEC int pcount() const;
    74 
    75 protected:                      // Overridden virtual member functions.
    76   _STLP_DECLSPEC virtual int_type overflow(int_type __c  = _Traits::eof());
    77   _STLP_DECLSPEC virtual int_type pbackfail(int_type __c = _Traits::eof());
    78   _STLP_DECLSPEC virtual int_type underflow();
    79   _STLP_DECLSPEC virtual _Base* setbuf(char* __buf, streamsize __n);
    80   _STLP_DECLSPEC virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
    81                            ios_base::openmode __mode
    82                                       = ios_base::in | ios_base::out);
    83   _STLP_DECLSPEC virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
    84                                       = ios_base::in | ios_base::out);
    85 
    86 private:                        // Helper functions.
    87   // Dynamic allocation, possibly using _M_alloc_fun and _M_free_fun.
    88   char* _M_alloc(size_t);
    89   void  _M_free(char*);
    90 
    91   // Helper function used in constructors.
    92   void _M_setup(char* __get, char* __put, streamsize __n);
    93 private:                        // Data members.
    94   __alloc_fn _M_alloc_fun;
    95   __free_fn  _M_free_fun;
    96   bool _M_dynamic  : 1;
    97   bool _M_frozen   : 1;
    98   bool _M_constant : 1;
    99 };
   100 
   101 //----------------------------------------------------------------------
   102 // Class istrstream, an istream that manages a strstreambuf.
   103 
   104 class _STLP_CLASS_DECLSPEC istrstream : public basic_istream<char, char_traits<char> > {
   105 public:
   106   _STLP_DECLSPEC explicit istrstream(char*);
   107   _STLP_DECLSPEC explicit istrstream(const char*);
   108   _STLP_DECLSPEC istrstream(char* , streamsize);
   109   _STLP_DECLSPEC istrstream(const char*, streamsize);
   110   _STLP_DECLSPEC virtual ~istrstream();
   111 
   112   _STLP_DECLSPEC strstreambuf* rdbuf() const;
   113   _STLP_DECLSPEC char* str();
   114 
   115 private:
   116   strstreambuf _M_buf;
   117 };
   118 
   119 //----------------------------------------------------------------------
   120 // Class ostrstream
   121 
   122 class _STLP_CLASS_DECLSPEC ostrstream : public basic_ostream<char, char_traits<char> >
   123 {
   124 public:
   125   _STLP_DECLSPEC ostrstream();
   126   _STLP_DECLSPEC ostrstream(char*, int, ios_base::openmode = ios_base::out);
   127   _STLP_DECLSPEC virtual ~ostrstream();
   128 
   129   _STLP_DECLSPEC strstreambuf* rdbuf() const;
   130   _STLP_DECLSPEC void freeze(bool = true);
   131   _STLP_DECLSPEC char* str();
   132   _STLP_DECLSPEC int pcount() const;
   133 
   134 private:
   135   strstreambuf _M_buf;
   136 };
   137 
   138 //----------------------------------------------------------------------
   139 // Class strstream
   140 
   141 class _STLP_CLASS_DECLSPEC strstream : public basic_iostream<char, char_traits<char> > {
   142 public:
   143   typedef char                        char_type;
   144   typedef char_traits<char>::int_type int_type;
   145   typedef char_traits<char>::pos_type pos_type;
   146   typedef char_traits<char>::off_type off_type;
   147 
   148   _STLP_DECLSPEC strstream();
   149   _STLP_DECLSPEC strstream(char*, int, ios_base::openmode = ios_base::in | ios_base::out);
   150   _STLP_DECLSPEC virtual ~strstream();
   151 
   152   _STLP_DECLSPEC strstreambuf* rdbuf() const;
   153   _STLP_DECLSPEC void freeze(bool = true);
   154   _STLP_DECLSPEC int pcount() const;
   155   _STLP_DECLSPEC char* str();
   156 
   157 private:
   158   strstreambuf _M_buf;
   159 
   160   //explicitely defined as private to avoid warnings:
   161   strstream(strstream const&);
   162   strstream& operator = (strstream const&);
   163 };
   164 
   165 _STLP_END_NAMESPACE
   166 
   167 #endif /* _STLP_INTERNAL_STRSTREAM */