1.1 --- a/epoc32/include/stdapis/stlport/stl/_istream.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_istream.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,342 @@
1.4 -_istream.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 +#ifndef _STLP_INTERNAL_ISTREAM_H
1.24 +#define _STLP_INTERNAL_ISTREAM_H
1.25 +
1.26 +// this block is included by _ostream.h, we include it here to lower #include level
1.27 +# if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_CWCHAR_H)
1.28 +# include <stl/_cwchar.h>
1.29 +# endif
1.30 +
1.31 +# ifndef _STLP_INTERNAL_IOS_H
1.32 +# include <stl/_ios.h> // For basic_ios<>. Includes <iosfwd>.
1.33 +# endif
1.34 +
1.35 +#ifndef _STLP_INTERNAL_OSTREAM_H
1.36 +# include <stl/_ostream.h> // Needed as a base class of basic_iostream.
1.37 +#endif
1.38 +
1.39 +#ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H
1.40 +# include <stl/_istreambuf_iterator.h>
1.41 +#endif
1.42 +
1.43 +#include <stl/_ctraits_fns.h> // Helper functions that allow char traits
1.44 + // to be used as function objects.
1.45 +_STLP_BEGIN_NAMESPACE
1.46 +
1.47 +template <class _CharT, class _Traits, class _Number>
1.48 +ios_base::iostate _STLP_CALL
1.49 +_M_get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val);
1.50 +
1.51 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
1.52 +template <class _CharT, class _Traits>
1.53 +class _Isentry;
1.54 +#endif
1.55 +
1.56 +struct _No_Skip_WS {}; // Dummy class used by sentry.
1.57 +
1.58 +template <class _CharT, class _Traits>
1.59 +bool _M_init_skip(basic_istream<_CharT, _Traits>& __is);
1.60 +template <class _CharT, class _Traits>
1.61 +bool _M_init_noskip(basic_istream<_CharT, _Traits>& __is);
1.62 +
1.63 +//----------------------------------------------------------------------
1.64 +// Class basic_istream, a class that performs formatted input through
1.65 +// a stream buffer.
1.66 +
1.67 +// The second template parameter, _Traits, defaults to char_traits<_CharT>.
1.68 +// The default is declared in header <iosfwd>, and it isn't declared here
1.69 +// because C++ language rules do not allow it to be declared twice.
1.70 +
1.71 +template <class _CharT, class _Traits>
1.72 +class basic_istream : virtual public basic_ios<_CharT, _Traits> {
1.73 +public:
1.74 + // Types
1.75 + typedef _CharT char_type;
1.76 + typedef typename _Traits::int_type int_type;
1.77 + typedef typename _Traits::pos_type pos_type;
1.78 + typedef typename _Traits::off_type off_type;
1.79 + typedef _Traits traits_type;
1.80 + typedef basic_ios<_CharT, _Traits> _Basic_ios;
1.81 + typedef basic_istream<_CharT, _Traits> _Self;
1.82 +
1.83 + typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&);
1.84 + typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&);
1.85 + typedef _Self& (_STLP_CALL *__istream_fn)(_Self&);
1.86 +
1.87 +public: // Constructor and destructor.
1.88 + _STLP_DECLSPEC explicit basic_istream(basic_streambuf<_CharT, _Traits>* __buf);
1.89 + _STLP_DECLSPEC ~basic_istream();
1.90 +
1.91 +public: // Nested sentry class.
1.92 +
1.93 +public: // Hooks for manipulators. The arguments are
1.94 + // function pointers.
1.95 + _Self& operator>> (__istream_fn __f) { return __f(*this); }
1.96 + _Self& operator>> (__ios_fn __f) { __f(*this); return *this; }
1.97 + _Self& operator>> (__ios_base_fn __f) { __f(*this); return *this; }
1.98 +
1.99 +public: // Formatted input of numbers.
1.100 + _Self& operator>> (short& __val) {
1.101 + long __lval = __val;
1.102 + unsigned short __uval;
1.103 + _M_get_num(*this, __lval);
1.104 + __val = __STATIC_CAST(short, __lval);
1.105 + __uval = __lval;
1.106 + // check if we lose digits
1.107 + // if ((__val != __lval) && ((unsigned short)__val != __lval))
1.108 + if ((__val != __lval) && ((long)__uval != __lval))
1.109 + this->setstate(ios_base::failbit);
1.110 + return *this;
1.111 + }
1.112 + _Self& operator>> (int& __val) {
1.113 + long __lval = __val;
1.114 + unsigned int __uval;
1.115 + _M_get_num(*this, __lval);
1.116 + __val = __lval;
1.117 + __uval = __lval;
1.118 + // check if we lose digits
1.119 + // if ((__val != __lval) && ((unsigned int)__val != __lval))
1.120 + if ((__val != __lval) && ((long)__uval != __lval))
1.121 + this->setstate(ios_base::failbit);
1.122 + return *this;
1.123 + }
1.124 + _Self& operator>> (unsigned short& __val) { _M_get_num(*this, __val); return *this; }
1.125 + _Self& operator>> (unsigned int& __val) { _M_get_num(*this, __val); return *this; }
1.126 + _Self& operator>> (long& __val) { _M_get_num(*this, __val); return *this; }
1.127 + _Self& operator>> (unsigned long& __val) { _M_get_num(*this, __val); return *this; }
1.128 +#ifdef _STLP_LONG_LONG
1.129 + _Self& operator>> (_STLP_LONG_LONG& __val) { _M_get_num(*this, __val); return *this; }
1.130 + _Self& operator>> (unsigned _STLP_LONG_LONG& __val) { _M_get_num(*this, __val); return *this; }
1.131 +#endif
1.132 + _Self& operator>> (float& __val) { _M_get_num(*this, __val); return *this; }
1.133 + _Self& operator>> (double& __val) { _M_get_num(*this, __val); return *this; }
1.134 +# ifndef _STLP_NO_LONG_DOUBLE
1.135 + _Self& operator>> (long double& __val) { _M_get_num(*this, __val); return *this; }
1.136 +# endif
1.137 +# ifndef _STLP_NO_BOOL
1.138 + _Self& operator>> (bool& __val) { _M_get_num(*this, __val); return *this; }
1.139 +# endif
1.140 + _Self& operator>> (void*& __val) { _M_get_num(*this, __val); return *this; }
1.141 +
1.142 +public: // Copying characters into a streambuf.
1.143 + _Self& operator>>(basic_streambuf<_CharT, _Traits>*);
1.144 +
1.145 +public: // Unformatted input.
1.146 + streamsize gcount() const { return _M_gcount; }
1.147 + int_type peek();
1.148 +
1.149 +public: // get() for single characters
1.150 + int_type get();
1.151 + _Self& get(char_type& __c);
1.152 +
1.153 +public: // get() for character arrays.
1.154 + _Self& get(char_type* __s, streamsize __n, char_type __delim);
1.155 + _Self& get(char_type* __s, streamsize __n)
1.156 + { return get(__s, __n, this->widen('\n')); }
1.157 +
1.158 +public: // get() for streambufs
1.159 + _Self& get(basic_streambuf<_CharT, _Traits>& __buf,
1.160 + char_type __delim);
1.161 + _Self& get(basic_streambuf<_CharT, _Traits>& __buf)
1.162 + { return get(__buf, this->widen('\n')); }
1.163 +
1.164 +public: // getline()
1.165 + _Self& getline(char_type* __s, streamsize __n, char_type delim);
1.166 + _Self& getline(char_type* __s, streamsize __n)
1.167 + { return getline(__s, __n, this->widen('\n')); }
1.168 +
1.169 +public: // read(), readsome(), ignore()
1.170 + _Self& ignore();
1.171 + _Self& ignore(streamsize __n);
1.172 +#if (defined (_STLP_MSVC) && _STLP_MSVC < 1200)
1.173 + inline
1.174 +#endif
1.175 + _Self& ignore(streamsize __n, int_type __delim);
1.176 +
1.177 + _Self& read(char_type* __s, streamsize __n);
1.178 + streamsize readsome(char_type* __s, streamsize __n);
1.179 +
1.180 +public: // putback
1.181 + _Self& putback(char_type __c);
1.182 + _Self& unget();
1.183 +
1.184 +public: // Positioning and buffer control.
1.185 + int sync();
1.186 +
1.187 + pos_type tellg();
1.188 + _Self& seekg(pos_type __pos);
1.189 + _Self& seekg(off_type, ios_base::seekdir);
1.190 +
1.191 +public: // Helper functions for non-member extractors.
1.192 + void _M_formatted_get(_CharT& __c);
1.193 + void _M_formatted_get(_CharT* __s);
1.194 + void _M_skip_whitespace(bool __set_failbit);
1.195 +
1.196 +private: // Number of characters extracted by the
1.197 + streamsize _M_gcount; // most recent unformatted input function.
1.198 +
1.199 +public:
1.200 +
1.201 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
1.202 + // If we are using DLL specs, we have not to use inner classes
1.203 + // end class declaration here
1.204 + typedef _Isentry<_CharT, _Traits> sentry;
1.205 +};
1.206 +# define sentry _Isentry
1.207 +template <class _CharT, class _Traits>
1.208 +class _Isentry {
1.209 + typedef _Isentry<_CharT, _Traits> _Self;
1.210 +# else
1.211 + class sentry {
1.212 + typedef sentry _Self;
1.213 +#endif
1.214 +
1.215 + private:
1.216 + const bool _M_ok;
1.217 + // basic_streambuf<_CharT, _Traits>* _M_buf;
1.218 +
1.219 + public:
1.220 + typedef _Traits traits_type;
1.221 +
1.222 + explicit sentry(basic_istream<_CharT, _Traits>& __is,
1.223 + bool __noskipws = false) :
1.224 + _M_ok((__noskipws || !(__is.flags() & ios_base::skipws)) ? _M_init_noskip(__is) : _M_init_skip(__is) )
1.225 + /* , _M_buf(__is.rdbuf()) */
1.226 + {}
1.227 +
1.228 + // Calling this constructor is the same as calling the previous one with
1.229 + // __noskipws = true, except that it doesn't require a runtime test.
1.230 + sentry(basic_istream<_CharT, _Traits>& __is, _No_Skip_WS) : /* _M_buf(__is.rdbuf()), */
1.231 + _M_ok(_M_init_noskip(__is)) {}
1.232 +
1.233 + ~sentry() {}
1.234 +
1.235 + operator bool() const { return _M_ok; }
1.236 +
1.237 + private: // Disable assignment and copy constructor.
1.238 + sentry(const _Self&) : _M_ok(false) {}
1.239 + void operator=(const _Self&) {}
1.240 + };
1.241 +
1.242 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.243 +# undef sentry
1.244 +# else
1.245 + // close basic_istream class definition here
1.246 +};
1.247 +# endif
1.248 +
1.249 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.250 +_STLP_EXPORT_TEMPLATE_CLASS _Isentry<char, char_traits<char> >;
1.251 +_STLP_EXPORT_TEMPLATE_CLASS basic_istream<char, char_traits<char> >;
1.252 +# if ! defined (_STLP_NO_WCHAR_T)
1.253 +_STLP_EXPORT_TEMPLATE_CLASS _Isentry<wchar_t, char_traits<wchar_t> >;
1.254 +_STLP_EXPORT_TEMPLATE_CLASS basic_istream<wchar_t, char_traits<wchar_t> >;
1.255 +# endif
1.256 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.257 +
1.258 +// Non-member character and string extractor functions.
1.259 +
1.260 +template <class _CharT, class _Traits>
1.261 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
1.262 +operator>>(basic_istream<_CharT, _Traits>& __stl_in, _CharT& __c) {
1.263 + __stl_in._M_formatted_get(__c);
1.264 + return __stl_in;
1.265 +}
1.266 +
1.267 +template <class _Traits>
1.268 +inline basic_istream<char, _Traits>& _STLP_CALL
1.269 +operator>>(basic_istream<char, _Traits>& __stl_in, unsigned char& __c) {
1.270 + __stl_in._M_formatted_get(__REINTERPRET_CAST(char&,__c));
1.271 + return __stl_in;
1.272 +}
1.273 +
1.274 +template <class _Traits>
1.275 +inline basic_istream<char, _Traits>& _STLP_CALL
1.276 +operator>>(basic_istream<char, _Traits>& __stl_in, signed char& __c) {
1.277 + __stl_in._M_formatted_get(__REINTERPRET_CAST(char&,__c));
1.278 + return __stl_in;
1.279 +}
1.280 +
1.281 +template <class _CharT, class _Traits>
1.282 +inline basic_istream<_CharT, _Traits>& _STLP_CALL
1.283 +operator>>(basic_istream<_CharT, _Traits>& __stl_in, _CharT* __s) {
1.284 + __stl_in._M_formatted_get(__s);
1.285 + return __stl_in;
1.286 +}
1.287 +
1.288 +template <class _Traits>
1.289 +inline basic_istream<char, _Traits>& _STLP_CALL
1.290 +operator>>(basic_istream<char, _Traits>& __stl_in, unsigned char* __s) {
1.291 + __stl_in._M_formatted_get(__REINTERPRET_CAST(char*,__s));
1.292 + return __stl_in;
1.293 +}
1.294 +
1.295 +template <class _Traits>
1.296 +inline basic_istream<char, _Traits>& _STLP_CALL
1.297 +operator>>(basic_istream<char, _Traits>& __stl_in, signed char* __s) {
1.298 + __stl_in._M_formatted_get(__REINTERPRET_CAST(char*,__s));
1.299 + return __stl_in;
1.300 +}
1.301 +
1.302 +//----------------------------------------------------------------------
1.303 +// istream manipulator.
1.304 +template <class _CharT, class _Traits>
1.305 +basic_istream<_CharT, _Traits>& _STLP_CALL
1.306 +ws(basic_istream<_CharT, _Traits>& __is);
1.307 +
1.308 +//----------------------------------------------------------------------
1.309 +// Class iostream.
1.310 +
1.311 +template <class _CharT, class _Traits>
1.312 +class basic_iostream
1.313 + : public basic_istream<_CharT, _Traits>,
1.314 + public basic_ostream<_CharT, _Traits>
1.315 +{
1.316 +public:
1.317 + typedef basic_ios<_CharT, _Traits> _Basic_ios;
1.318 +
1.319 + _STLP_DECLSPEC explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __buf);
1.320 + _STLP_DECLSPEC virtual ~basic_iostream();
1.321 +};
1.322 +
1.323 +# if defined (_STLP_USE_TEMPLATE_EXPORT)
1.324 +_STLP_EXPORT_TEMPLATE_CLASS basic_iostream<char, char_traits<char> >;
1.325 +# if ! defined (_STLP_NO_WCHAR_T)
1.326 +_STLP_EXPORT_TEMPLATE_CLASS basic_iostream<wchar_t, char_traits<wchar_t> >;
1.327 +# endif
1.328 +# endif /* _STLP_USE_TEMPLATE_EXPORT */
1.329 +
1.330 +template <class _CharT, class _Traits>
1.331 +basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& __is)
1.332 +{
1.333 + return __is.rdbuf();
1.334 +}
1.335 +
1.336 +_STLP_END_NAMESPACE
1.337 +
1.338 +# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
1.339 +# include <stl/_istream.c>
1.340 +# endif
1.341 +
1.342 +#endif /* _STLP_INTERNAL_ISTREAM_H */
1.343 +
1.344 +// Local Variables:
1.345 +// mode:C++
1.346 +// End: