diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/stdapis/stlportv5/stl/_ostream.h --- a/epoc32/include/stdapis/stlportv5/stl/_ostream.h Wed Mar 31 12:27:01 2010 +0100 +++ b/epoc32/include/stdapis/stlportv5/stl/_ostream.h Wed Mar 31 12:33:34 2010 +0100 @@ -1,58 +1,64 @@ /* - * © 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_OSTREAM_H #define _STLP_INTERNAL_OSTREAM_H #ifndef _STLP_INTERNAL_IOS_H -# include // For basic_ios<>. Includes . +# include // For basic_ios<>. Includes . #endif #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H -# include +# include +#endif + +#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) && !defined (_STLP_INTERNAL_EXCEPTION) +# include #endif _STLP_BEGIN_NAMESPACE -template -basic_ostream<_CharT, _Traits>& _STLP_CALL -_M_put_num(basic_ostream<_CharT, _Traits>& __os, _Number __x); - -# if defined (_STLP_USE_TEMPLATE_EXPORT) +#if defined (_STLP_USE_TEMPLATE_EXPORT) template class _Osentry; -# endif +#endif + +_STLP_MOVE_TO_PRIV_NAMESPACE template -bool -_M_init(basic_ostream<_CharT, _Traits>& __str); +bool __init_bostr(basic_ostream<_CharT, _Traits>& __str); + +_STLP_MOVE_TO_STD_NAMESPACE //---------------------------------------------------------------------- // class basic_ostream<> template -class basic_ostream : virtual public basic_ios<_CharT, _Traits> -{ +class basic_ostream : virtual public basic_ios<_CharT, _Traits> { typedef basic_ostream<_CharT, _Traits> _Self; - + +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310) + //explicitely defined as private to avoid warnings: + basic_ostream(_Self const&); + _Self& operator = (_Self const&); +#endif + public: // Types typedef _CharT char_type; typedef typename _Traits::int_type int_type; @@ -62,8 +68,8 @@ typedef basic_ios<_CharT, _Traits> _Basic_ios; public: // Constructor and destructor. - _STLP_DECLSPEC explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf); - _STLP_DECLSPEC ~basic_ostream(); + explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf); + ~basic_ostream(); public: // Hooks for manipulators. typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&); @@ -97,44 +103,31 @@ // this is needed for compiling with option char = unsigned _Self& operator<<(unsigned char __x) { _M_put_char(__x); return *this; } # endif -#ifdef __SYMBIAN32__ - _Self& operator<<(short __x) - { - ios_base::fmtflags __fmtf = - ios_base::flags() & ios_base::basefield; - long __ly = (__fmtf == ios_base::oct || __fmtf == ios_base::hex) ? - (long)(unsigned short)(__x) : (long)__x; - return _M_put_num(*this, __ly); - } - _Self& operator<<(int __x) - { - ios_base::fmtflags __fmtf = - ios_base::flags() & ios_base::basefield; - long __ly = (__fmtf == ios_base::oct || __fmtf == ios_base::hex) ? - (long)(unsigned int)(__x) : (long)__x; - return _M_put_num(*this, __ly); - } + _Self& operator<<(short __x); + _Self& operator<<(unsigned short __x); + _Self& operator<<(int __x); +#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300) + _Self& operator<<(unsigned int __x); #else - _Self& operator<<(short __x) { return _M_put_num(*this, __x); } - _Self& operator<<(int __x) { return _M_put_num(*this, __x); } +/* We define this operator with size_t rather than unsigned int to avoid + * 64 bits warning. + */ + _Self& operator<<(size_t __x); #endif - _Self& operator<<(unsigned int __x) { return _M_put_num(*this, __STATIC_CAST(unsigned long,__x)); } - _Self& operator<<(unsigned short __x) { return _M_put_num(*this, __STATIC_CAST(unsigned long,__x)); } - _Self& operator<<(long __x) { return _M_put_num(*this, __x); } - _Self& operator<<(unsigned long __x) { return _M_put_num(*this, __x); } + _Self& operator<<(long __x); + _Self& operator<<(unsigned long __x); #ifdef _STLP_LONG_LONG - _Self& operator<< (_STLP_LONG_LONG __x) { return _M_put_num(*this, __x); } - _Self& operator<< (unsigned _STLP_LONG_LONG __x) { return _M_put_num(*this, __x); } -#endif - _Self& operator<<(float __x) - { return _M_put_num(*this, __STATIC_CAST(double,__x)); } - _Self& operator<<(double __x) { return _M_put_num(*this, __x); } + _Self& operator<< (_STLP_LONG_LONG __x); + _Self& operator<< (unsigned _STLP_LONG_LONG __x); +#endif + _Self& operator<<(float __x); + _Self& operator<<(double __x); # ifndef _STLP_NO_LONG_DOUBLE - _Self& operator<<(long double __x) { return _M_put_num(*this, __x); } + _Self& operator<<(long double __x); # endif - _Self& operator<<(const void* __x) { return _M_put_num(*this, __x); } + _Self& operator<<(const void* __x); # ifndef _STLP_NO_BOOL - _Self& operator<<(bool __x) { return _M_put_num(*this, __x); } + _Self& operator<<(bool __x); # endif public: // Buffer positioning and manipulation. @@ -152,16 +145,17 @@ } _Self& seekp(pos_type __pos) { - if (this->rdbuf() && !this->fail()) - if( pos_type(off_type(-1)) == this->rdbuf()->pubseekpos(__pos, ios_base::out)) + if (this->rdbuf() && !this->fail()) { + if (this->rdbuf()->pubseekpos(__pos) == pos_type(-1)) { this->setstate(ios_base::failbit); + } + } return *this; } _Self& seekp(off_type __off, ios_base::seekdir __dir) { if (this->rdbuf() && !this->fail()) - if( pos_type(off_type(-1)) == this->rdbuf()->pubseekoff(__off, __dir, ios_base::out)) - this->setstate(ios_base::failbit); + this->rdbuf()->pubseekoff(__off, __dir); return *this; } @@ -174,61 +168,77 @@ template class _Osentry { typedef _Osentry<_CharT, _Traits> _Self; -# else +#else class sentry { typedef sentry _Self; -# endif +#endif private: basic_ostream<_CharT, _Traits>& _M_str; // basic_streambuf<_CharT, _Traits>* _M_buf; bool _M_ok; public: explicit sentry(basic_ostream<_CharT, _Traits>& __str) - : _M_str(__str), /* _M_buf(__str.rdbuf()), */ _M_ok(_M_init(__str)) - { - } - + : _M_str(__str), /* _M_buf(__str.rdbuf()), */ _M_ok(_STLP_PRIV __init_bostr(__str)) + {} + ~sentry() { if (_M_str.flags() & ios_base::unitbuf) -# ifndef _STLP_INCOMPLETE_EXCEPTION_HEADER - if (!_STLP_VENDOR_EXCEPT_STD::uncaught_exception()) -# endif +#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) + if (!uncaught_exception()) +#endif _M_str.flush(); } operator bool() const { return _M_ok; } private: // Disable assignment and copy constructor. - sentry(const _Self& __s) : _M_str (__s._M_str) {}; - void operator=(const _Self&) {}; + //Implementation is here only to avoid warning with some compilers. + sentry(const _Self& __s) : _M_str(__s._M_str) {} + _Self& operator=(const _Self&) { return *this; } }; -# if defined (_STLP_USE_TEMPLATE_EXPORT) +#if defined (_STLP_USE_TEMPLATE_EXPORT) # undef sentry -# else - // close basic_ostream class definition here +#else + // close basic_ostream class definition here }; -# endif - -# if defined (_STLP_USE_TEMPLATE_EXPORT) +#endif + +#if defined (_STLP_USE_TEMPLATE_EXPORT) _STLP_EXPORT_TEMPLATE_CLASS basic_ostream >; _STLP_EXPORT_TEMPLATE_CLASS _Osentry >; # if !defined (_STLP_NO_WCHAR_T) _STLP_EXPORT_TEMPLATE_CLASS basic_ostream >; _STLP_EXPORT_TEMPLATE_CLASS _Osentry >; # endif -# endif /* _STLP_USE_TEMPLATE_EXPORT */ +#endif /* _STLP_USE_TEMPLATE_EXPORT */ + +_STLP_MOVE_TO_PRIV_NAMESPACE + +// Helper functions for istream<>::sentry constructor. +template +bool __init_bostr(basic_ostream<_CharT, _Traits>& __str) { + if (__str.good()) { + // boris : check if this is needed ! + if (!__str.rdbuf()) + __str.setstate(ios_base::badbit); + if (__str.tie()) + __str.tie()->flush(); + return __str.good(); + } + else + return false; +} template -inline basic_streambuf<_CharT, _Traits>* _STLP_CALL -_M_get_ostreambuf(basic_ostream<_CharT, _Traits>& __St) -{ - return __St.rdbuf(); -} +inline basic_streambuf<_CharT, _Traits>* _STLP_CALL +__get_ostreambuf(basic_ostream<_CharT, _Traits>& __St) +{ return __St.rdbuf(); } + +_STLP_MOVE_TO_STD_NAMESPACE // Non-member functions. - template inline basic_ostream<_CharT, _Traits>& _STLP_CALL -operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) { +operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c){ __os._M_put_char(__c); return __os; } @@ -236,15 +246,11 @@ template inline basic_ostream<_CharT, _Traits>& _STLP_CALL operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s); -#else __os._M_put_nowiden(__s); -#endif return __os; } -# ifdef _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER +#if defined (_STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER) // some specializations inline basic_ostream >& _STLP_CALL @@ -267,35 +273,23 @@ inline basic_ostream >& _STLP_CALL operator<<(basic_ostream >& __os, const char* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s); -#else __os._M_put_nowiden(__s); -#endif return __os; } inline basic_ostream >& _STLP_CALL operator<<(basic_ostream >& __os, const signed char* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#else - __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#endif + __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); return __os; } inline basic_ostream >& operator<<(basic_ostream >& __os, const unsigned char* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#else __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#endif return __os; } -# else +#else // also for compilers who might use that template @@ -329,47 +323,31 @@ template inline basic_ostream<_CharT, _Traits>& _STLP_CALL operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_widen(__s); -#else __os._M_put_widen(__s); -#endif return __os; } template inline basic_ostream& _STLP_CALL operator<<(basic_ostream& __os, const char* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s); -#else __os._M_put_nowiden(__s); -#endif return __os; } template inline basic_ostream& _STLP_CALL operator<<(basic_ostream& __os, const signed char* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#else __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#endif return __os; } template inline basic_ostream& operator<<(basic_ostream& __os, const unsigned char* __s) { -#ifdef __SYMBIAN32__ - !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#else __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s)); -#endif return __os; } -# endif /* _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER */ +#endif /* _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER */ //---------------------------------------------------------------------- // basic_ostream manipulators. @@ -398,11 +376,9 @@ _STLP_END_NAMESPACE -# undef _STLP_MANIP_INLINE - #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION) # include -# endif +#endif #endif /* _STLP_INTERNAL_OSTREAM_H */