epoc32/include/stdapis/stlportv5/stl/_ostream.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/_ostream.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_ostream.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -1,58 +1,64 @@
     1.4  /*
     1.5 - * © Portions copyright (c) 2006-2007 Nokia Corporation.  All rights reserved.
     1.6 - *
     1.7   * Copyright (c) 1999
     1.8   * Silicon Graphics Computer Systems, Inc.
     1.9   *
    1.10 - * Copyright (c) 1999 
    1.11 + * Copyright (c) 1999
    1.12   * Boris Fomitchev
    1.13   *
    1.14   * This material is provided "as is", with absolutely no warranty expressed
    1.15   * or implied. Any use is at your own risk.
    1.16   *
    1.17 - * Permission to use or copy this software for any purpose is hereby granted 
    1.18 + * Permission to use or copy this software for any purpose is hereby granted
    1.19   * without fee, provided the above notices are retained on all copies.
    1.20   * Permission to modify the code and to distribute modified code is granted,
    1.21   * provided the above notices are retained, and a notice that the code was
    1.22   * modified is included with the above copyright notice.
    1.23   *
    1.24 - */ 
    1.25 + */
    1.26  
    1.27  
    1.28  #ifndef _STLP_INTERNAL_OSTREAM_H
    1.29  #define _STLP_INTERNAL_OSTREAM_H
    1.30  
    1.31  #ifndef _STLP_INTERNAL_IOS_H
    1.32 -# include <stl/_ios.h>                  // For basic_ios<>.  Includes <iosfwd>.
    1.33 +#  include <stl/_ios.h>                  // For basic_ios<>.  Includes <iosfwd>.
    1.34  #endif
    1.35  
    1.36  #ifndef _STLP_INTERNAL_OSTREAMBUF_ITERATOR_H
    1.37 -# include <stl/_ostreambuf_iterator.h>
    1.38 +#  include <stl/_ostreambuf_iterator.h>
    1.39 +#endif
    1.40 +
    1.41 +#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT) && !defined (_STLP_INTERNAL_EXCEPTION)
    1.42 +#  include <stl/_exception.h>
    1.43  #endif
    1.44  
    1.45  _STLP_BEGIN_NAMESPACE
    1.46  
    1.47 -template <class _CharT, class _Traits, class _Number> 
    1.48 -basic_ostream<_CharT, _Traits>& _STLP_CALL
    1.49 -_M_put_num(basic_ostream<_CharT, _Traits>& __os, _Number __x);
    1.50 -
    1.51 -# if defined (_STLP_USE_TEMPLATE_EXPORT)
    1.52 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
    1.53  template <class _CharT, class _Traits>
    1.54  class _Osentry;
    1.55 -# endif
    1.56 +#endif
    1.57 +
    1.58 +_STLP_MOVE_TO_PRIV_NAMESPACE
    1.59  
    1.60  template <class _CharT, class _Traits>
    1.61 -bool
    1.62 -_M_init(basic_ostream<_CharT, _Traits>& __str);
    1.63 +bool __init_bostr(basic_ostream<_CharT, _Traits>& __str);
    1.64 +
    1.65 +_STLP_MOVE_TO_STD_NAMESPACE
    1.66  
    1.67  //----------------------------------------------------------------------
    1.68  // class basic_ostream<>
    1.69  
    1.70  template <class _CharT, class _Traits>
    1.71 -class basic_ostream : virtual public basic_ios<_CharT, _Traits>
    1.72 -{
    1.73 +class basic_ostream : virtual public basic_ios<_CharT, _Traits> {
    1.74    typedef basic_ostream<_CharT, _Traits> _Self;
    1.75 -  
    1.76 +
    1.77 +#if defined (_STLP_MSVC) && (_STLP_MSVC >= 1300 && _STLP_MSVC <= 1310)
    1.78 +  //explicitely defined as private to avoid warnings:
    1.79 +  basic_ostream(_Self const&);
    1.80 +  _Self& operator = (_Self const&);
    1.81 +#endif
    1.82 +
    1.83  public:                         // Types
    1.84    typedef _CharT                     char_type;
    1.85    typedef typename _Traits::int_type int_type;
    1.86 @@ -62,8 +68,8 @@
    1.87    typedef basic_ios<_CharT, _Traits> _Basic_ios;
    1.88  
    1.89  public:                         // Constructor and destructor.
    1.90 -  _STLP_DECLSPEC explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf);
    1.91 -  _STLP_DECLSPEC ~basic_ostream();
    1.92 +  explicit basic_ostream(basic_streambuf<_CharT, _Traits>* __buf);
    1.93 +  ~basic_ostream();
    1.94  
    1.95  public:                         // Hooks for manipulators.
    1.96    typedef basic_ios<_CharT, _Traits>& (_STLP_CALL *__ios_fn)(basic_ios<_CharT, _Traits>&);
    1.97 @@ -97,44 +103,31 @@
    1.98    // this is needed for compiling with option char = unsigned
    1.99    _Self& operator<<(unsigned char __x) { _M_put_char(__x); return *this; }
   1.100  # endif
   1.101 -#ifdef __SYMBIAN32__
   1.102 -  _Self& operator<<(short __x) 
   1.103 -    { 
   1.104 -	ios_base::fmtflags __fmtf =
   1.105 -		ios_base::flags() & ios_base::basefield;
   1.106 -    long __ly = (__fmtf == ios_base::oct ||  __fmtf == ios_base::hex) ? 
   1.107 -                    (long)(unsigned short)(__x) : (long)__x;
   1.108 -    return _M_put_num(*this,  __ly); 
   1.109 -    }
   1.110 -  _Self& operator<<(int __x) 
   1.111 -  { 
   1.112 -	ios_base::fmtflags __fmtf =
   1.113 -		ios_base::flags() & ios_base::basefield;
   1.114 -    long __ly = (__fmtf == ios_base::oct ||  __fmtf == ios_base::hex) ? 
   1.115 -                    (long)(unsigned int)(__x) : (long)__x;
   1.116 -    return _M_put_num(*this,  __ly); 
   1.117 -  }
   1.118 +  _Self& operator<<(short __x);
   1.119 +  _Self& operator<<(unsigned short __x);
   1.120 +  _Self& operator<<(int __x);
   1.121 +#if defined (_WIN64) || !defined (_STLP_MSVC) || (_STLP_MSVC < 1300)
   1.122 +  _Self& operator<<(unsigned int __x);
   1.123  #else
   1.124 -  _Self& operator<<(short __x) { return _M_put_num(*this,  __x); }
   1.125 -  _Self& operator<<(int __x) { return _M_put_num(*this,  __x); }
   1.126 +/* We define this operator with size_t rather than unsigned int to avoid
   1.127 + * 64 bits warning.
   1.128 + */
   1.129 +  _Self& operator<<(size_t __x);
   1.130  #endif
   1.131 -  _Self& operator<<(unsigned int __x) { return _M_put_num(*this,  __STATIC_CAST(unsigned long,__x)); }
   1.132 -  _Self& operator<<(unsigned short __x) { return _M_put_num(*this,  __STATIC_CAST(unsigned long,__x)); }
   1.133 -  _Self& operator<<(long __x) { return _M_put_num(*this,  __x); }
   1.134 -  _Self& operator<<(unsigned long __x) { return _M_put_num(*this,  __x); }
   1.135 +  _Self& operator<<(long __x);
   1.136 +  _Self& operator<<(unsigned long __x);
   1.137  #ifdef _STLP_LONG_LONG
   1.138 -  _Self& operator<< (_STLP_LONG_LONG __x)     { return _M_put_num(*this,  __x); }
   1.139 -  _Self& operator<< (unsigned _STLP_LONG_LONG __x) { return _M_put_num(*this,  __x); }
   1.140 -#endif 
   1.141 -  _Self& operator<<(float __x)
   1.142 -    { return _M_put_num(*this,  __STATIC_CAST(double,__x)); }
   1.143 -  _Self& operator<<(double __x) { return _M_put_num(*this,  __x); }
   1.144 +  _Self& operator<< (_STLP_LONG_LONG __x);
   1.145 +  _Self& operator<< (unsigned _STLP_LONG_LONG __x);
   1.146 +#endif
   1.147 +  _Self& operator<<(float __x);
   1.148 +  _Self& operator<<(double __x);
   1.149  # ifndef _STLP_NO_LONG_DOUBLE
   1.150 -  _Self& operator<<(long double __x) { return _M_put_num(*this,  __x); }
   1.151 +  _Self& operator<<(long double __x);
   1.152  # endif
   1.153 -  _Self& operator<<(const void* __x) { return _M_put_num(*this,  __x); }
   1.154 +  _Self& operator<<(const void* __x);
   1.155  # ifndef _STLP_NO_BOOL
   1.156 -  _Self& operator<<(bool __x) { return _M_put_num(*this,  __x); }
   1.157 +  _Self& operator<<(bool __x);
   1.158  # endif
   1.159  
   1.160  public:                         // Buffer positioning and manipulation.
   1.161 @@ -152,16 +145,17 @@
   1.162    }
   1.163  
   1.164    _Self& seekp(pos_type __pos) {
   1.165 -    if (this->rdbuf() && !this->fail())
   1.166 -      if( pos_type(off_type(-1)) == this->rdbuf()->pubseekpos(__pos, ios_base::out))
   1.167 +    if (this->rdbuf() && !this->fail()) {
   1.168 +      if (this->rdbuf()->pubseekpos(__pos) == pos_type(-1)) {
   1.169          this->setstate(ios_base::failbit);
   1.170 +      }
   1.171 +    }
   1.172      return *this;
   1.173    }
   1.174  
   1.175    _Self& seekp(off_type __off, ios_base::seekdir __dir) {
   1.176      if (this->rdbuf() && !this->fail())
   1.177 -      if( pos_type(off_type(-1)) == this->rdbuf()->pubseekoff(__off, __dir, ios_base::out))
   1.178 -        this->setstate(ios_base::failbit);
   1.179 +      this->rdbuf()->pubseekoff(__off, __dir);
   1.180      return *this;
   1.181    }
   1.182  
   1.183 @@ -174,61 +168,77 @@
   1.184    template <class _CharT, class _Traits>
   1.185    class _Osentry {
   1.186      typedef _Osentry<_CharT, _Traits> _Self;
   1.187 -# else
   1.188 +#else
   1.189      class sentry {
   1.190        typedef sentry _Self;
   1.191 -# endif
   1.192 +#endif
   1.193      private:
   1.194        basic_ostream<_CharT, _Traits>& _M_str;
   1.195        //      basic_streambuf<_CharT, _Traits>* _M_buf;
   1.196        bool _M_ok;
   1.197      public:
   1.198        explicit sentry(basic_ostream<_CharT, _Traits>& __str)
   1.199 -        : _M_str(__str), /* _M_buf(__str.rdbuf()), */ _M_ok(_M_init(__str))
   1.200 -      {
   1.201 -      }
   1.202 -      
   1.203 +        : _M_str(__str), /* _M_buf(__str.rdbuf()), */ _M_ok(_STLP_PRIV __init_bostr(__str))
   1.204 +      {}
   1.205 +
   1.206        ~sentry() {
   1.207          if (_M_str.flags() & ios_base::unitbuf)
   1.208 -# ifndef _STLP_INCOMPLETE_EXCEPTION_HEADER 
   1.209 -          if (!_STLP_VENDOR_EXCEPT_STD::uncaught_exception())
   1.210 -# endif
   1.211 +#if !defined (_STLP_NO_UNCAUGHT_EXCEPT_SUPPORT)
   1.212 +          if (!uncaught_exception())
   1.213 +#endif
   1.214              _M_str.flush();
   1.215        }
   1.216  
   1.217        operator bool() const { return _M_ok; }
   1.218      private:                        // Disable assignment and copy constructor.
   1.219 -      sentry(const _Self& __s) : _M_str (__s._M_str) {};
   1.220 -      void operator=(const _Self&) {};
   1.221 +      //Implementation is here only to avoid warning with some compilers.
   1.222 +      sentry(const _Self& __s) : _M_str(__s._M_str) {}
   1.223 +      _Self& operator=(const _Self&) { return *this; }
   1.224      };
   1.225 -# if defined (_STLP_USE_TEMPLATE_EXPORT)
   1.226 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
   1.227  #  undef sentry
   1.228 -# else
   1.229 -  // close basic_ostream class definition here    
   1.230 +#else
   1.231 +  // close basic_ostream class definition here
   1.232  };
   1.233 -# endif
   1.234 -  
   1.235 -# if defined (_STLP_USE_TEMPLATE_EXPORT)
   1.236 +#endif
   1.237 +
   1.238 +#if defined (_STLP_USE_TEMPLATE_EXPORT)
   1.239  _STLP_EXPORT_TEMPLATE_CLASS basic_ostream<char, char_traits<char> >;
   1.240  _STLP_EXPORT_TEMPLATE_CLASS _Osentry<char, char_traits<char> >;
   1.241  #  if !defined (_STLP_NO_WCHAR_T)
   1.242  _STLP_EXPORT_TEMPLATE_CLASS basic_ostream<wchar_t, char_traits<wchar_t> >;
   1.243  _STLP_EXPORT_TEMPLATE_CLASS _Osentry<wchar_t, char_traits<wchar_t> >;
   1.244  #  endif
   1.245 -# endif /* _STLP_USE_TEMPLATE_EXPORT */
   1.246 +#endif /* _STLP_USE_TEMPLATE_EXPORT */
   1.247 +
   1.248 +_STLP_MOVE_TO_PRIV_NAMESPACE
   1.249 +
   1.250 +// Helper functions for istream<>::sentry constructor.
   1.251 +template <class _CharT, class _Traits>
   1.252 +bool __init_bostr(basic_ostream<_CharT, _Traits>& __str) {
   1.253 +  if (__str.good()) {
   1.254 +    // boris : check if this is needed !
   1.255 +    if (!__str.rdbuf())
   1.256 +      __str.setstate(ios_base::badbit);
   1.257 +    if (__str.tie())
   1.258 +      __str.tie()->flush();
   1.259 +    return __str.good();
   1.260 +  }
   1.261 +  else
   1.262 +    return false;
   1.263 +}
   1.264  
   1.265  template <class _CharT, class _Traits>
   1.266 -inline basic_streambuf<_CharT, _Traits>* _STLP_CALL 
   1.267 -_M_get_ostreambuf(basic_ostream<_CharT, _Traits>& __St) 
   1.268 -{
   1.269 -  return __St.rdbuf();
   1.270 -}
   1.271 +inline basic_streambuf<_CharT, _Traits>* _STLP_CALL
   1.272 +__get_ostreambuf(basic_ostream<_CharT, _Traits>& __St)
   1.273 +{ return __St.rdbuf(); }
   1.274 +
   1.275 +_STLP_MOVE_TO_STD_NAMESPACE
   1.276  
   1.277  // Non-member functions.
   1.278 -
   1.279  template <class _CharT, class _Traits>
   1.280  inline basic_ostream<_CharT, _Traits>& _STLP_CALL
   1.281 -operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c) {
   1.282 +operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c){
   1.283    __os._M_put_char(__c);
   1.284    return __os;
   1.285  }
   1.286 @@ -236,15 +246,11 @@
   1.287  template <class _CharT, class _Traits>
   1.288  inline basic_ostream<_CharT, _Traits>& _STLP_CALL
   1.289  operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __s) {
   1.290 -#ifdef __SYMBIAN32__
   1.291 -  !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s);
   1.292 -#else
   1.293    __os._M_put_nowiden(__s);
   1.294 -#endif
   1.295    return __os;
   1.296  }
   1.297  
   1.298 -# ifdef _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER
   1.299 +#if defined (_STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER)
   1.300  // some specializations
   1.301  
   1.302  inline basic_ostream<char, char_traits<char> >& _STLP_CALL
   1.303 @@ -267,35 +273,23 @@
   1.304  
   1.305  inline basic_ostream<char, char_traits<char> >& _STLP_CALL
   1.306  operator<<(basic_ostream<char, char_traits<char> >& __os, const char* __s) {
   1.307 -#ifdef __SYMBIAN32__
   1.308 -  !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s);
   1.309 -#else
   1.310    __os._M_put_nowiden(__s);
   1.311 -#endif
   1.312    return __os;
   1.313  }
   1.314  
   1.315  inline basic_ostream<char, char_traits<char> >& _STLP_CALL
   1.316  operator<<(basic_ostream<char, char_traits<char> >& __os, const signed char* __s) {
   1.317 -#ifdef __SYMBIAN32__
   1.318 -   !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.319 -#else
   1.320 -   __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.321 -#endif
   1.322 +  __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.323    return __os;
   1.324  }
   1.325  
   1.326  inline basic_ostream<char, char_traits<char> >&
   1.327  operator<<(basic_ostream<char, char_traits<char> >& __os, const unsigned char* __s) {
   1.328 -#ifdef __SYMBIAN32__
   1.329 -  !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.330 -#else
   1.331    __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.332 -#endif
   1.333    return __os;
   1.334  }
   1.335  
   1.336 -# else
   1.337 +#else
   1.338  
   1.339  // also for compilers who might use that
   1.340  template <class _CharT, class _Traits>
   1.341 @@ -329,47 +323,31 @@
   1.342  template <class _CharT, class _Traits>
   1.343  inline basic_ostream<_CharT, _Traits>& _STLP_CALL
   1.344  operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __s) {
   1.345 -#ifdef __SYMBIAN32__
   1.346 -  !__s ? __os.setstate(ios_base::badbit):__os._M_put_widen(__s);
   1.347 -#else
   1.348    __os._M_put_widen(__s);
   1.349 -#endif
   1.350    return __os;
   1.351  }
   1.352  
   1.353  template <class _Traits>
   1.354  inline basic_ostream<char, _Traits>& _STLP_CALL
   1.355  operator<<(basic_ostream<char, _Traits>& __os, const char* __s) {
   1.356 -#ifdef __SYMBIAN32__
   1.357 -  !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__s);
   1.358 -#else
   1.359    __os._M_put_nowiden(__s);
   1.360 -#endif
   1.361    return __os;
   1.362  }
   1.363  
   1.364  template <class _Traits>
   1.365  inline basic_ostream<char, _Traits>& _STLP_CALL
   1.366  operator<<(basic_ostream<char, _Traits>& __os, const signed char* __s) {
   1.367 -#ifdef __SYMBIAN32__
   1.368 -  !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.369 -#else
   1.370    __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.371 -#endif
   1.372    return __os;
   1.373  }
   1.374  
   1.375  template <class _Traits>
   1.376  inline basic_ostream<char, _Traits>&
   1.377  operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __s) {
   1.378 -#ifdef __SYMBIAN32__
   1.379 -  !__s ? __os.setstate(ios_base::badbit):__os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.380 -#else
   1.381    __os._M_put_nowiden(__REINTERPRET_CAST(const char*,__s));
   1.382 -#endif
   1.383    return __os;
   1.384  }
   1.385 -# endif /* _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER */
   1.386 +#endif /* _STLP_NO_FUNCTION_TMPL_PARTIAL_ORDER */
   1.387  
   1.388  //----------------------------------------------------------------------
   1.389  // basic_ostream manipulators.
   1.390 @@ -398,11 +376,9 @@
   1.391  
   1.392  _STLP_END_NAMESPACE
   1.393  
   1.394 -#  undef _STLP_MANIP_INLINE
   1.395 -
   1.396  #if defined (_STLP_EXPOSE_STREAM_IMPLEMENTATION) && !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.397  #  include <stl/_ostream.c>
   1.398 -# endif
   1.399 +#endif
   1.400  
   1.401  #endif /* _STLP_INTERNAL_OSTREAM_H */
   1.402