epoc32/include/stdapis/stlportv5/stl/char_traits.h
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
     1.1 --- a/epoc32/include/stdapis/stlportv5/stl/char_traits.h	Wed Mar 31 12:27:01 2010 +0100
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/char_traits.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -21,86 +21,98 @@
     1.4  
     1.5  // Define char_traits
     1.6  
     1.7 -# if defined (_STLP_OWN_IOSTREAMS) || ! defined (_STLP_USE_NEW_IOSTREAMS)
     1.8 -
     1.9 -# if ! defined (_STLP_CSTDDEF)
    1.10 -#  include <cstddef>
    1.11 -# endif
    1.12 -
    1.13 -#if ! defined (_STLP_CSTRING)
    1.14 -#  include <cstring>
    1.15 +#ifndef _STLP_INTERNAL_CSTDDEF
    1.16 +#  include <stl/_cstddef.h>
    1.17  #endif
    1.18  
    1.19 -#if defined (_STLP_UNIX) && defined (_STLP_HAS_NO_NEW_C_HEADERS)
    1.20 -#include <sys/types.h>          // For off_t
    1.21 +#ifndef _STLP_INTERNAL_CSTRING
    1.22 +#  include <stl/_cstring.h>
    1.23 +#endif
    1.24 +
    1.25 +#if defined (__unix) || defined (N_PLAT_NLM)
    1.26 +#  include <sys/types.h>         // For off_t
    1.27  #endif /* __unix */
    1.28  
    1.29  #ifdef __BORLANDC__
    1.30 -# include <mem.h>
    1.31 -# include <string.h>
    1.32 -# include <_stddef.h>
    1.33 -// class mbstate_t;
    1.34 +#  include _STLP_NATIVE_C_HEADER(mem.h)
    1.35 +#  include _STLP_NATIVE_C_HEADER(string.h)
    1.36 +#  include _STLP_NATIVE_C_HEADER(_stddef.h)
    1.37  #endif
    1.38  
    1.39 -#ifndef __TYPE_TRAITS_H
    1.40 -# include <stl/type_traits.h>
    1.41 +#ifndef _STLP_INTERNAL_CONSTRUCT_H
    1.42 +#  include <stl/_construct.h>
    1.43  #endif
    1.44  
    1.45 -# if !defined (_STLP_CWCHAR)
    1.46 +#ifndef _STLP_INTERNAL_CWCHAR
    1.47  #  include <stl/_cwchar.h>
    1.48 -# endif
    1.49 +#endif
    1.50  
    1.51  _STLP_BEGIN_NAMESPACE
    1.52  
    1.53 -# ifdef _STLP_OWN_IOSTREAMS
    1.54 -
    1.55  template <class _Tp> class allocator;
    1.56  
    1.57  #define _STLP_NULL_CHAR_INIT(_ChT) _STLP_DEFAULT_CONSTRUCTED(_ChT)
    1.58  
    1.59  #if defined (__sgi) && defined (_STLP_HAS_NO_NEW_C_HEADERS) /* IRIX */
    1.60 -typedef off64_t   streamoff;
    1.61 -// #elif defined (__unix) && defined (_STLP_HAS_NO_NEW_C_HEADERS) /* Other version of UNIX */
    1.62 -// typedef off_t     streamoff;
    1.63 -#else /* __unix */
    1.64 -// boris : here, it's not ptrdiff_t as some Solaris systems have confusing definitions of these.
    1.65 +typedef off64_t streamoff;
    1.66 +#elif defined(_STLP_WCE)
    1.67  typedef long streamoff;
    1.68 -#endif /* _STLP_HAS_NO_NEW_C_HEADERS */
    1.69 +#elif defined (_STLP_WIN32)
    1.70 +#  if defined (_STLP_LONG_LONG) && !defined (__CYGWIN__)
    1.71 +//The Win32 file io API support 64 bits access so streamoff and streamsize
    1.72 +//has to reflect that. Do not change the stringbuf behavior.
    1.73 +typedef _STLP_LONG_LONG streamoff;
    1.74 +#  else
    1.75 +typedef ptrdiff_t streamoff;
    1.76 +#  endif
    1.77 +#else // __unix
    1.78 +#  ifdef _STLP_USE_DEFAULT_FILE_OFFSET
    1.79 +typedef off_t streamoff;
    1.80 +#  elif defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE) /* || defined(__USE_FILE_OFFSET64) */ \
    1.81 +       /* || (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */ /* || defined (__sgi) && defined (_STLP_HAS_NO_NEW_C_HEADERS) */
    1.82 +typedef off64_t streamoff;
    1.83 +#  else
    1.84 +typedef off_t streamoff;
    1.85 +#  endif
    1.86 +#endif /* ___unix */
    1.87  
    1.88 +#if defined (_STLP_WIN32)
    1.89 +typedef streamoff streamsize;
    1.90 +#else
    1.91  typedef ptrdiff_t streamsize;
    1.92 +#endif
    1.93  
    1.94  // Class fpos, which represents a position within a file.  (The C++
    1.95  // standard calls for it to be defined in <ios>.  This implementation
    1.96  // moves it to <iosfwd>, which is included by <ios>.)
    1.97 -template <class _StateT> class fpos
    1.98 -{
    1.99 +template <class _StateT> class fpos {
   1.100  public:                         // From table 88 of the C++ standard.
   1.101    fpos(streamoff __pos) : _M_pos(__pos), _M_st(_STLP_NULL_CHAR_INIT(_StateT)) {}
   1.102    fpos() : _M_pos(0), _M_st(_STLP_NULL_CHAR_INIT(_StateT)) {}
   1.103  
   1.104    operator streamoff() const { return _M_pos; }
   1.105  
   1.106 -  bool  _STLP_CALL operator==(const fpos<_StateT>& __y) const
   1.107 -    { return _M_pos == __y._M_pos; }
   1.108 -  bool _STLP_CALL operator!=(const fpos<_StateT>& __y) const
   1.109 -    { return _M_pos != __y._M_pos; }
   1.110 +  bool operator==(const fpos& __y) const
   1.111 +  { return _M_pos == __y._M_pos; }
   1.112 +  bool operator!=(const fpos& __y) const
   1.113 +  { return _M_pos != __y._M_pos; }
   1.114  
   1.115 -  fpos<_StateT>& operator+=(streamoff __off) {
   1.116 +  fpos& operator+=(streamoff __off) {
   1.117      _M_pos += __off;
   1.118      return *this;
   1.119    }
   1.120 -  fpos<_StateT>& operator-=(streamoff __off) {
   1.121 +  fpos& operator-=(streamoff __off) {
   1.122      _M_pos -= __off;
   1.123      return *this;
   1.124    }
   1.125  
   1.126 -  fpos<_StateT> operator+(streamoff __off) {
   1.127 -    fpos<_StateT> __tmp(*this);
   1.128 +  fpos operator+(streamoff __off) {
   1.129 +    fpos __tmp(*this);
   1.130      __tmp += __off;
   1.131      return __tmp;
   1.132    }
   1.133 -  fpos<_StateT> operator-(streamoff __off) {
   1.134 -    fpos<_StateT> __tmp(*this);
   1.135 +  fpos operator-(streamoff __off) {
   1.136 +    fpos __tmp(*this);
   1.137      __tmp -= __off;
   1.138      return __tmp;
   1.139    }
   1.140 @@ -113,90 +125,80 @@
   1.141    _StateT _M_st;
   1.142  };
   1.143  
   1.144 +#if !defined (_STLP_NO_MBSTATE_T)
   1.145  typedef fpos<mbstate_t> streampos;
   1.146  typedef fpos<mbstate_t> wstreampos;
   1.147 -# endif
   1.148 +#endif
   1.149  
   1.150  // Class __char_traits_base.
   1.151 -
   1.152 -template <class _CharT, class _IntT> class __char_traits_base {
   1.153 +template <class _CharT, class _IntT>
   1.154 +class __char_traits_base {
   1.155  public:
   1.156    typedef _CharT char_type;
   1.157    typedef _IntT int_type;
   1.158 -#ifdef _STLP_USE_NEW_IOSTREAMS
   1.159    typedef streamoff off_type;
   1.160    typedef streampos pos_type;
   1.161 -# ifdef _STLP_NO_MBSTATE_T
   1.162 +#if defined (_STLP_NO_MBSTATE_T)
   1.163    typedef char      state_type;
   1.164 -# else
   1.165 +#else
   1.166    typedef mbstate_t state_type;
   1.167 -# endif
   1.168 -#endif /* _STLP_USE_NEW_IOSTREAMS */
   1.169 +#endif
   1.170  
   1.171    static void _STLP_CALL assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; }
   1.172 -  static bool _STLP_CALL eq(const _CharT& __c1, const _CharT& __c2)
   1.173 -    { return __c1 == __c2; }
   1.174 -  static bool _STLP_CALL lt(const _CharT& __c1, const _CharT& __c2)
   1.175 -    { return __c1 < __c2; }
   1.176 +  static bool _STLP_CALL eq(const char_type& __c1, const char_type& __c2)
   1.177 +  { return __c1 == __c2; }
   1.178 +  static bool _STLP_CALL lt(const char_type& __c1, const char_type& __c2)
   1.179 +  { return __c1 < __c2; }
   1.180  
   1.181 -  static int _STLP_CALL compare(const _CharT* __s1, const _CharT* __s2, size_t __n) {
   1.182 +  static int _STLP_CALL compare(const char_type* __s1, const char_type* __s2, size_t __n) {
   1.183      for (size_t __i = 0; __i < __n; ++__i)
   1.184        if (!eq(__s1[__i], __s2[__i]))
   1.185          return __s1[__i] < __s2[__i] ? -1 : 1;
   1.186      return 0;
   1.187    }
   1.188  
   1.189 -  static size_t _STLP_CALL length(const _CharT* __s) {
   1.190 -    const _CharT _NullChar = _STLP_DEFAULT_CONSTRUCTED(_CharT);
   1.191 -    size_t __i;
   1.192 -    for (__i = 0; !eq(__s[__i], _NullChar); ++__i)
   1.193 -      {}
   1.194 +  static size_t _STLP_CALL length(const char_type* __s) {
   1.195 +    const char_type _NullChar = _STLP_DEFAULT_CONSTRUCTED(char_type);
   1.196 +    size_t __i(0);
   1.197 +    for (; !eq(__s[__i], _NullChar); ++__i) {}
   1.198      return __i;
   1.199    }
   1.200  
   1.201 -  static const _CharT* _STLP_CALL find(const _CharT* __s, size_t __n, const _CharT& __c) {
   1.202 +  static const char_type* _STLP_CALL find(const char_type* __s, size_t __n, const char_type& __c) {
   1.203      for ( ; __n > 0 ; ++__s, --__n)
   1.204        if (eq(*__s, __c))
   1.205          return __s;
   1.206      return 0;
   1.207    }
   1.208  
   1.209 +  static char_type* _STLP_CALL move(char_type* __s1, const char_type* __s2, size_t _Sz)
   1.210 +  { return (_Sz == 0 ? __s1 : (char_type*)memmove(__s1, __s2, _Sz * sizeof(char_type))); }
   1.211  
   1.212 -  static _CharT* _STLP_CALL move(_CharT* __s1, const _CharT* __s2, size_t _Sz) {
   1.213 -    return (_Sz == 0 ? __s1 : (_CharT*)memmove(__s1, __s2, _Sz * sizeof(_CharT)));
   1.214 +  static char_type* _STLP_CALL copy(char_type* __s1, const char_type* __s2, size_t __n) {
   1.215 +    return (__n == 0 ? __s1 :
   1.216 +      (char_type*)memcpy(__s1, __s2, __n * sizeof(char_type)));
   1.217    }
   1.218  
   1.219 -  static _CharT* _STLP_CALL copy(_CharT* __s1, const _CharT* __s2, size_t __n) {
   1.220 -    return (__n == 0 ? __s1 :
   1.221 -	    (_CharT*)memcpy(__s1, __s2, __n * sizeof(_CharT)));
   1.222 -    }
   1.223 -
   1.224 -  static _CharT* _STLP_CALL assign(_CharT* __s, size_t __n, _CharT __c) {
   1.225 +  static char_type* _STLP_CALL assign(char_type* __s, size_t __n, char_type __c) {
   1.226      for (size_t __i = 0; __i < __n; ++__i)
   1.227        __s[__i] = __c;
   1.228      return __s;
   1.229    }
   1.230  
   1.231 -  static int_type _STLP_CALL not_eof(const int_type& __c) {
   1.232 -    return !eq_int_type(__c, eof()) ? __c : __STATIC_CAST(int_type, 0);
   1.233 -  }
   1.234 +  static int_type _STLP_CALL not_eof(const int_type& __c)
   1.235 +  { return !eq_int_type(__c, eof()) ? __c : __STATIC_CAST(int_type, 0); }
   1.236  
   1.237 -  static char_type _STLP_CALL to_char_type(const int_type& __c) {
   1.238 -    return (char_type)__c;
   1.239 -  }
   1.240 +  static char_type _STLP_CALL to_char_type(const int_type& __c)
   1.241 +  { return (char_type)__c; }
   1.242  
   1.243 -  static int_type _STLP_CALL to_int_type(const char_type& __c) {
   1.244 -    return (int_type)__c;
   1.245 -  }
   1.246 +  static int_type _STLP_CALL to_int_type(const char_type& __c)
   1.247 +  { return (int_type)__c; }
   1.248  
   1.249 -  static bool _STLP_CALL eq_int_type(const int_type& __c1, const int_type& __c2) {
   1.250 -    return __c1 == __c2;
   1.251 -  }
   1.252 +  static bool _STLP_CALL eq_int_type(const int_type& __c1, const int_type& __c2)
   1.253 +  { return __c1 == __c2; }
   1.254  
   1.255 -  static int_type _STLP_CALL eof() {
   1.256 -    return (int_type)-1;
   1.257 -    //    return __STATIC_CAST(int_type,-1);
   1.258 -  }
   1.259 +  static int_type _STLP_CALL eof()
   1.260 +  { return (int_type)-1; }
   1.261  };
   1.262  
   1.263  // Generic char_traits class.  Note that this class is provided only
   1.264 @@ -204,63 +206,83 @@
   1.265  //  as is for any particular user-defined type.  In particular, it
   1.266  //  *will not work* for a non-POD type.
   1.267  
   1.268 -template <class _CharT> class char_traits
   1.269 -  : public __char_traits_base<_CharT, _CharT>
   1.270 -{};
   1.271 +template <class _CharT>
   1.272 +class char_traits
   1.273 +  : public __char_traits_base<_CharT, _CharT> {};
   1.274  
   1.275  // Specialization for char.
   1.276  
   1.277 -_STLP_TEMPLATE_NULL class _STLP_CLASS_DECLSPEC char_traits<char>
   1.278 -  : public __char_traits_base<char, int>
   1.279 -{
   1.280 +_STLP_TEMPLATE_NULL
   1.281 +class _STLP_CLASS_DECLSPEC char_traits<char>
   1.282 +  : public __char_traits_base<char, int> {
   1.283  public:
   1.284    typedef char char_type;
   1.285    typedef int int_type;
   1.286 -#ifdef _STLP_USE_NEW_IOSTREAMS
   1.287    typedef streamoff off_type;
   1.288 -# ifndef _STLP_NO_MBSTATE_T
   1.289 +#if !defined (_STLP_NO_MBSTATE_T)
   1.290    typedef streampos pos_type;
   1.291    typedef mbstate_t state_type;
   1.292 -# endif
   1.293 -#endif /* _STLP_USE_NEW_IOSTREAMS */
   1.294 +#endif
   1.295  
   1.296 -  static char _STLP_CALL to_char_type(const int& __c) {
   1.297 -    return (char)(unsigned char)__c;
   1.298 -  }
   1.299 +  static char _STLP_CALL to_char_type(const int& __c)
   1.300 +  { return (char)(unsigned char)__c; }
   1.301  
   1.302 -  static int _STLP_CALL to_int_type(const char& __c) {
   1.303 -    return (unsigned char)__c;
   1.304 -  }
   1.305 +  static int _STLP_CALL to_int_type(const char& __c)
   1.306 +  { return (unsigned char)__c; }
   1.307  
   1.308    static int _STLP_CALL compare(const char* __s1, const char* __s2, size_t __n)
   1.309 -    { return memcmp(__s1, __s2, __n); }
   1.310 +  { return memcmp(__s1, __s2, __n); }
   1.311  
   1.312 -  static size_t _STLP_CALL length(const char* __s) { return strlen(__s); }
   1.313 +  static size_t _STLP_CALL length(const char* __s)
   1.314 +  { return strlen(__s); }
   1.315  
   1.316 -  static void _STLP_CALL assign(char& __c1, const char& __c2) { __c1 = __c2; }
   1.317 +  static void _STLP_CALL assign(char& __c1, const char& __c2)
   1.318 +  { __c1 = __c2; }
   1.319  
   1.320 -  static char* _STLP_CALL assign(char* __s, size_t __n, char __c)
   1.321 -    { memset(__s, __c, __n); return __s; }
   1.322 +  static char* _STLP_CALL assign(char* __s, size_t __n, char __c) {
   1.323 +    memset(__s, __c, __n);
   1.324 +    return __s;
   1.325 +  }
   1.326  };
   1.327  
   1.328 -# if defined (_STLP_HAS_WCHAR_T)
   1.329 +#if defined (_STLP_HAS_WCHAR_T)
   1.330  // Specialization for wchar_t.
   1.331 -_STLP_TEMPLATE_NULL class _STLP_CLASS_DECLSPEC char_traits<wchar_t>
   1.332 -  : public __char_traits_base<wchar_t, wint_t>
   1.333 -{};
   1.334 -# endif
   1.335 +_STLP_TEMPLATE_NULL
   1.336 +class _STLP_CLASS_DECLSPEC char_traits<wchar_t>
   1.337 +  : public __char_traits_base<wchar_t, wint_t> {
   1.338 +#  if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && !defined (_STLP_WCHAR_HPACC_EXCLUDE)
   1.339 +public:
   1.340 +#    if !defined (N_PLAT_NLM)
   1.341 +#      if !defined (__BORLANDC__)
   1.342 +  static wchar_t* _STLP_CALL move(wchar_t* __dest, const wchar_t* __src, size_t __n)
   1.343 +  { return wmemmove(__dest, __src, __n); }
   1.344 +#      endif
   1.345 +
   1.346 +  static wchar_t* _STLP_CALL copy(wchar_t* __dest, const wchar_t* __src, size_t __n)
   1.347 +  { return wmemcpy(__dest, __src, __n); }
   1.348 +
   1.349 +#      if !defined (__DMC__) && !defined (__BORLANDC__)
   1.350 +  static int _STLP_CALL compare(const wchar_t* __s1, const wchar_t* __s2, size_t __n)
   1.351 +  { return wmemcmp(__s1, __s2, __n); }
   1.352 +#      endif
   1.353 +
   1.354 +  static wchar_t* _STLP_CALL assign(wchar_t* __s, size_t __n, wchar_t __c)
   1.355 +  { return wmemset(__s, __c, __n); }
   1.356 +#    endif
   1.357 +
   1.358 +  static size_t _STLP_CALL length(const wchar_t* __s)
   1.359 +  { return wcslen(__s); }
   1.360 +
   1.361 +  static void _STLP_CALL assign(wchar_t& __c1, const wchar_t& __c2)
   1.362 +  { __c1 = __c2; }
   1.363 +#  endif
   1.364 +};
   1.365 +#endif
   1.366  
   1.367  _STLP_END_NAMESPACE
   1.368  
   1.369 -# else /* OWN_IOSTREAMS */
   1.370 -
   1.371 -#  include <wrap_std/iosfwd>
   1.372 -
   1.373 -# endif /* OWN_IOSTREAMS */
   1.374 -
   1.375  #endif /* _STLP_CHAR_TRAITS_H */
   1.376  
   1.377  // Local Variables:
   1.378  // mode:C++
   1.379  // End:
   1.380 -