epoc32/include/tools/stlport/stl/_string_base.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- a/epoc32/include/tools/stlport/stl/_string_base.h	Tue Mar 16 16:12:26 2010 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,249 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 1997-1999
     1.6 - * Silicon Graphics Computer Systems, Inc.
     1.7 - *
     1.8 - * Copyright (c) 1999
     1.9 - * Boris Fomitchev
    1.10 - *
    1.11 - * Copyright (c) 2003
    1.12 - * Francois Dumont
    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 - * without fee, provided the above notices are retained on all copies.
    1.19 - * Permission to modify the code and to distribute modified code is granted,
    1.20 - * provided the above notices are retained, and a notice that the code was
    1.21 - * modified is included with the above copyright notice.
    1.22 - *
    1.23 - */
    1.24 -
    1.25 -#ifndef _STLP_STRING_BASE_H
    1.26 -#define _STLP_STRING_BASE_H
    1.27 -
    1.28 -// ------------------------------------------------------------
    1.29 -// Class _String_base.
    1.30 -
    1.31 -// _String_base is a helper class that makes it it easier to write an
    1.32 -// exception-safe version of basic_string.  The constructor allocates,
    1.33 -// but does not initialize, a block of memory.  The destructor
    1.34 -// deallocates, but does not destroy elements within, a block of
    1.35 -// memory.  The destructor assumes that _M_start either is null, or else
    1.36 -// points to a block of memory that was allocated using _String_base's
    1.37 -// allocator and whose size is _M_end_of_storage._M_data - _M_start.
    1.38 -
    1.39 -_STLP_BEGIN_NAMESPACE
    1.40 -
    1.41 -_STLP_MOVE_TO_PRIV_NAMESPACE
    1.42 -
    1.43 -#ifndef _STLP_SHORT_STRING_SZ
    1.44 -#  define _STLP_SHORT_STRING_SZ 16
    1.45 -#endif
    1.46 -
    1.47 -template <class _Tp, class _Alloc>
    1.48 -class _String_base {
    1.49 -  typedef _String_base<_Tp, _Alloc> _Self;
    1.50 -protected:
    1.51 -  _STLP_FORCE_ALLOCATORS(_Tp, _Alloc)
    1.52 -public:
    1.53 -  //dums: Some compiler(MSVC6) require it to be public not simply protected!
    1.54 -  enum {_DEFAULT_SIZE = _STLP_SHORT_STRING_SZ};
    1.55 -  //This is needed by the full move framework
    1.56 -  typedef typename _Alloc_traits<_Tp, _Alloc>::allocator_type allocator_type;
    1.57 -  typedef _STLP_alloc_proxy<_Tp*, _Tp, allocator_type> _AllocProxy;
    1.58 -  typedef size_t size_type;
    1.59 -private:
    1.60 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
    1.61 -  union _Buffers {
    1.62 -    _Tp*  _M_dynamic_buf;
    1.63 -    _Tp   _M_static_buf[_DEFAULT_SIZE];
    1.64 -  } _M_buffers;
    1.65 -#else
    1.66 -  _Tp*    _M_start;
    1.67 -#endif /* _STLP_USE_SHORT_STRING_OPTIM */
    1.68 -protected:
    1.69 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
    1.70 -  bool _M_using_static_buf() const {
    1.71 -    return (_M_end_of_storage._M_data == _M_buffers._M_static_buf + _DEFAULT_SIZE);
    1.72 -  }
    1.73 -  _Tp const* _M_Start() const {
    1.74 -    return _M_using_static_buf()?_M_buffers._M_static_buf:_M_buffers._M_dynamic_buf;
    1.75 -  }
    1.76 -  _Tp* _M_Start() {
    1.77 -    return _M_using_static_buf()?_M_buffers._M_static_buf:_M_buffers._M_dynamic_buf;
    1.78 -  }
    1.79 -#else
    1.80 -  _Tp const* _M_Start() const {return _M_start;}
    1.81 -  _Tp* _M_Start() {return _M_start;}
    1.82 -#endif /* _STLP_USE_SHORT_STRING_OPTIM */
    1.83 -
    1.84 -  _Tp*    _M_finish;
    1.85 -  _AllocProxy _M_end_of_storage;
    1.86 -
    1.87 -  _Tp const* _M_Finish() const {return _M_finish;}
    1.88 -  _Tp* _M_Finish() {return _M_finish;}
    1.89 -
    1.90 -  // Precondition: 0 < __n <= max_size().
    1.91 -  void _M_allocate_block(size_t __n = _DEFAULT_SIZE);
    1.92 -  void _M_deallocate_block() {
    1.93 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
    1.94 -    if (!_M_using_static_buf() && (_M_buffers._M_dynamic_buf != 0))
    1.95 -      _M_end_of_storage.deallocate(_M_buffers._M_dynamic_buf, _M_end_of_storage._M_data - _M_buffers._M_dynamic_buf);
    1.96 -#else
    1.97 -    if (_M_start != 0)
    1.98 -      _M_end_of_storage.deallocate(_M_start, _M_end_of_storage._M_data - _M_start);
    1.99 -#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.100 -  }
   1.101 -
   1.102 -  size_t max_size() const {
   1.103 -    const size_type __string_max_size = size_type(-1) / sizeof(_Tp);
   1.104 -    typename allocator_type::size_type __alloc_max_size = _M_end_of_storage.max_size();
   1.105 -    return (min)(__alloc_max_size, __string_max_size) - 1;
   1.106 -  }
   1.107 -
   1.108 -  _String_base(const allocator_type& __a)
   1.109 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.110 -    : _M_finish(_M_buffers._M_static_buf), _M_end_of_storage(__a, _M_buffers._M_static_buf + _DEFAULT_SIZE)
   1.111 -#else
   1.112 -    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, (_Tp*)0)
   1.113 -#endif
   1.114 -    {}
   1.115 -
   1.116 -  _String_base(const allocator_type& __a, size_t __n)
   1.117 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.118 -    : _M_finish(_M_buffers._M_static_buf), _M_end_of_storage(__a, _M_buffers._M_static_buf + _DEFAULT_SIZE) {
   1.119 -#else
   1.120 -    : _M_start(0), _M_finish(0), _M_end_of_storage(__a, (_Tp*)0) {
   1.121 -#endif
   1.122 -      _M_allocate_block(__n);
   1.123 -    }
   1.124 -
   1.125 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.126 -  void _M_move_src (_Self &src) {
   1.127 -      if (src._M_using_static_buf()) {
   1.128 -        _M_buffers = src._M_buffers;
   1.129 -        _M_finish = _M_buffers._M_static_buf + (src._M_finish - src._M_buffers._M_static_buf);
   1.130 -        _M_end_of_storage._M_data = _M_buffers._M_static_buf + _DEFAULT_SIZE;
   1.131 -      }
   1.132 -      else {
   1.133 -        _M_buffers._M_dynamic_buf = src._M_buffers._M_dynamic_buf;
   1.134 -        _M_finish = src._M_finish;
   1.135 -        _M_end_of_storage._M_data = src._M_end_of_storage._M_data;
   1.136 -        src._M_buffers._M_dynamic_buf = 0;
   1.137 -      }
   1.138 -    }
   1.139 -#endif
   1.140 -
   1.141 -  _String_base(__move_source<_Self> src)
   1.142 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.143 -    : _M_end_of_storage(__move_source<_AllocProxy>(src.get()._M_end_of_storage)) {
   1.144 -      _M_move_src(src.get());
   1.145 -#else
   1.146 -    : _M_start(src.get()._M_start), _M_finish(src.get()._M_finish),
   1.147 -      _M_end_of_storage(__move_source<_AllocProxy>(src.get()._M_end_of_storage)) {
   1.148 -      src.get()._M_start = 0;
   1.149 -#endif
   1.150 -    }
   1.151 -
   1.152 -  ~_String_base() { _M_deallocate_block(); }
   1.153 -
   1.154 -  void _M_reset(_Tp *__start, _Tp *__finish, _Tp *__end_of_storage) {
   1.155 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.156 -    _M_buffers._M_dynamic_buf = __start;
   1.157 -#else
   1.158 -    _M_start = __start;
   1.159 -#endif
   1.160 -    _M_finish = __finish;
   1.161 -    _M_end_of_storage._M_data = __end_of_storage;
   1.162 -  }
   1.163 -
   1.164 -  void _M_destroy_back () {
   1.165 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.166 -    if (!_M_using_static_buf())
   1.167 -#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.168 -      _STLP_STD::_Destroy(_M_finish);
   1.169 -  }
   1.170 -
   1.171 -  void _M_destroy_range(size_t __from_off = 0, size_t __to_off = 1) {
   1.172 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.173 -    if (!_M_using_static_buf())
   1.174 -      _STLP_STD::_Destroy_Range(_M_buffers._M_dynamic_buf + __from_off, _M_finish + __to_off);
   1.175 -#else
   1.176 -    _STLP_STD::_Destroy_Range(_M_start + __from_off, _M_finish + __to_off);
   1.177 -#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.178 -  }
   1.179 -
   1.180 -  void _M_destroy_ptr_range(_Tp *__f, _Tp *__l) {
   1.181 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.182 -    if (!_M_using_static_buf())
   1.183 -#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.184 -      _STLP_STD::_Destroy_Range(__f, __l);
   1.185 -  }
   1.186 -
   1.187 -  void _M_Swap(_Self &__s) {
   1.188 -#if defined (_STLP_USE_SHORT_STRING_OPTIM)
   1.189 -    if (_M_using_static_buf()) {
   1.190 -      if (__s._M_using_static_buf()) {
   1.191 -        _STLP_STD::swap(_M_buffers, __s._M_buffers);
   1.192 -        _Tp *__tmp = _M_finish;
   1.193 -        _M_finish = _M_buffers._M_static_buf + (__s._M_finish - __s._M_buffers._M_static_buf);
   1.194 -        __s._M_finish = __s._M_buffers._M_static_buf + (__tmp - _M_buffers._M_static_buf);
   1.195 -        //We need to swap _M_end_of_storage for allocators with state:
   1.196 -        _M_end_of_storage.swap(__s._M_end_of_storage);
   1.197 -        _M_end_of_storage._M_data = _M_buffers._M_static_buf + _DEFAULT_SIZE;
   1.198 -        __s._M_end_of_storage._M_data = __s._M_buffers._M_static_buf + _DEFAULT_SIZE;
   1.199 -      } else {
   1.200 -        __s._M_Swap(*this);
   1.201 -        return;
   1.202 -      }
   1.203 -    }
   1.204 -    else if (__s._M_using_static_buf()) {
   1.205 -      _Tp *__tmp = _M_buffers._M_dynamic_buf;
   1.206 -      _Tp *__tmp_finish = _M_finish;
   1.207 -      _Tp *__tmp_end_data = _M_end_of_storage._M_data;
   1.208 -      _M_buffers = __s._M_buffers;
   1.209 -      //We need to swap _M_end_of_storage for allocators with state:
   1.210 -      _M_end_of_storage.swap(__s._M_end_of_storage);
   1.211 -      _M_end_of_storage._M_data = _M_buffers._M_static_buf + _DEFAULT_SIZE;
   1.212 -      _M_finish = _M_buffers._M_static_buf + (__s._M_finish - __s._M_buffers._M_static_buf);
   1.213 -      __s._M_buffers._M_dynamic_buf = __tmp;
   1.214 -      __s._M_end_of_storage._M_data = __tmp_end_data;
   1.215 -      __s._M_finish = __tmp_finish;
   1.216 -    }
   1.217 -    else {
   1.218 -      _STLP_STD::swap(_M_buffers._M_dynamic_buf, __s._M_buffers._M_dynamic_buf);
   1.219 -      _M_end_of_storage.swap(__s._M_end_of_storage);
   1.220 -      _STLP_STD::swap(_M_finish, __s._M_finish);
   1.221 -    }
   1.222 -#else
   1.223 -    _STLP_STD::swap(_M_start, __s._M_start);
   1.224 -    _M_end_of_storage.swap(__s._M_end_of_storage);
   1.225 -    _STLP_STD::swap(_M_finish, __s._M_finish);
   1.226 -#endif /* _STLP_USE_SHORT_STRING_OPTIM */
   1.227 -  }
   1.228 -
   1.229 -  void _STLP_FUNCTION_THROWS _M_throw_length_error() const;
   1.230 -  void _STLP_FUNCTION_THROWS _M_throw_out_of_range() const;
   1.231 -};
   1.232 -
   1.233 -#undef _STLP_SHORT_STRING_SZ
   1.234 -
   1.235 -#if defined (_STLP_USE_TEMPLATE_EXPORT)
   1.236 -_STLP_EXPORT_TEMPLATE_CLASS _String_base<char, allocator<char> >;
   1.237 -#  if defined (_STLP_HAS_WCHAR_T)
   1.238 -_STLP_EXPORT_TEMPLATE_CLASS _String_base<wchar_t, allocator<wchar_t> >;
   1.239 -#  endif
   1.240 -#endif /* _STLP_USE_TEMPLATE_EXPORT */
   1.241 -
   1.242 -_STLP_MOVE_TO_STD_NAMESPACE
   1.243 -
   1.244 -_STLP_END_NAMESPACE
   1.245 -
   1.246 -#endif /* _STLP_STRING_BASE_H */
   1.247 -
   1.248 -/*
   1.249 - * Local Variables:
   1.250 - * mode:C++
   1.251 - * End:
   1.252 - */