diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/stdapis/stlportv5/stl/_istream.h --- a/epoc32/include/stdapis/stlportv5/stl/_istream.h Wed Mar 31 12:27:01 2010 +0100 +++ b/epoc32/include/stdapis/stlportv5/stl/_istream.h Wed Mar 31 12:33:34 2010 +0100 @@ -1,49 +1,44 @@ /* - * © Portions copyright (c) 2006-2007 Nokia Corporation. All rights reserved. * Copyright (c) 1999 * Silicon Graphics Computer Systems, Inc. * - * Copyright (c) 1999 + * 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 + * 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_ISTREAM_H -#define _STLP_INTERNAL_ISTREAM_H + */ +#ifndef _STLP_INTERNAL_ISTREAM +#define _STLP_INTERNAL_ISTREAM // this block is included by _ostream.h, we include it here to lower #include level -# if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_CWCHAR_H) +#if defined (_STLP_HAS_WCHAR_T) && !defined (_STLP_INTERNAL_CWCHAR) # include -# endif +#endif -# ifndef _STLP_INTERNAL_IOS_H +#ifndef _STLP_INTERNAL_IOS_H # include // For basic_ios<>. Includes . -# endif +#endif #ifndef _STLP_INTERNAL_OSTREAM_H -# include // Needed as a base class of basic_iostream. +# include // Needed as a base class of basic_iostream. #endif #ifndef _STLP_INTERNAL_ISTREAMBUF_ITERATOR_H -# include +# include #endif #include // Helper functions that allow char traits // to be used as function objects. _STLP_BEGIN_NAMESPACE -template -ios_base::iostate _STLP_CALL -_M_get_num(basic_istream<_CharT, _Traits>& __that, _Number& __val); - #if defined (_STLP_USE_TEMPLATE_EXPORT) template class _Isentry; @@ -52,9 +47,9 @@ struct _No_Skip_WS {}; // Dummy class used by sentry. template -bool _M_init_skip(basic_istream<_CharT, _Traits>& __is); +bool _M_init_skip(basic_istream<_CharT, _Traits>& __istr); template -bool _M_init_noskip(basic_istream<_CharT, _Traits>& __is); +bool _M_init_noskip(basic_istream<_CharT, _Traits>& __istr); //---------------------------------------------------------------------- // Class basic_istream, a class that performs formatted input through @@ -62,10 +57,18 @@ // The second template parameter, _Traits, defaults to char_traits<_CharT>. // The default is declared in header , and it isn't declared here -// because C++ language rules do not allow it to be declared twice. +// because C++ language rules do not allow it to be declared twice. template class basic_istream : virtual public basic_ios<_CharT, _Traits> { + typedef basic_istream<_CharT, _Traits> _Self; + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + //explicitely defined as private to avoid warnings: + basic_istream(_Self const&); + _Self& operator = (_Self const&); +#endif + public: // Types typedef _CharT char_type; @@ -74,15 +77,17 @@ typedef typename _Traits::off_type off_type; typedef _Traits traits_type; typedef basic_ios<_CharT, _Traits> _Basic_ios; - typedef basic_istream<_CharT, _Traits> _Self; typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&); typedef ios_base& (_STLP_CALL *__ios_base_fn)(ios_base&); typedef _Self& (_STLP_CALL *__istream_fn)(_Self&); public: // Constructor and destructor. - _STLP_DECLSPEC explicit basic_istream(basic_streambuf<_CharT, _Traits>* __buf); - _STLP_DECLSPEC ~basic_istream(); + explicit basic_istream(basic_streambuf<_CharT, _Traits>* __buf) : + basic_ios<_CharT, _Traits>(), _M_gcount(0) { + this->init(__buf); + } + ~basic_istream() {}; public: // Nested sentry class. @@ -93,47 +98,25 @@ _Self& operator>> (__ios_base_fn __f) { __f(*this); return *this; } public: // Formatted input of numbers. - _Self& operator>> (short& __val) { - long __lval = __val; - unsigned short __uval; - _M_get_num(*this, __lval); - __val = __STATIC_CAST(short, __lval); - __uval = __lval; - // check if we lose digits - // if ((__val != __lval) && ((unsigned short)__val != __lval)) - if ((__val != __lval) && ((long)__uval != __lval)) - this->setstate(ios_base::failbit); - return *this; - } - _Self& operator>> (int& __val) { - long __lval = __val; - unsigned int __uval; - _M_get_num(*this, __lval); - __val = __lval; - __uval = __lval; - // check if we lose digits - // if ((__val != __lval) && ((unsigned int)__val != __lval)) - if ((__val != __lval) && ((long)__uval != __lval)) - this->setstate(ios_base::failbit); - return *this; - } - _Self& operator>> (unsigned short& __val) { _M_get_num(*this, __val); return *this; } - _Self& operator>> (unsigned int& __val) { _M_get_num(*this, __val); return *this; } - _Self& operator>> (long& __val) { _M_get_num(*this, __val); return *this; } - _Self& operator>> (unsigned long& __val) { _M_get_num(*this, __val); return *this; } + _Self& operator>> (short& __val); + _Self& operator>> (int& __val); + _Self& operator>> (unsigned short& __val); + _Self& operator>> (unsigned int& __val); + _Self& operator>> (long& __val); + _Self& operator>> (unsigned long& __val); #ifdef _STLP_LONG_LONG - _Self& operator>> (_STLP_LONG_LONG& __val) { _M_get_num(*this, __val); return *this; } - _Self& operator>> (unsigned _STLP_LONG_LONG& __val) { _M_get_num(*this, __val); return *this; } -#endif - _Self& operator>> (float& __val) { _M_get_num(*this, __val); return *this; } - _Self& operator>> (double& __val) { _M_get_num(*this, __val); return *this; } + _Self& operator>> (_STLP_LONG_LONG& __val); + _Self& operator>> (unsigned _STLP_LONG_LONG& __val); +#endif + _Self& operator>> (float& __val); + _Self& operator>> (double& __val); # ifndef _STLP_NO_LONG_DOUBLE - _Self& operator>> (long double& __val) { _M_get_num(*this, __val); return *this; } + _Self& operator>> (long double& __val); # endif # ifndef _STLP_NO_BOOL - _Self& operator>> (bool& __val) { _M_get_num(*this, __val); return *this; } + _Self& operator>> (bool& __val); # endif - _Self& operator>> (void*& __val) { _M_get_num(*this, __val); return *this; } + _Self& operator>> (void*& __val); public: // Copying characters into a streambuf. _Self& operator>>(basic_streambuf<_CharT, _Traits>*); @@ -207,34 +190,35 @@ class sentry { typedef sentry _Self; #endif - + private: const bool _M_ok; // basic_streambuf<_CharT, _Traits>* _M_buf; - + public: typedef _Traits traits_type; - - explicit sentry(basic_istream<_CharT, _Traits>& __is, - bool __noskipws = false) : - _M_ok((__noskipws || !(__is.flags() & ios_base::skipws)) ? _M_init_noskip(__is) : _M_init_skip(__is) ) - /* , _M_buf(__is.rdbuf()) */ + + explicit sentry(basic_istream<_CharT, _Traits>& __istr, + bool __noskipws = false) : + _M_ok((__noskipws || !(__istr.flags() & ios_base::skipws)) ? _M_init_noskip(__istr) : _M_init_skip(__istr) ) + /* , _M_buf(__istr.rdbuf()) */ {} - - // Calling this constructor is the same as calling the previous one with + + // Calling this constructor is the same as calling the previous one with // __noskipws = true, except that it doesn't require a runtime test. - sentry(basic_istream<_CharT, _Traits>& __is, _No_Skip_WS) : /* _M_buf(__is.rdbuf()), */ - _M_ok(_M_init_noskip(__is)) {} - + sentry(basic_istream<_CharT, _Traits>& __istr, _No_Skip_WS) : /* _M_buf(__istr.rdbuf()), */ + _M_ok(_M_init_noskip(__istr)) {} + ~sentry() {} - + operator bool() const { return _M_ok; } - + private: // Disable assignment and copy constructor. + //Implementation is here only to avoid warning with some compilers. sentry(const _Self&) : _M_ok(false) {} - void operator=(const _Self&) {} + _Self& operator=(const _Self&) { return *this; } }; - + # if defined (_STLP_USE_TEMPLATE_EXPORT) # undef sentry # else @@ -252,58 +236,95 @@ # endif /* _STLP_USE_TEMPLATE_EXPORT */ // Non-member character and string extractor functions. - template -inline basic_istream<_CharT, _Traits>& _STLP_CALL -operator>>(basic_istream<_CharT, _Traits>& __stl_in, _CharT& __c) { - __stl_in._M_formatted_get(__c); - return __stl_in; +inline basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __in_str, _CharT& __c) { + __in_str._M_formatted_get(__c); + return __in_str; } template -inline basic_istream& _STLP_CALL -operator>>(basic_istream& __stl_in, unsigned char& __c) { - __stl_in._M_formatted_get(__REINTERPRET_CAST(char&,__c)); - return __stl_in; +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, unsigned char& __c) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char&,__c)); + return __in_str; } template -inline basic_istream& _STLP_CALL -operator>>(basic_istream& __stl_in, signed char& __c) { - __stl_in._M_formatted_get(__REINTERPRET_CAST(char&,__c)); - return __stl_in; +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, signed char& __c) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char&,__c)); + return __in_str; } template -inline basic_istream<_CharT, _Traits>& _STLP_CALL -operator>>(basic_istream<_CharT, _Traits>& __stl_in, _CharT* __s) { - __stl_in._M_formatted_get(__s); - return __stl_in; +inline basic_istream<_CharT, _Traits>& _STLP_CALL +operator>>(basic_istream<_CharT, _Traits>& __in_str, _CharT* __s) { + __in_str._M_formatted_get(__s); + return __in_str; } template -inline basic_istream& _STLP_CALL -operator>>(basic_istream& __stl_in, unsigned char* __s) { - __stl_in._M_formatted_get(__REINTERPRET_CAST(char*,__s)); - return __stl_in; +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, unsigned char* __s) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char*,__s)); + return __in_str; } template -inline basic_istream& _STLP_CALL -operator>>(basic_istream& __stl_in, signed char* __s) { - __stl_in._M_formatted_get(__REINTERPRET_CAST(char*,__s)); - return __stl_in; +inline basic_istream& _STLP_CALL +operator>>(basic_istream& __in_str, signed char* __s) { + __in_str._M_formatted_get(__REINTERPRET_CAST(char*,__s)); + return __in_str; } //---------------------------------------------------------------------- // istream manipulator. template basic_istream<_CharT, _Traits>& _STLP_CALL -ws(basic_istream<_CharT, _Traits>& __is); +ws(basic_istream<_CharT, _Traits>& __istr) { + if (!__istr.eof()) { + typedef typename basic_istream<_CharT, _Traits>::sentry _Sentry; + _Sentry __sentry(__istr, _No_Skip_WS()); // Don't skip whitespace. + if (__sentry) + __istr._M_skip_whitespace(false); + } + return __istr; +} + +// Helper functions for istream<>::sentry constructor. +template +inline bool _M_init_skip(basic_istream<_CharT, _Traits>& __istr) { + if (__istr.good()) { + if (__istr.tie()) + __istr.tie()->flush(); + + __istr._M_skip_whitespace(true); + } + + if (!__istr.good()) { + __istr.setstate(ios_base::failbit); + return false; + } else + return true; +} + +template +inline bool _M_init_noskip(basic_istream<_CharT, _Traits>& __istr) { + if (__istr.good()) { + if (__istr.tie()) + __istr.tie()->flush(); + + if (!__istr.rdbuf()) + __istr.setstate(ios_base::badbit); + } + else + __istr.setstate(ios_base::failbit); + return __istr.good(); +} //---------------------------------------------------------------------- // Class iostream. - template class basic_iostream : public basic_istream<_CharT, _Traits>, @@ -312,30 +333,29 @@ public: typedef basic_ios<_CharT, _Traits> _Basic_ios; - _STLP_DECLSPEC explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __buf); - _STLP_DECLSPEC virtual ~basic_iostream(); + explicit basic_iostream(basic_streambuf<_CharT, _Traits>* __buf); + virtual ~basic_iostream(); }; # if defined (_STLP_USE_TEMPLATE_EXPORT) _STLP_EXPORT_TEMPLATE_CLASS basic_iostream >; + # if ! defined (_STLP_NO_WCHAR_T) _STLP_EXPORT_TEMPLATE_CLASS basic_iostream >; # endif # endif /* _STLP_USE_TEMPLATE_EXPORT */ template -basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& __is) -{ - return __is.rdbuf(); -} +basic_streambuf<_CharT, _Traits>* _STLP_CALL _M_get_istreambuf(basic_istream<_CharT, _Traits>& __istr) +{ return __istr.rdbuf(); } _STLP_END_NAMESPACE -# if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) +#if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) # include -# endif +#endif -#endif /* _STLP_INTERNAL_ISTREAM_H */ +#endif /* _STLP_INTERNAL_ISTREAM */ // Local Variables: // mode:C++