epoc32/include/tools/stlport/stl/_string_sum.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
 * Copyright (c) 2003
williamr@2
     3
 * Francois Dumont
williamr@2
     4
 *
williamr@2
     5
 * This material is provided "as is", with absolutely no warranty expressed
williamr@2
     6
 * or implied. Any use is at your own risk.
williamr@2
     7
 *
williamr@2
     8
 * Permission to use or copy this software for any purpose is hereby granted
williamr@2
     9
 * without fee, provided the above notices are retained on all copies.
williamr@2
    10
 * Permission to modify the code and to distribute modified code is granted,
williamr@2
    11
 * provided the above notices are retained, and a notice that the code was
williamr@2
    12
 * modified is included with the above copyright notice.
williamr@2
    13
 *
williamr@2
    14
 */
williamr@2
    15
williamr@2
    16
#ifndef _STLP_STRING_SUM_H
williamr@2
    17
#define _STLP_STRING_SUM_H
williamr@2
    18
williamr@2
    19
_STLP_BEGIN_NAMESPACE
williamr@2
    20
williamr@2
    21
_STLP_MOVE_TO_PRIV_NAMESPACE
williamr@2
    22
williamr@2
    23
/*char wrapper to simulate basic_string*/
williamr@2
    24
template <class _CharT>
williamr@2
    25
struct __char_wrapper {
williamr@2
    26
  typedef const _CharT& const_reference;
williamr@2
    27
williamr@2
    28
  __char_wrapper(_CharT __val) : _Val(__val) {}
williamr@2
    29
williamr@2
    30
  _CharT getValue() const { return _Val; }
williamr@2
    31
  size_t size() const { return 1; }
williamr@2
    32
williamr@2
    33
  const_reference operator[] (size_t __n) const {
williamr@2
    34
    //To avoid a check on __n we use this strange implementation
williamr@2
    35
    return (&_Val)[__n];
williamr@2
    36
  }
williamr@2
    37
williamr@2
    38
private:
williamr@2
    39
  _CharT _Val;
williamr@2
    40
};
williamr@2
    41
williamr@2
    42
/*C string wrapper to simulate basic_string*/
williamr@2
    43
template <class _CharT>
williamr@2
    44
struct __cstr_wrapper {
williamr@2
    45
  typedef const _CharT& const_reference;
williamr@2
    46
williamr@2
    47
  __cstr_wrapper(const _CharT *__cstr, size_t __size) :
williamr@2
    48
    _CStr(__cstr), _Size(__size) {}
williamr@2
    49
williamr@2
    50
  const _CharT* c_str() const { return _CStr; }
williamr@2
    51
williamr@2
    52
  size_t size() const { return _Size; }
williamr@2
    53
williamr@2
    54
  const_reference operator[] (size_t __n) const { return _CStr[__n]; }
williamr@2
    55
williamr@2
    56
private:
williamr@2
    57
  const _CharT *_CStr;
williamr@2
    58
  size_t _Size;
williamr@2
    59
};
williamr@2
    60
williamr@2
    61
/*basic_string wrapper to ensure that we only store a reference to the original string and not copy it*/
williamr@2
    62
template <class _CharT, class _Traits, class _Alloc>
williamr@2
    63
struct __bstr_wrapper {
williamr@2
    64
  typedef const _CharT& const_reference;
williamr@2
    65
  typedef basic_string<_CharT, _Traits, _Alloc> _BString;
williamr@2
    66
williamr@2
    67
  __bstr_wrapper (_BString const& __s) :
williamr@2
    68
    _BStr(__s) {}
williamr@2
    69
williamr@2
    70
  size_t size() const { return _BStr.size(); }
williamr@2
    71
williamr@2
    72
  const_reference operator[] (size_t __n) const { return _BStr[__n]; }
williamr@2
    73
williamr@2
    74
  _BString const& b_str() const { return _BStr; }
williamr@2
    75
williamr@2
    76
private:
williamr@2
    77
  _BString const& _BStr;
williamr@2
    78
};
williamr@2
    79
williamr@2
    80
struct __on_left {};
williamr@2
    81
struct __on_right {};
williamr@2
    82
williamr@2
    83
template <class _CharT, class _Traits, class _Alloc,
williamr@2
    84
          class _Left, class _Right,
williamr@2
    85
          class _StorageDirection>
williamr@2
    86
class __bstr_sum {
williamr@2
    87
public:
williamr@2
    88
  typedef basic_string<_CharT, _Traits, _Alloc> _BString;
williamr@2
    89
  typedef typename _BString::const_reference const_reference;
williamr@2
    90
  typedef typename _BString::const_iterator const_iterator;
williamr@2
    91
  typedef typename _BString::const_reverse_iterator const_reverse_iterator;
williamr@2
    92
  typedef typename _BString::size_type size_type;
williamr@2
    93
  typedef typename _BString::allocator_type allocator_type;
williamr@2
    94
  typedef __bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDirection> _Self;
williamr@2
    95
williamr@2
    96
  __bstr_sum (_Left const& lhs, _Right const& rhs) :
williamr@2
    97
    _lhs(lhs), _rhs(rhs) {}
williamr@2
    98
williamr@2
    99
  _Left const& getLhs() const { return _lhs; }
williamr@2
   100
  _Right const& getRhs() const { return _rhs; }
williamr@2
   101
williamr@2
   102
  allocator_type get_allocator() const { return _M_get_storage(false).get_allocator(); }
williamr@2
   103
williamr@2
   104
  const_iterator begin() const { return _M_get_storage().begin(); }
williamr@2
   105
  const_iterator end()   const { return _M_get_storage().end(); }
williamr@2
   106
  const_reverse_iterator rbegin() const { return _M_get_storage().rbegin(); }
williamr@2
   107
  const_reverse_iterator rend()   const { return _M_get_storage().rend(); }
williamr@2
   108
williamr@2
   109
  size_type size() const { return _lhs.size() + _rhs.size(); }
williamr@2
   110
  size_type length() const { return size(); }
williamr@2
   111
williamr@2
   112
  size_t max_size() const { return _M_get_storage().max_size(); }
williamr@2
   113
  size_type capacity() const { return size(); }
williamr@2
   114
  bool empty() const { return size() == 0; }
williamr@2
   115
williamr@2
   116
  const_reference operator[](size_t __n) const
williamr@2
   117
  { return (__n < _lhs.size())?_lhs[__n]:_rhs[__n - _lhs.size()]; }
williamr@2
   118
williamr@2
   119
  const_reference at(size_type __n) const
williamr@2
   120
  { return _M_get_storage().at(__n); }
williamr@2
   121
williamr@2
   122
  //operator +=
williamr@2
   123
  typedef __bstr_sum<_CharT, _Traits, _Alloc, _Self, __bstr_wrapper<_CharT, _Traits, _Alloc>, __on_left> _BStrOnLeft;
williamr@2
   124
  _BStrOnLeft operator += (const _BString& __s) { return append(__s); }
williamr@2
   125
williamr@2
   126
  typedef __bstr_sum<_CharT, _Traits, _Alloc, _Self, __cstr_wrapper<_CharT>, __on_left> _CStrOnLeft;
williamr@2
   127
  _CStrOnLeft operator += (const _CharT* __s) { return append(__s); }
williamr@2
   128
williamr@2
   129
  typedef __bstr_sum<_CharT, _Traits, _Alloc, _Self, __char_wrapper<_CharT>, __on_left> _CharOnLeft;
williamr@2
   130
  _CharOnLeft operator += (_CharT __c) { return _CharOnLeft(*this, __c); }
williamr@2
   131
williamr@2
   132
  //append
williamr@2
   133
  _BStrOnLeft append (const _BString& __s)
williamr@2
   134
  { return _BStrOnLeft(*this, __s); }
williamr@2
   135
  _BString& append(const _BString& __s, size_type __pos, size_type __n)
williamr@2
   136
  { return _M_get_storage().append(__s, __pos, __n); }
williamr@2
   137
  _CStrOnLeft append(const _CharT* __s) {
williamr@2
   138
    const size_type __n = _Traits::length(__s);
williamr@2
   139
    return _CStrOnLeft(*this, __cstr_wrapper<_CharT>(__s, __n));
williamr@2
   140
  }
williamr@2
   141
  _CStrOnLeft append(const _CharT* __s, size_type __n)
williamr@2
   142
  { return _CStrOnLeft(*this, __cstr_wrapper<_CharT>(__s, __n)); }
williamr@2
   143
  _BString& append(size_type __n, _CharT __c)
williamr@2
   144
  {return _M_get_storage().append(__n, __c);}
williamr@2
   145
  template <class _InputIter>
williamr@2
   146
  _BString& append(_InputIter __first, _InputIter __last)
williamr@2
   147
  {return _M_get_storage().append(__first, __last);}
williamr@2
   148
williamr@2
   149
  //assign
williamr@2
   150
  _BString& assign(const _BString& __s) {return _M_get_storage().assign(__s);}
williamr@2
   151
  _BString& assign(const _BString& __s, size_type __pos, size_type __n) {return _M_get_storage().assign(__s, __pos, __n);}
williamr@2
   152
  _BString& assign(const _CharT* __s, size_type __n) {return _M_get_storage().assign(__s, __n);}
williamr@2
   153
  _BString& assign(const _CharT* __s) {return _M_get_storage().assign(__s); }
williamr@2
   154
  _BString& assign(size_type __n, _CharT __c) {return _M_get_storage().assign(__n, __c);}
williamr@2
   155
williamr@2
   156
  //insert
williamr@2
   157
  _BString& insert(size_type __pos, const _BString& __s) {return _M_get_storage().insert(__pos, __s);}
williamr@2
   158
  _BString& insert(size_type __pos, const _BString& __s, size_type __beg, size_type __n)
williamr@2
   159
  {return _M_get_storage().insert(__pos, __s, __beg, __n);}
williamr@2
   160
  _BString& insert(size_type __pos, const _CharT* __s, size_type __n) {return _M_get_storage().insert(__pos, __s, __n);}
williamr@2
   161
  _BString& insert(size_type __pos, const _CharT* __s) {return _M_get_storage().insert(__pos, __s);}
williamr@2
   162
  _BString& insert(size_type __pos, size_type __n, _CharT __c) {return _M_get_storage().insert(__pos, __n, __c);}
williamr@2
   163
williamr@2
   164
  //erase
williamr@2
   165
  _BString& erase(size_type __pos = 0, size_type __n =_BString::npos) {return _M_get_storage().erase(__pos, __n);}
williamr@2
   166
williamr@2
   167
  //replace
williamr@2
   168
  _BString& replace(size_type __pos, size_type __n, const _BString& __s)
williamr@2
   169
  {return _M_get_storage().replace(__pos, __n, __s);}
williamr@2
   170
  _BString& replace(size_type __pos1, size_type __n1, const _BString& __s, size_type __pos2, size_type __n2)
williamr@2
   171
  {return _M_get_storage().replace(__pos1, __n1, __s, __pos2, __n2);}
williamr@2
   172
  _BString& replace(size_type __pos, size_type __n1, const _CharT* __s, size_type __n2)
williamr@2
   173
  {return _M_get_storage().replace(__pos, __n1, __s, __n2);}
williamr@2
   174
  _BString& replace(size_type __pos, size_type __n1, const _CharT* __s)
williamr@2
   175
  {return _M_get_storage().replace(__pos, __n1, __s);}
williamr@2
   176
  _BString& replace(size_type __pos, size_type __n1, size_type __n2, _CharT __c)
williamr@2
   177
  {return _M_get_storage().replace(__pos, __n1, __n2, __c);}
williamr@2
   178
williamr@2
   179
  size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const
williamr@2
   180
  {return _M_get_storage().copy(__s, __n, __pos);}
williamr@2
   181
williamr@2
   182
  void swap(_BString& __s)
williamr@2
   183
  {_M_get_storage().swap(__s);}
williamr@2
   184
williamr@2
   185
  const _CharT* c_str() const { return _M_get_storage().c_str(); }
williamr@2
   186
  const _CharT* data()  const { return _M_get_storage().data(); }
williamr@2
   187
williamr@2
   188
  //find family
williamr@2
   189
  size_type find(const _BString& __s, size_type __pos = 0) const { return _M_get_storage().find(__s, __pos); }
williamr@2
   190
  size_type find(const _CharT* __s, size_type __pos = 0) const { return _M_get_storage().find(__s, __pos); }
williamr@2
   191
  size_type find(const _CharT* __s, size_type __pos, size_type __n) const { return _M_get_storage().find(__s, __pos, __n); }
williamr@2
   192
  size_type find(_CharT __c, size_type __pos = 0) const { return _M_get_storage().find(__c, __pos); }
williamr@2
   193
williamr@2
   194
  size_type rfind(const _BString& __s, size_type __pos = _BString::npos) const { return _M_get_storage().rfind(__s, __pos); }
williamr@2
   195
  size_type rfind(const _CharT* __s, size_type __pos = _BString::npos) const { return _M_get_storage().rfind(__s, __pos); }
williamr@2
   196
  size_type rfind(const _CharT* __s, size_type __pos, size_type __n) const { return _M_get_storage().rfind(__s, __pos, __n); }
williamr@2
   197
  size_type rfind(_CharT __c, size_type __pos = _BString::npos) const { return _M_get_storage().rfind(__c, __pos); }
williamr@2
   198
williamr@2
   199
  size_type find_first_of(const _BString& __s, size_type __pos = 0) const
williamr@2
   200
  { return _M_get_storage().find_first_of(__s, __pos); }
williamr@2
   201
  size_type find_first_of(const _CharT* __s, size_type __pos = 0) const
williamr@2
   202
  { return _M_get_storage().find_first_of(__s, __pos); }
williamr@2
   203
  size_type find_first_of(const _CharT* __s, size_type __pos, size_type __n) const
williamr@2
   204
  { return _M_get_storage().find_first_of(__s, __pos, __n); }
williamr@2
   205
  size_type find_first_of(_CharT __c, size_type __pos = 0) const
williamr@2
   206
  { return _M_get_storage().find(__c, __pos); }
williamr@2
   207
williamr@2
   208
  size_type find_last_of(const _BString& __s, size_type __pos = _BString::npos) const
williamr@2
   209
  { return _M_get_storage().find_last_of(__s, __pos); }
williamr@2
   210
  size_type find_last_of(const _CharT* __s, size_type __pos = _BString::npos) const
williamr@2
   211
  { return _M_get_storage().find_last_of(__s, __pos); }
williamr@2
   212
  size_type find_last_of(const _CharT* __s, size_type __pos, size_type __n) const
williamr@2
   213
  { return _M_get_storage().find_last_of(__s, __pos, __n); }
williamr@2
   214
  size_type find_last_of(_CharT __c, size_type __pos = _BString::npos) const
williamr@2
   215
  { return _M_get_storage().rfind(__c, __pos); }
williamr@2
   216
williamr@2
   217
  size_type find_first_not_of(const _BString& __s, size_type __pos = 0) const
williamr@2
   218
  { return _M_get_storage().find_first_not_of(__s, __pos); }
williamr@2
   219
  size_type find_first_not_of(const _CharT* __s, size_type __pos = 0) const
williamr@2
   220
  { return _M_get_storage().find_first_not_of(__s, __pos); }
williamr@2
   221
  size_type find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
williamr@2
   222
  { return _M_get_storage().find_first_not_of(__s, __pos, __n); }
williamr@2
   223
  size_type find_first_not_of(_CharT __c, size_type __pos = 0) const
williamr@2
   224
  { return _M_get_storage().find_first_not_of(__c, __pos); }
williamr@2
   225
williamr@2
   226
  size_type find_last_not_of(const _BString& __s, size_type __pos = _BString::npos) const
williamr@2
   227
  { return _M_get_storage().find_last_not_of(__s, __pos); }
williamr@2
   228
  size_type find_last_not_of(const _CharT* __s, size_type __pos =_BString:: npos) const
williamr@2
   229
  { return _M_get_storage().find_last_not_of(__s, __pos); }
williamr@2
   230
  size_type find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
williamr@2
   231
  { return _M_get_storage().find_last_not_of(__s, __pos, __n); }
williamr@2
   232
  size_type find_last_not_of(_CharT __c, size_type __pos = _BString::npos) const
williamr@2
   233
  { return _M_get_storage().find_last_not_of(__c, __pos); }
williamr@2
   234
williamr@2
   235
  _BString substr(size_type __pos = 0, size_type __n = _BString::npos) const
williamr@2
   236
  { return _M_get_storage().substr(__pos, __n); }
williamr@2
   237
williamr@2
   238
  //compare
williamr@2
   239
  int compare(const _BString& __s) const
williamr@2
   240
  { return _M_get_storage().compare(__s); }
williamr@2
   241
  int compare(size_type __pos1, size_type __n1, const _Self& __s) const
williamr@2
   242
  { return _M_get_storage().compare(__pos1, __n1, __s); }
williamr@2
   243
  int compare(size_type __pos1, size_type __n1, const _Self& __s, size_type __pos2, size_type __n2) const
williamr@2
   244
  { return _M_get_storage().compare(__pos1, __n1, __s, __pos2, __n2); }
williamr@2
   245
  int compare(const _CharT* __s) const
williamr@2
   246
  { return _M_get_storage().compare(__s); }
williamr@2
   247
  int compare(size_type __pos1, size_type __n1, const _CharT* __s) const
williamr@2
   248
  { return _M_get_storage().compare(__pos1, __n1, __s); }
williamr@2
   249
  int compare(size_type __pos1, size_type __n1, const _CharT* __s, size_type __n2) const
williamr@2
   250
  { return _M_get_storage().compare(__pos1, __n1, __s, __n2); }
williamr@2
   251
williamr@2
   252
  //Returns the underlying basic_string representation of the template expression
williamr@2
   253
  //The non const method will always initialise it.
williamr@2
   254
  _BString& _M_get_storage()
williamr@2
   255
  { return _rhs._M_get_storage(*this, _StorageDirection()); }
williamr@2
   256
williamr@2
   257
  template <class _Lhs, class _Rhs, class _StorageDir>
williamr@2
   258
  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,
williamr@2
   259
                           __on_left const& /*StorageDir*/)
williamr@2
   260
  { return _lhs._M_get_storage(__ref); }
williamr@2
   261
williamr@2
   262
  template <class _Lhs, class _Rhs, class _StorageDir>
williamr@2
   263
  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,
williamr@2
   264
                           __on_right const& /*StorageDir*/)
williamr@2
   265
  { return _rhs._M_get_storage(__ref); }
williamr@2
   266
williamr@2
   267
  template <class _Lhs, class _Rhs, class _StorageDir>
williamr@2
   268
  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref)
williamr@2
   269
  { return _M_get_storage(__ref, _StorageDirection()); }
williamr@2
   270
williamr@2
   271
  //The const method can be invoked without initialising the basic_string so avoiding dynamic allocation.
williamr@2
   272
  _BString const& _M_get_storage(bool __do_init = true) const
williamr@2
   273
  { return _M_get_storage(*this, __do_init, _StorageDirection()); }
williamr@2
   274
williamr@2
   275
  template <class _Lhs, class _Rhs, class _StorageDir>
williamr@2
   276
  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,
williamr@2
   277
                                 bool __do_init, __on_left const& /*StorageDir*/) const
williamr@2
   278
  { return _lhs._M_get_storage(__ref, __do_init); }
williamr@2
   279
williamr@2
   280
  template <class _Lhs, class _Rhs, class _StorageDir>
williamr@2
   281
  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,
williamr@2
   282
                                 bool __do_init, __on_right const& /*StorageDir*/) const
williamr@2
   283
  { return _rhs._M_get_storage(__ref, __do_init); }
williamr@2
   284
williamr@2
   285
  template <class _Lhs, class _Rhs, class _StorageDir>
williamr@2
   286
  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Lhs, _Rhs, _StorageDir>  const& __ref,
williamr@2
   287
                                 bool __do_init) const
williamr@2
   288
  { return _M_get_storage(__ref, __do_init, _StorageDirection()); }
williamr@2
   289
williamr@2
   290
private:
williamr@2
   291
  _Left  _lhs;
williamr@2
   292
  _Right _rhs;
williamr@2
   293
};
williamr@2
   294
williamr@2
   295
/*
williamr@2
   296
 * For this operator we choose to use the right part as the storage part
williamr@2
   297
 */
williamr@2
   298
template <class _CharT, class _Traits, class _Alloc,
williamr@2
   299
          class _Lh1, class _Rh1, class _StoreDir1,
williamr@2
   300
          class _Lh2, class _Rh2, class _StoreDir2>
williamr@2
   301
inline __bstr_sum<_CharT, _Traits, _Alloc,
williamr@2
   302
                  __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1>,
williamr@2
   303
                  __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2>,
williamr@2
   304
                  __on_right> _STLP_CALL
williamr@2
   305
operator + (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,
williamr@2
   306
            const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs) {
williamr@2
   307
  return __bstr_sum<_CharT, _Traits, _Alloc,
williamr@2
   308
                    __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1>,
williamr@2
   309
                    __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2>,
williamr@2
   310
                    __on_right>(__lhs, __rhs);
williamr@2
   311
}
williamr@2
   312
williamr@2
   313
template <class _CharT, class _Traits, class _Alloc,
williamr@2
   314
          class _Lh1, class _Rh1, class _StoreDir1,
williamr@2
   315
          class _Lh2, class _Rh2, class _StoreDir2>
williamr@2
   316
inline bool _STLP_CALL
williamr@2
   317
operator == (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,
williamr@2
   318
             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs)
williamr@2
   319
{ return (__lhs.size() == __rhs.size()) && (__lhs._M_get_storage() == __rhs._M_get_storage()); }
williamr@2
   320
williamr@2
   321
template <class _CharT, class _Traits, class _Alloc,
williamr@2
   322
          class _Lh1, class _Rh1, class _StoreDir1,
williamr@2
   323
          class _Lh2, class _Rh2, class _StoreDir2>
williamr@2
   324
inline bool _STLP_CALL
williamr@2
   325
operator < (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,
williamr@2
   326
            const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs)
williamr@2
   327
{ return __lhs._M_get_storage() < __rhs._M_get_storage(); }
williamr@2
   328
williamr@2
   329
#ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
williamr@2
   330
williamr@2
   331
template <class _CharT, class _Traits, class _Alloc,
williamr@2
   332
          class _Lh1, class _Rh1, class _StoreDir1,
williamr@2
   333
          class _Lh2, class _Rh2, class _StoreDir2>
williamr@2
   334
inline bool _STLP_CALL
williamr@2
   335
operator != (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,
williamr@2
   336
             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs)
williamr@2
   337
{ return !(__lhs == __rhs); }
williamr@2
   338
williamr@2
   339
template <class _CharT, class _Traits, class _Alloc,
williamr@2
   340
          class _Lh1, class _Rh1, class _StoreDir1,
williamr@2
   341
          class _Lh2, class _Rh2, class _StoreDir2>
williamr@2
   342
inline bool _STLP_CALL
williamr@2
   343
operator > (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,
williamr@2
   344
            const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs)
williamr@2
   345
{ return __rhs < __lhs; }
williamr@2
   346
williamr@2
   347
template <class _CharT, class _Traits, class _Alloc,
williamr@2
   348
          class _Lh1, class _Rh1, class _StoreDir1,
williamr@2
   349
          class _Lh2, class _Rh2, class _StoreDir2>
williamr@2
   350
inline bool _STLP_CALL
williamr@2
   351
operator <= (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,
williamr@2
   352
             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs)
williamr@2
   353
{ return !(__rhs < __lhs); }
williamr@2
   354
williamr@2
   355
template <class _CharT, class _Traits, class _Alloc,
williamr@2
   356
          class _Lh1, class _Rh1, class _StoreDir1,
williamr@2
   357
          class _Lh2, class _Rh2, class _StoreDir2>
williamr@2
   358
inline bool _STLP_CALL
williamr@2
   359
operator >= (const __bstr_sum<_CharT, _Traits, _Alloc, _Lh1, _Rh1, _StoreDir1> &__lhs,
williamr@2
   360
             const __bstr_sum<_CharT, _Traits, _Alloc, _Lh2, _Rh2, _StoreDir2> &__rhs)
williamr@2
   361
{ return !(__lhs < __rhs); }
williamr@2
   362
williamr@2
   363
#endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
williamr@2
   364
williamr@2
   365
williamr@2
   366
/*
williamr@2
   367
 * This class will be used to simulate a temporary string that is required for
williamr@2
   368
 * a call to the c_str method on the __bstr_sum class.
williamr@2
   369
 */
williamr@2
   370
williamr@2
   371
template <class _CharT, class _Traits, class _Alloc>
williamr@2
   372
struct __sum_storage_elem {
williamr@2
   373
  typedef basic_string<_CharT, _Traits, _Alloc> _BString;
williamr@2
   374
williamr@2
   375
  __sum_storage_elem(_Alloc __alloc) : _M_init(false), _M_storage(__alloc)
williamr@2
   376
  {}
williamr@2
   377
williamr@2
   378
  template <class _Left, class _Right, class _StorageDir>
williamr@2
   379
  void _M_Init(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>  const& __ref) const {
williamr@2
   380
    if (!_M_init) {
williamr@2
   381
      _M_storage = __ref;
williamr@2
   382
      _M_init = true;
williamr@2
   383
    }
williamr@2
   384
  }
williamr@2
   385
williamr@2
   386
  template <class _Left, class _Right, class _StorageDir>
williamr@2
   387
  _BString const& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>  const& __ref,
williamr@2
   388
                                 bool __do_init) const {
williamr@2
   389
    if (__do_init) {
williamr@2
   390
      _M_Init(__ref);
williamr@2
   391
    }
williamr@2
   392
    return _M_storage;
williamr@2
   393
  }
williamr@2
   394
  template <class _Left, class _Right, class _StorageDir>
williamr@2
   395
  _BString& _M_get_storage(__bstr_sum<_CharT, _Traits, _Alloc, _Left, _Right, _StorageDir>  const& __ref) {
williamr@2
   396
    _M_Init(__ref);
williamr@2
   397
    return _M_storage;
williamr@2
   398
  }
williamr@2
   399
williamr@2
   400
  size_t size() const { return 0; }
williamr@2
   401
  _CharT const& operator[](size_t __n) const
williamr@2
   402
  { return __STATIC_CAST(_CharT*, 0)[__n]; }
williamr@2
   403
williamr@2
   404
private:
williamr@2
   405
  mutable bool _M_init;
williamr@2
   406
  mutable basic_string<_CharT, _Traits, _Alloc> _M_storage;
williamr@2
   407
};
williamr@2
   408
williamr@2
   409
_STLP_MOVE_TO_STD_NAMESPACE
williamr@2
   410
williamr@2
   411
_STLP_END_NAMESPACE
williamr@2
   412
williamr@2
   413
#endif /*_STLP_STRING_SUM_H*/