diff -r e1b950c65cb4 -r 837f303aceeb epoc32/include/stdapis/stlportv5/stl/char_traits.h --- a/epoc32/include/stdapis/stlportv5/stl/char_traits.h Wed Mar 31 12:27:01 2010 +0100 +++ b/epoc32/include/stdapis/stlportv5/stl/char_traits.h Wed Mar 31 12:33:34 2010 +0100 @@ -21,86 +21,98 @@ // Define char_traits -# if defined (_STLP_OWN_IOSTREAMS) || ! defined (_STLP_USE_NEW_IOSTREAMS) - -# if ! defined (_STLP_CSTDDEF) -# include -# endif - -#if ! defined (_STLP_CSTRING) -# include +#ifndef _STLP_INTERNAL_CSTDDEF +# include #endif -#if defined (_STLP_UNIX) && defined (_STLP_HAS_NO_NEW_C_HEADERS) -#include // For off_t +#ifndef _STLP_INTERNAL_CSTRING +# include +#endif + +#if defined (__unix) || defined (N_PLAT_NLM) +# include // For off_t #endif /* __unix */ #ifdef __BORLANDC__ -# include -# include -# include <_stddef.h> -// class mbstate_t; +# include _STLP_NATIVE_C_HEADER(mem.h) +# include _STLP_NATIVE_C_HEADER(string.h) +# include _STLP_NATIVE_C_HEADER(_stddef.h) #endif -#ifndef __TYPE_TRAITS_H -# include +#ifndef _STLP_INTERNAL_CONSTRUCT_H +# include #endif -# if !defined (_STLP_CWCHAR) +#ifndef _STLP_INTERNAL_CWCHAR # include -# endif +#endif _STLP_BEGIN_NAMESPACE -# ifdef _STLP_OWN_IOSTREAMS - template class allocator; #define _STLP_NULL_CHAR_INIT(_ChT) _STLP_DEFAULT_CONSTRUCTED(_ChT) #if defined (__sgi) && defined (_STLP_HAS_NO_NEW_C_HEADERS) /* IRIX */ -typedef off64_t streamoff; -// #elif defined (__unix) && defined (_STLP_HAS_NO_NEW_C_HEADERS) /* Other version of UNIX */ -// typedef off_t streamoff; -#else /* __unix */ -// boris : here, it's not ptrdiff_t as some Solaris systems have confusing definitions of these. +typedef off64_t streamoff; +#elif defined(_STLP_WCE) typedef long streamoff; -#endif /* _STLP_HAS_NO_NEW_C_HEADERS */ +#elif defined (_STLP_WIN32) +# if defined (_STLP_LONG_LONG) && !defined (__CYGWIN__) +//The Win32 file io API support 64 bits access so streamoff and streamsize +//has to reflect that. Do not change the stringbuf behavior. +typedef _STLP_LONG_LONG streamoff; +# else +typedef ptrdiff_t streamoff; +# endif +#else // __unix +# ifdef _STLP_USE_DEFAULT_FILE_OFFSET +typedef off_t streamoff; +# elif defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE) /* || defined(__USE_FILE_OFFSET64) */ \ + /* || (defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)) */ /* || defined (__sgi) && defined (_STLP_HAS_NO_NEW_C_HEADERS) */ +typedef off64_t streamoff; +# else +typedef off_t streamoff; +# endif +#endif /* ___unix */ +#if defined (_STLP_WIN32) +typedef streamoff streamsize; +#else typedef ptrdiff_t streamsize; +#endif // Class fpos, which represents a position within a file. (The C++ // standard calls for it to be defined in . This implementation // moves it to , which is included by .) -template class fpos -{ +template class fpos { public: // From table 88 of the C++ standard. fpos(streamoff __pos) : _M_pos(__pos), _M_st(_STLP_NULL_CHAR_INIT(_StateT)) {} fpos() : _M_pos(0), _M_st(_STLP_NULL_CHAR_INIT(_StateT)) {} operator streamoff() const { return _M_pos; } - bool _STLP_CALL operator==(const fpos<_StateT>& __y) const - { return _M_pos == __y._M_pos; } - bool _STLP_CALL operator!=(const fpos<_StateT>& __y) const - { return _M_pos != __y._M_pos; } + bool operator==(const fpos& __y) const + { return _M_pos == __y._M_pos; } + bool operator!=(const fpos& __y) const + { return _M_pos != __y._M_pos; } - fpos<_StateT>& operator+=(streamoff __off) { + fpos& operator+=(streamoff __off) { _M_pos += __off; return *this; } - fpos<_StateT>& operator-=(streamoff __off) { + fpos& operator-=(streamoff __off) { _M_pos -= __off; return *this; } - fpos<_StateT> operator+(streamoff __off) { - fpos<_StateT> __tmp(*this); + fpos operator+(streamoff __off) { + fpos __tmp(*this); __tmp += __off; return __tmp; } - fpos<_StateT> operator-(streamoff __off) { - fpos<_StateT> __tmp(*this); + fpos operator-(streamoff __off) { + fpos __tmp(*this); __tmp -= __off; return __tmp; } @@ -113,90 +125,80 @@ _StateT _M_st; }; +#if !defined (_STLP_NO_MBSTATE_T) typedef fpos streampos; typedef fpos wstreampos; -# endif +#endif // Class __char_traits_base. - -template class __char_traits_base { +template +class __char_traits_base { public: typedef _CharT char_type; typedef _IntT int_type; -#ifdef _STLP_USE_NEW_IOSTREAMS typedef streamoff off_type; typedef streampos pos_type; -# ifdef _STLP_NO_MBSTATE_T +#if defined (_STLP_NO_MBSTATE_T) typedef char state_type; -# else +#else typedef mbstate_t state_type; -# endif -#endif /* _STLP_USE_NEW_IOSTREAMS */ +#endif static void _STLP_CALL assign(char_type& __c1, const char_type& __c2) { __c1 = __c2; } - static bool _STLP_CALL eq(const _CharT& __c1, const _CharT& __c2) - { return __c1 == __c2; } - static bool _STLP_CALL lt(const _CharT& __c1, const _CharT& __c2) - { return __c1 < __c2; } + static bool _STLP_CALL eq(const char_type& __c1, const char_type& __c2) + { return __c1 == __c2; } + static bool _STLP_CALL lt(const char_type& __c1, const char_type& __c2) + { return __c1 < __c2; } - static int _STLP_CALL compare(const _CharT* __s1, const _CharT* __s2, size_t __n) { + static int _STLP_CALL compare(const char_type* __s1, const char_type* __s2, size_t __n) { for (size_t __i = 0; __i < __n; ++__i) if (!eq(__s1[__i], __s2[__i])) return __s1[__i] < __s2[__i] ? -1 : 1; return 0; } - static size_t _STLP_CALL length(const _CharT* __s) { - const _CharT _NullChar = _STLP_DEFAULT_CONSTRUCTED(_CharT); - size_t __i; - for (__i = 0; !eq(__s[__i], _NullChar); ++__i) - {} + static size_t _STLP_CALL length(const char_type* __s) { + const char_type _NullChar = _STLP_DEFAULT_CONSTRUCTED(char_type); + size_t __i(0); + for (; !eq(__s[__i], _NullChar); ++__i) {} return __i; } - static const _CharT* _STLP_CALL find(const _CharT* __s, size_t __n, const _CharT& __c) { + static const char_type* _STLP_CALL find(const char_type* __s, size_t __n, const char_type& __c) { for ( ; __n > 0 ; ++__s, --__n) if (eq(*__s, __c)) return __s; return 0; } + static char_type* _STLP_CALL move(char_type* __s1, const char_type* __s2, size_t _Sz) + { return (_Sz == 0 ? __s1 : (char_type*)memmove(__s1, __s2, _Sz * sizeof(char_type))); } - static _CharT* _STLP_CALL move(_CharT* __s1, const _CharT* __s2, size_t _Sz) { - return (_Sz == 0 ? __s1 : (_CharT*)memmove(__s1, __s2, _Sz * sizeof(_CharT))); + static char_type* _STLP_CALL copy(char_type* __s1, const char_type* __s2, size_t __n) { + return (__n == 0 ? __s1 : + (char_type*)memcpy(__s1, __s2, __n * sizeof(char_type))); } - static _CharT* _STLP_CALL copy(_CharT* __s1, const _CharT* __s2, size_t __n) { - return (__n == 0 ? __s1 : - (_CharT*)memcpy(__s1, __s2, __n * sizeof(_CharT))); - } - - static _CharT* _STLP_CALL assign(_CharT* __s, size_t __n, _CharT __c) { + static char_type* _STLP_CALL assign(char_type* __s, size_t __n, char_type __c) { for (size_t __i = 0; __i < __n; ++__i) __s[__i] = __c; return __s; } - static int_type _STLP_CALL not_eof(const int_type& __c) { - return !eq_int_type(__c, eof()) ? __c : __STATIC_CAST(int_type, 0); - } + static int_type _STLP_CALL not_eof(const int_type& __c) + { return !eq_int_type(__c, eof()) ? __c : __STATIC_CAST(int_type, 0); } - static char_type _STLP_CALL to_char_type(const int_type& __c) { - return (char_type)__c; - } + static char_type _STLP_CALL to_char_type(const int_type& __c) + { return (char_type)__c; } - static int_type _STLP_CALL to_int_type(const char_type& __c) { - return (int_type)__c; - } + static int_type _STLP_CALL to_int_type(const char_type& __c) + { return (int_type)__c; } - static bool _STLP_CALL eq_int_type(const int_type& __c1, const int_type& __c2) { - return __c1 == __c2; - } + static bool _STLP_CALL eq_int_type(const int_type& __c1, const int_type& __c2) + { return __c1 == __c2; } - static int_type _STLP_CALL eof() { - return (int_type)-1; - // return __STATIC_CAST(int_type,-1); - } + static int_type _STLP_CALL eof() + { return (int_type)-1; } }; // Generic char_traits class. Note that this class is provided only @@ -204,63 +206,83 @@ // as is for any particular user-defined type. In particular, it // *will not work* for a non-POD type. -template class char_traits - : public __char_traits_base<_CharT, _CharT> -{}; +template +class char_traits + : public __char_traits_base<_CharT, _CharT> {}; // Specialization for char. -_STLP_TEMPLATE_NULL class _STLP_CLASS_DECLSPEC char_traits - : public __char_traits_base -{ +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC char_traits + : public __char_traits_base { public: typedef char char_type; typedef int int_type; -#ifdef _STLP_USE_NEW_IOSTREAMS typedef streamoff off_type; -# ifndef _STLP_NO_MBSTATE_T +#if !defined (_STLP_NO_MBSTATE_T) typedef streampos pos_type; typedef mbstate_t state_type; -# endif -#endif /* _STLP_USE_NEW_IOSTREAMS */ +#endif - static char _STLP_CALL to_char_type(const int& __c) { - return (char)(unsigned char)__c; - } + static char _STLP_CALL to_char_type(const int& __c) + { return (char)(unsigned char)__c; } - static int _STLP_CALL to_int_type(const char& __c) { - return (unsigned char)__c; - } + static int _STLP_CALL to_int_type(const char& __c) + { return (unsigned char)__c; } static int _STLP_CALL compare(const char* __s1, const char* __s2, size_t __n) - { return memcmp(__s1, __s2, __n); } + { return memcmp(__s1, __s2, __n); } - static size_t _STLP_CALL length(const char* __s) { return strlen(__s); } + static size_t _STLP_CALL length(const char* __s) + { return strlen(__s); } - static void _STLP_CALL assign(char& __c1, const char& __c2) { __c1 = __c2; } + static void _STLP_CALL assign(char& __c1, const char& __c2) + { __c1 = __c2; } - static char* _STLP_CALL assign(char* __s, size_t __n, char __c) - { memset(__s, __c, __n); return __s; } + static char* _STLP_CALL assign(char* __s, size_t __n, char __c) { + memset(__s, __c, __n); + return __s; + } }; -# if defined (_STLP_HAS_WCHAR_T) +#if defined (_STLP_HAS_WCHAR_T) // Specialization for wchar_t. -_STLP_TEMPLATE_NULL class _STLP_CLASS_DECLSPEC char_traits - : public __char_traits_base -{}; -# endif +_STLP_TEMPLATE_NULL +class _STLP_CLASS_DECLSPEC char_traits + : public __char_traits_base { +# if !defined (_STLP_NO_NATIVE_WIDE_FUNCTIONS) && !defined (_STLP_WCHAR_HPACC_EXCLUDE) +public: +# if !defined (N_PLAT_NLM) +# if !defined (__BORLANDC__) + static wchar_t* _STLP_CALL move(wchar_t* __dest, const wchar_t* __src, size_t __n) + { return wmemmove(__dest, __src, __n); } +# endif + + static wchar_t* _STLP_CALL copy(wchar_t* __dest, const wchar_t* __src, size_t __n) + { return wmemcpy(__dest, __src, __n); } + +# if !defined (__DMC__) && !defined (__BORLANDC__) + static int _STLP_CALL compare(const wchar_t* __s1, const wchar_t* __s2, size_t __n) + { return wmemcmp(__s1, __s2, __n); } +# endif + + static wchar_t* _STLP_CALL assign(wchar_t* __s, size_t __n, wchar_t __c) + { return wmemset(__s, __c, __n); } +# endif + + static size_t _STLP_CALL length(const wchar_t* __s) + { return wcslen(__s); } + + static void _STLP_CALL assign(wchar_t& __c1, const wchar_t& __c2) + { __c1 = __c2; } +# endif +}; +#endif _STLP_END_NAMESPACE -# else /* OWN_IOSTREAMS */ - -# include - -# endif /* OWN_IOSTREAMS */ - #endif /* _STLP_CHAR_TRAITS_H */ // Local Variables: // mode:C++ // End: -