1.1 --- a/epoc32/include/stdapis/stlport/stl/_sstream.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_sstream.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,273 @@
1.4 -_sstream.h
1.5 +/*
1.6 + * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved.
1.7 + * Copyright (c) 1999
1.8 + * Silicon Graphics Computer Systems, Inc.
1.9 + *
1.10 + * Copyright (c) 1999
1.11 + * Boris Fomitchev
1.12 + *
1.13 + * This material is provided "as is", with absolutely no warranty expressed
1.14 + * or implied. Any use is at your own risk.
1.15 + *
1.16 + * Permission to use or copy this software for any purpose is hereby granted
1.17 + * without fee, provided the above notices are retained on all copies.
1.18 + * Permission to modify the code and to distribute modified code is granted,
1.19 + * provided the above notices are retained, and a notice that the code was
1.20 + * modified is included with the above copyright notice.
1.21 + *
1.22 + */
1.23 +
1.24 +
1.25 +// This header defines classes basic_stringbuf, basic_istringstream,
1.26 +// basic_ostringstream, and basic_stringstream. These classes
1.27 +// represent streamsbufs and streams whose sources or destinations are
1.28 +// C++ strings.
1.29 +
1.30 +#ifndef _STLP_SSTREAM_H
1.31 +#define _STLP_SSTREAM_H
1.32 +
1.33 +#ifndef _STLP_INTERNAL_STREAMBUF
1.34 +# include <stl/_streambuf.h>
1.35 +#endif
1.36 +
1.37 +#ifndef _STLP_INTERNAL_ISTREAM_H
1.38 +# include <stl/_istream.h> // Includes <ostream>, <ios>, <iosfwd>
1.39 +#endif
1.40 +
1.41 +#ifndef _STLP_STRING_H
1.42 +# include <stl/_string.h>
1.43 +#endif
1.44 +
1.45 +_STLP_BEGIN_NAMESPACE
1.46 +
1.47 +//----------------------------------------------------------------------
1.48 +// This version of basic_stringbuf relies on the internal details of
1.49 +// basic_string. It relies on the fact that, in this implementation,
1.50 +// basic_string's iterators are pointers. It also assumes (as allowed
1.51 +// by the standard) that _CharT is a POD type.
1.52 +
1.53 +// We have a very small buffer for the put area, just so that we don't
1.54 +// have to use append() for every sputc. Conceptually, the buffer
1.55 +// immediately follows the end of the underlying string. We use this
1.56 +// buffer when appending to write-only streambufs, but we don't use it
1.57 +// for read-write streambufs.
1.58 +
1.59 +template <class _CharT, class _Traits, class _Alloc>
1.60 +#ifdef __SYMBIAN32__
1.61 +NONSHARABLE_CLASS ( basic_stringbuf ) : public basic_streambuf<_CharT, _Traits>
1.62 +#else
1.63 +class basic_stringbuf : public basic_streambuf<_CharT, _Traits>
1.64 +#endif
1.65 +{
1.66 +public: // Typedefs.
1.67 + typedef _CharT char_type;
1.68 + typedef typename _Traits::int_type int_type;
1.69 + typedef typename _Traits::pos_type pos_type;
1.70 + typedef typename _Traits::off_type off_type;
1.71 + typedef _Traits traits_type;
1.72 +
1.73 + typedef basic_streambuf<_CharT, _Traits> _Base;
1.74 + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Self;
1.75 + typedef basic_string<_CharT, _Traits, _Alloc> _String;
1.76 +
1.77 +public: // Constructors, destructor.
1.78 + _STLP_DECLSPEC explicit basic_stringbuf(ios_base::openmode __mode
1.79 + = ios_base::in | ios_base::out);
1.80 + _STLP_DECLSPEC explicit basic_stringbuf(const _String& __s, ios_base::openmode __mode
1.81 + = ios_base::in | ios_base::out);
1.82 + _STLP_DECLSPEC virtual ~basic_stringbuf();
1.83 +
1.84 +public: // Get or set the string.
1.85 + _String str() const {
1.86 + if ( _M_mode & ios_base::out )
1.87 + _M_append_buffer();
1.88 + return _M_str;
1.89 + }
1.90 + _STLP_DECLSPEC void str(const _String& __s);
1.91 +
1.92 +protected: // Overridden virtual member functions.
1.93 + virtual int_type underflow();
1.94 + virtual int_type uflow();
1.95 + virtual int_type pbackfail(int_type __c);
1.96 + virtual int_type overflow(int_type __c);
1.97 + int_type pbackfail() {return pbackfail(_Traits::eof());}
1.98 + int_type overflow() {return overflow(_Traits::eof());}
1.99 +
1.100 + virtual streamsize xsputn(const char_type* __s, streamsize __n);
1.101 + virtual streamsize _M_xsputnc(char_type __c, streamsize __n);
1.102 +
1.103 + virtual _Base* setbuf(_CharT* __buf, streamsize __n);
1.104 + virtual pos_type seekoff(off_type __off, ios_base::seekdir __dir,
1.105 + ios_base::openmode __mode
1.106 + = ios_base::in | ios_base::out);
1.107 + virtual pos_type seekpos(pos_type __pos, ios_base::openmode __mode
1.108 + = ios_base::in | ios_base::out);
1.109 + ios_base::openmode _M_mode;
1.110 +
1.111 +private: // Helper functions.
1.112 + // Append the internal buffer to the string if necessary.
1.113 + void _M_append_buffer() const;
1.114 + void _M_set_ptrs();
1.115 +
1.116 +private:
1.117 + mutable basic_string<_CharT, _Traits, _Alloc> _M_str;
1.118 +
1.119 + enum _JustName { _S_BufSiz = 8 };
1.120 + _CharT _M_Buf[ 8 /* _S_BufSiz */];
1.121 +};
1.122 +
1.123 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.124 +_STLP_EXPORT_TEMPLATE_CLASS basic_stringbuf<char, char_traits<char>, allocator<char> >;
1.125 +# if !defined (_STLP_NO_WCHAR_T)
1.126 +_STLP_EXPORT_TEMPLATE_CLASS basic_stringbuf<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
1.127 +# endif
1.128 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.129 +
1.130 +//----------------------------------------------------------------------
1.131 +// Class basic_istringstream, an input stream that uses a stringbuf.
1.132 +
1.133 +template <class _CharT, class _Traits, class _Alloc>
1.134 +#ifdef __SYMBIAN32__
1.135 +NONSHARABLE_CLASS ( basic_istringstream ) : public basic_istream<_CharT, _Traits>
1.136 +#else
1.137 +class basic_istringstream : public basic_istream<_CharT, _Traits>
1.138 +#endif
1.139 +{
1.140 +public: // Typedefs
1.141 + typedef typename _Traits::char_type char_type;
1.142 + typedef typename _Traits::int_type int_type;
1.143 + typedef typename _Traits::pos_type pos_type;
1.144 + typedef typename _Traits::off_type off_type;
1.145 + typedef _Traits traits_type;
1.146 +
1.147 + typedef basic_ios<_CharT, _Traits> _Basic_ios;
1.148 + typedef basic_istream<_CharT, _Traits> _Base;
1.149 + typedef basic_string<_CharT, _Traits, _Alloc> _String;
1.150 + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Buf;
1.151 +
1.152 +public: // Constructors, destructor.
1.153 + basic_istringstream(ios_base::openmode __mode = ios_base::in);
1.154 + basic_istringstream(const _String& __str,
1.155 + ios_base::openmode __mode = ios_base::in);
1.156 + ~basic_istringstream();
1.157 +
1.158 +public: // Member functions
1.159 +
1.160 + basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const
1.161 + { return __CONST_CAST(_Buf*,&_M_buf); }
1.162 +
1.163 + _String str() const { return _M_buf.str(); }
1.164 + void str(const _String& __s) { _M_buf.str(__s); }
1.165 +
1.166 +private:
1.167 + basic_stringbuf<_CharT, _Traits, _Alloc> _M_buf;
1.168 +};
1.169 +
1.170 +
1.171 +//----------------------------------------------------------------------
1.172 +// Class basic_ostringstream, an output stream that uses a stringbuf.
1.173 +
1.174 +template <class _CharT, class _Traits, class _Alloc>
1.175 +#ifdef __SYMBIAN32__
1.176 +NONSHARABLE_CLASS ( basic_ostringstream ) : public basic_ostream<_CharT, _Traits>
1.177 +#else
1.178 +class basic_ostringstream : public basic_ostream<_CharT, _Traits>
1.179 +#endif
1.180 +{
1.181 +public: // Typedefs
1.182 + typedef typename _Traits::char_type char_type;
1.183 + typedef typename _Traits::int_type int_type;
1.184 + typedef typename _Traits::pos_type pos_type;
1.185 + typedef typename _Traits::off_type off_type;
1.186 + typedef _Traits traits_type;
1.187 +
1.188 + typedef basic_ios<_CharT, _Traits> _Basic_ios;
1.189 + typedef basic_ostream<_CharT, _Traits> _Base;
1.190 + typedef basic_string<_CharT, _Traits, _Alloc> _String;
1.191 + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Buf;
1.192 +
1.193 +public: // Constructors, destructor.
1.194 + basic_ostringstream(ios_base::openmode __mode = ios_base::out);
1.195 + basic_ostringstream(const _String& __str,
1.196 + ios_base::openmode __mode = ios_base::out);
1.197 + ~basic_ostringstream();
1.198 +
1.199 +public: // Member functions.
1.200 +
1.201 + basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const
1.202 + { return __CONST_CAST(_Buf*,&_M_buf); }
1.203 +
1.204 + _String str() const { return _M_buf.str(); }
1.205 + void str(const _String& __s) { _M_buf.str(__s); } // dwa 02/07/00 - BUG STOMPER DAVE
1.206 +
1.207 +
1.208 +private:
1.209 + basic_stringbuf<_CharT, _Traits, _Alloc> _M_buf;
1.210 +};
1.211 +
1.212 +
1.213 +//----------------------------------------------------------------------
1.214 +// Class basic_stringstream, a bidirectional stream that uses a stringbuf.
1.215 +
1.216 +template <class _CharT, class _Traits, class _Alloc>
1.217 +#ifdef __SYMBIAN32__
1.218 +NONSHARABLE_CLASS ( basic_stringstream ) : public basic_iostream<_CharT, _Traits>
1.219 +#else
1.220 +class basic_stringstream : public basic_iostream<_CharT, _Traits>
1.221 +#endif
1.222 +{
1.223 +public: // Typedefs
1.224 + typedef typename _Traits::char_type char_type;
1.225 + typedef typename _Traits::int_type int_type;
1.226 + typedef typename _Traits::pos_type pos_type;
1.227 + typedef typename _Traits::off_type off_type;
1.228 + typedef _Traits traits_type;
1.229 +
1.230 + typedef basic_ios<_CharT, _Traits> _Basic_ios;
1.231 + typedef basic_iostream<_CharT, _Traits> _Base;
1.232 + typedef basic_string<_CharT, _Traits, _Alloc> _String;
1.233 + typedef basic_stringbuf<_CharT, _Traits, _Alloc> _Buf;
1.234 +
1.235 + typedef ios_base::openmode openmode;
1.236 +
1.237 +public: // Constructors, destructor.
1.238 + _STLP_DECLSPEC basic_stringstream(openmode __mod = ios_base::in | ios_base::out);
1.239 + _STLP_DECLSPEC basic_stringstream(const _String& __str,
1.240 + openmode __mod = ios_base::in | ios_base::out);
1.241 + ~basic_stringstream();
1.242 +
1.243 +public: // Member functions.
1.244 +
1.245 + basic_stringbuf<_CharT, _Traits, _Alloc>* rdbuf() const
1.246 + { return __CONST_CAST(_Buf*,&_M_buf); }
1.247 +
1.248 + _String str() const { return _M_buf.str(); }
1.249 + void str(const _String& __s) { _M_buf.str(__s); }
1.250 +
1.251 +private:
1.252 + basic_stringbuf<_CharT, _Traits, _Alloc> _M_buf;
1.253 +};
1.254 +
1.255 +
1.256 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.257 +_STLP_EXPORT_TEMPLATE_CLASS basic_istringstream<char, char_traits<char>, allocator<char> >;
1.258 +_STLP_EXPORT_TEMPLATE_CLASS basic_ostringstream<char, char_traits<char>, allocator<char> >;
1.259 +_STLP_EXPORT_TEMPLATE_CLASS basic_stringstream<char, char_traits<char>, allocator<char> >;
1.260 +# if !defined (_STLP_NO_WCHAR_T)
1.261 +_STLP_EXPORT_TEMPLATE_CLASS basic_istringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
1.262 +_STLP_EXPORT_TEMPLATE_CLASS basic_ostringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
1.263 +_STLP_EXPORT_TEMPLATE_CLASS basic_stringstream<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >;
1.264 +# endif
1.265 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.266 +
1.267 +_STLP_END_NAMESPACE
1.268 +
1.269 +# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
1.270 +# include <stl/_sstream.c>
1.271 +# endif
1.272 +
1.273 +#endif /* _STLP_SSTREAM_H */
1.274 +
1.275 +// Local Variables:
1.276 +// mode:C++
1.277 +// End: