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