1
/*      Copyright (C) 2004 Garrett A. Kajmowicz
 
 
3
        This file is part of the uClibc++ Library.
 
 
5
        This library is free software; you can redistribute it and/or
 
 
6
        modify it under the terms of the GNU Lesser General Public
 
 
7
        License as published by the Free Software Foundation; either
 
 
8
        version 2.1 of the License, or (at your option) any later version.
 
 
10
        This library is distributed in the hope that it will be useful,
 
 
11
        but WITHOUT ANY WARRANTY; without even the implied warranty of
 
 
12
        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
 
13
        Lesser General Public License for more details.
 
 
15
        You should have received a copy of the GNU Lesser General Public
 
 
16
        License along with this library; if not, write to the Free Software
 
 
17
        Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 
20
#include <basic_definitions>
 
 
21
#include <char_traits>
 
 
23
#include <func_exception>
 
 
28
#ifdef __UCLIBCXX_HAS_WCHAR__
 
 
33
#ifndef __HEADER_STD_STRING
 
 
34
#define __HEADER_STD_STRING 1
 
 
36
#pragma GCC visibility push(default)
 
 
42
        template<class Ch, class Tr = char_traits<Ch>, class A = allocator<Ch> > class basic_string;
 
 
44
        typedef basic_string<char> string;
 
 
45
        #ifdef __UCLIBCXX_HAS_WCHAR__
 
 
46
        typedef basic_string<wchar_t> wstring;
 
 
51
//template<class Ch, class Tr = char_traits<Ch>, class A = allocator<Ch> > class _UCXXEXPORT basic_string
 
 
52
template<class Ch, class Tr, class A> class basic_string
 
 
53
        : public std::vector<Ch, A>
 
 
56
        typedef Tr traits_type;
 
 
57
        typedef typename Tr::char_type value_type;
 
 
58
        typedef A allocator_type;
 
 
59
        typedef typename A::size_type size_type;
 
 
60
        typedef typename A::difference_type difference_type;
 
 
62
        typedef typename A::reference reference;
 
 
63
        typedef typename A::const_reference const_reference;
 
 
64
        typedef typename A::pointer pointer;
 
 
65
        typedef typename A::const_pointer const_pointer;
 
 
67
        typedef typename vector<Ch, A>::iterator iterator;
 
 
68
        typedef typename vector<Ch, A>::const_iterator const_iterator;
 
 
70
        typedef typename vector<Ch, A>::reverse_iterator reverse_iterator;
 
 
71
        typedef typename vector<Ch, A>::const_reverse_iterator const_reverse_iterator;
 
 
73
        static const size_type npos = (size_type)-1;
 
 
75
        explicit _UCXXEXPORT basic_string(const A& al = A()) : vector<Ch, A>(al){ return; }
 
 
77
        _UCXXEXPORT basic_string(const basic_string& str, size_type pos = 0, size_type n = npos, const A& al = A());    //Below
 
 
79
        _UCXXEXPORT basic_string(const Ch* s, size_type n, const A& al = A())
 
 
83
                        __throw_out_of_range();
 
 
87
                        Tr::copy(vector<Ch, A>::data, s, vector<Ch, A>::elements);
 
 
91
        _UCXXEXPORT basic_string(const Ch* s, const A& al = A());               //Below
 
 
93
        _UCXXEXPORT basic_string(size_type n, Ch c, const A& al = A())
 
 
94
                : vector<Ch, A>(n, c, al)
 
 
98
        template<class InputIterator> _UCXXEXPORT basic_string(InputIterator begin, InputIterator end, const A& a = A())
 
 
99
                :vector<Ch, A>(begin, end)
 
 
104
        _UCXXEXPORT ~basic_string() {
 
 
108
        _UCXXEXPORT basic_string& operator=(const basic_string& str);   //Below
 
 
110
        _UCXXEXPORT basic_string& operator=(const Ch* s){
 
 
111
                vector<Ch, A>::clear();
 
 
113
                        size_type len = Tr::length(s);
 
 
115
                        Tr::copy( vector<Ch, A>::data, s, len);
 
 
120
        _UCXXEXPORT basic_string& operator=(Ch c){
 
 
121
                vector<Ch, A>::clear();
 
 
122
                vector<Ch, A>::push_back(c);
 
 
126
        inline _UCXXEXPORT size_type length() const { return vector<Ch, A>::size(); }
 
 
128
        void _UCXXEXPORT resize(size_type n, Ch c = Ch()){
 
 
129
                vector<Ch, A>::resize(n, c);
 
 
132
        _UCXXEXPORT basic_string& operator+=(const basic_string& str){
 
 
136
        _UCXXEXPORT basic_string& operator+=(const Ch * s){
 
 
140
        _UCXXEXPORT basic_string& operator+=(Ch c){
 
 
141
                vector<Ch, A>::push_back(c);
 
 
145
        _UCXXEXPORT basic_string& append(const basic_string& str){
 
 
146
                size_t temp = vector<Ch, A>::elements;
 
 
147
                resize(vector<Ch, A>::elements + str.elements);
 
 
148
                Tr::copy( vector<Ch, A>::data + temp, str.vector<Ch, A>::data, str.elements);
 
 
153
        _UCXXEXPORT basic_string& append(const basic_string& str, size_type pos, size_type n){
 
 
154
                if(pos > str.size()){
 
 
155
                        __throw_out_of_range();
 
 
158
                size_type rlen = str.elements - pos;
 
 
162
                if(vector<Ch, A>::elements > npos - rlen){
 
 
163
                        __throw_length_error();
 
 
165
                size_t temp = vector<Ch, A>::elements;
 
 
166
                resize(vector<Ch, A>::elements + rlen);
 
 
167
                Tr::copy( vector<Ch, A>::data + temp, str.vector<Ch, A>::data + pos, rlen);
 
 
171
        _UCXXEXPORT basic_string& append(const Ch* s, size_type n){
 
 
172
                size_t temp = vector<Ch, A>::elements;
 
 
173
                resize(vector<Ch, A>::elements + n);
 
 
174
                Tr::copy( vector<Ch, A>::data + temp, s, n);
 
 
178
        _UCXXEXPORT basic_string& append(const Ch* s){
 
 
179
                size_type strLen = Tr::length(s);
 
 
180
                size_t temp = vector<Ch, A>::elements;
 
 
181
                resize(vector<Ch, A>::elements + strLen);
 
 
182
                Tr::copy( vector<Ch, A>::data + temp, s, strLen);
 
 
186
        _UCXXEXPORT basic_string& append(size_type n, Ch c){
 
 
187
                vector<Ch, A>::resize(vector<Ch, A>::elements + n, c);
 
 
191
        _UCXXEXPORT basic_string& assign(const basic_string& str){
 
 
196
        _UCXXEXPORT basic_string& assign(const basic_string& str, size_type pos, size_type n){
 
 
197
                if(pos > str.elements){
 
 
198
                        __throw_out_of_range();
 
 
200
                size_type r = str.elements - pos;
 
 
205
                Tr::copy(vector<Ch, A>::data, str.vector<Ch, A>::data + pos, r);
 
 
209
        _UCXXEXPORT basic_string& assign(const Ch* s, size_type n){
 
 
211
                Tr::copy(vector<Ch, A>::data, s, n);
 
 
215
        _UCXXEXPORT basic_string& assign(const Ch* s){
 
 
216
                size_type len = Tr::length(s);
 
 
217
                return assign(s, len);
 
 
220
        _UCXXEXPORT basic_string& assign(size_type n, Ch c){
 
 
221
                vector<Ch, A>::clear();
 
 
222
                vector<Ch, A>::resize(n, Ch() );
 
 
226
        template<class InputIterator> _UCXXEXPORT basic_string& assign(InputIterator first, InputIterator last){
 
 
227
                vector<Ch, A>::resize(0, Ch());
 
 
228
                while (first != last){
 
 
235
        _UCXXEXPORT basic_string& insert(size_type pos1, const basic_string& str, size_type pos2=0, size_type n=npos){
 
 
236
                if(pos1 > vector<Ch, A>::elements || pos2 > str.elements){
 
 
237
                        __throw_out_of_range();
 
 
239
                size_type r = str.elements - pos2;
 
 
243
                if(vector<Ch, A>::elements > npos - r){
 
 
244
                        __throw_length_error();
 
 
246
                size_type temp = vector<Ch, A>::elements;
 
 
247
                resize(vector<Ch, A>::elements + r);
 
 
248
                Tr::move(vector<Ch, A>::data + pos1 + r, vector<Ch, A>::data + pos1, temp - pos1);
 
 
249
                Tr::copy(vector<Ch, A>::data + pos1, str.vector<Ch, A>::data + pos2, r);
 
 
253
        _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s, size_type n){
 
 
254
                if(pos > vector<Ch, A>::elements){
 
 
255
                        __throw_out_of_range();
 
 
257
                if(vector<Ch, A>::elements > npos - n){
 
 
258
                        __throw_length_error();
 
 
260
                size_type temp = vector<Ch, A>::elements;
 
 
261
                resize(vector<Ch, A>::elements + n);
 
 
262
                Tr::move(vector<Ch, A>::data + pos + n, vector<Ch, A>::data + pos, temp - pos);
 
 
263
                Tr::copy(vector<Ch, A>::data + pos, s, n);
 
 
267
        inline _UCXXEXPORT basic_string& insert(size_type pos, const Ch* s){
 
 
268
                size_type len = Tr::length(s);
 
 
269
                return insert(pos, s, len);
 
 
272
        _UCXXEXPORT basic_string& insert(size_type pos, size_type n, Ch c){
 
 
273
                if(pos > vector<Ch, A>::elements){
 
 
274
                        __throw_out_of_range();
 
 
276
                if(vector<Ch, A>::elements > npos - n){
 
 
277
                        __throw_length_error();
 
 
279
                size_type temp = vector<Ch, A>::elements;
 
 
280
                resize(vector<Ch, A>::elements + n);
 
 
281
                Tr::move(vector<Ch, A>::data + pos + n, vector<Ch, A>::data + pos, temp - pos);
 
 
282
                Tr::assign(vector<Ch, A>::data + pos, n, c);
 
 
286
        using vector<Ch, A>::insert;
 
 
287
//      void insert(iterator p, size_type n, charT c);
 
 
288
//      template<class InputIterator> void insert(iterator p, InputIterator first, InputIterator last);
 
 
290
        _UCXXEXPORT basic_string& erase(size_type pos = 0, size_type n = npos){
 
 
291
                size_type xlen = vector<Ch, A>::elements - pos;
 
 
296
                size_type temp = vector<Ch, A>::elements;
 
 
298
                Tr::move(vector<Ch, A>::data + pos, vector<Ch, A>::data + pos + xlen, temp - pos - xlen);
 
 
303
        _UCXXEXPORT iterator erase(iterator position){
 
 
304
                if(position == vector<Ch, A>::end()){
 
 
310
                iterator temp = position;
 
 
312
                while(position != vector<Ch, A>::end()){
 
 
313
                        *(position-1) = *position;
 
 
316
                vector<Ch, A>::pop_back();
 
 
320
        _UCXXEXPORT iterator erase(iterator first, iterator last){
 
 
321
                size_t count = last - first;
 
 
323
                iterator temp = last;
 
 
325
                while(last != vector<Ch, A>::end()){
 
 
326
                        *(last - count) = *last;
 
 
330
                resize( vector<Ch, A>::elements-count);
 
 
335
        _UCXXEXPORT basic_string&
 
 
336
                replace(size_type pos1, size_type n1, const basic_string& str, size_type pos2=0, size_type n2=npos)
 
 
338
                if(pos1 > vector<Ch, A>::elements){
 
 
339
                        __throw_out_of_range();
 
 
341
                size_type xlen = vector<Ch, A>::elements - pos1;
 
 
345
                size_type rlen = str.elements - pos2;
 
 
349
                if((vector<Ch, A>::elements - xlen) >= (npos - rlen)){
 
 
350
                        __throw_length_error();
 
 
353
                size_t temp = vector<Ch, A>::elements;
 
 
355
                if(rlen > xlen){                //Only if making larger
 
 
356
                        resize(temp - xlen + rlen);
 
 
359
                //Final length = vector<Ch, A>::elements - xlen + rlen
 
 
360
                //Initial block is of size pos1
 
 
361
                //Block 2 is of size len
 
 
363
                Tr::move(vector<Ch, A>::data + pos1 + rlen, vector<Ch, A>::data + pos1 + xlen, temp - pos1 - xlen);
 
 
364
                Tr::copy(vector<Ch, A>::data + pos1, str.vector<Ch, A>::data + pos2, rlen);
 
 
365
                resize(temp - xlen + rlen);
 
 
369
        _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s, size_type n2){
 
 
370
                return replace(pos,n1,basic_string<Ch,Tr,A>(s,n2));
 
 
374
        inline _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, const Ch* s){
 
 
375
                return replace(pos,n1,basic_string<Ch,Tr,A>(s));
 
 
378
        _UCXXEXPORT basic_string& replace(size_type pos, size_type n1, size_type n2, Ch c){
 
 
379
                return replace(pos,n1,basic_string<Ch, Tr, A>(n2,c));
 
 
381
//      _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const basic_string& str);
 
 
382
//      _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s, size_type n);
 
 
383
//      _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, const Ch* s);
 
 
384
//      _UCXXEXPORT basic_string& replace(iterator i1, iterator i2, size_type n, Ch c);
 
 
385
/*      template<class InputIterator> _UCXXEXPORT basic_string& replace(iterator i1, iterator i2,
 
 
386
                InputIterator j1, InputIterator j2);*/
 
 
388
        size_type _UCXXEXPORT copy(Ch* s, size_type n, size_type pos = 0) const{
 
 
389
                if(pos > vector<Ch, A>::elements){
 
 
390
                        __throw_out_of_range();
 
 
392
                size_type r = vector<Ch, A>::elements - pos;
 
 
396
                Tr::copy(s, vector<Ch, A>::data + pos, r);
 
 
400
        _UCXXEXPORT void swap(basic_string<Ch,Tr,A>& s){
 
 
403
                vector<Ch, A>::swap(s);
 
 
406
        _UCXXEXPORT const Ch* c_str() const{
 
 
407
                const_cast<basic_string<Ch,Tr,A> *>(this)->reserve(vector<Ch, A>::elements+1);
 
 
408
                vector<Ch, A>::data[vector<Ch, A>::elements] = 0;       //Add 0 at the end
 
 
409
                return vector<Ch, A>::data;
 
 
412
        _UCXXEXPORT const Ch* data() const{
 
 
413
                return vector<Ch, A>::data;
 
 
415
        _UCXXEXPORT allocator_type get_allocator() const{
 
 
416
                return vector<Ch, A>::a;
 
 
419
        _UCXXEXPORT size_type find (const basic_string& str, size_type pos = 0) const;  //Below
 
 
421
        _UCXXEXPORT size_type find (const Ch* s, size_type pos, size_type n) const{
 
 
422
                return find(basic_string<Ch, Tr, A>(s,n), pos);
 
 
424
        _UCXXEXPORT size_type find (const Ch* s, size_type pos = 0) const{
 
 
425
                return find(basic_string<Ch, Tr, A>(s), pos);
 
 
427
        _UCXXEXPORT size_type find (Ch c, size_type pos = 0) const{
 
 
428
                for(size_type i = pos; i < length(); ++i){
 
 
429
                        if(operator[](i) == c){
 
 
435
        _UCXXEXPORT size_type rfind(const basic_string& str, size_type pos = npos) const{
 
 
439
                for(size_type i = pos; i > 0; --i){
 
 
440
                        if(str == substr(i-1, str.length())){
 
 
446
        _UCXXEXPORT size_type rfind(const Ch* s, size_type pos, size_type n) const{
 
 
447
                return rfind(basic_string<Ch, Tr, A>(s,n),pos);
 
 
449
        _UCXXEXPORT size_type rfind(const Ch* s, size_type pos = npos) const{
 
 
450
                return rfind(basic_string<Ch, Tr, A>(s),pos);
 
 
452
        _UCXXEXPORT size_type rfind(Ch c, size_type pos = npos) const{
 
 
453
                return rfind(basic_string<Ch, Tr, A>(1,c),pos);
 
 
456
        _UCXXEXPORT size_type find_first_of(const basic_string& str, size_type pos = 0) const{
 
 
457
                for(size_type i = pos; i < length(); ++i){
 
 
458
                        for(size_type j = 0; j < str.length() ; ++j){
 
 
459
                                if( Tr::eq(str[j], operator[](i)) ){
 
 
467
        _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos, size_type n) const{
 
 
468
                return find_first_of(basic_string<Ch, Tr, A>(s,n),pos);
 
 
470
        _UCXXEXPORT size_type find_first_of(const Ch* s, size_type pos = 0) const{
 
 
471
                return find_first_of(basic_string<Ch, Tr, A>(s),pos);
 
 
473
        _UCXXEXPORT size_type find_first_of(Ch c, size_type pos = 0) const{
 
 
474
                for(size_type i = pos; i< length(); ++i){
 
 
475
                        if( Tr::eq(operator[](i), c) ){
 
 
482
        _UCXXEXPORT size_type find_last_of (const basic_string& str, size_type pos = npos) const{
 
 
486
                for(size_type i = pos; i >0 ; --i){
 
 
487
                        for(size_type j = 0 ; j < str.length(); ++j){
 
 
488
                                if( Tr::eq(operator[](i-1), str[j]) ){
 
 
495
        _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos, size_type n) const{
 
 
496
                return find_last_of(basic_string<Ch, Tr, A>(s,n),pos);
 
 
498
        _UCXXEXPORT size_type find_last_of (const Ch* s, size_type pos = npos) const{
 
 
499
                return find_last_of(basic_string<Ch, Tr, A>(s),pos);
 
 
501
        _UCXXEXPORT size_type find_last_of (Ch c, size_type pos = npos) const{
 
 
505
                for(size_type i = pos; i >0 ; --i){
 
 
506
                        if( Tr::eq(operator[](i-1), c) ){
 
 
513
        _UCXXEXPORT size_type find_first_not_of(const basic_string& str, size_type pos = 0) const{
 
 
515
                for(size_type i = pos; i < length(); ++i){
 
 
516
                        foundCharacter = false;
 
 
517
                        for(size_type j = 0; j < str.length() ; ++j){
 
 
518
                                if( Tr::eq(str[j], operator[](i)) ){
 
 
519
                                        foundCharacter = true;
 
 
522
                        if(foundCharacter == false){
 
 
529
        _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos, size_type n) const{
 
 
530
                return find_first_not_of(basic_string<Ch, Tr, A>(s,n),pos);
 
 
532
        _UCXXEXPORT size_type find_first_not_of(const Ch* s, size_type pos = 0) const{
 
 
533
                return find_first_not_of(basic_string<Ch, Tr, A>(s),pos);
 
 
535
        _UCXXEXPORT size_type find_first_not_of(Ch c, size_type pos = 0) const{
 
 
536
                for(size_type i = pos; i < length() ; ++i){
 
 
537
                        if(operator[](i) != c){
 
 
543
        _UCXXEXPORT size_type find_last_not_of (const basic_string& str, size_type pos = npos) const{
 
 
544
                size_type xpos(length() - 1);
 
 
549
                while(xpos != npos && npos != str.find_first_of(at(xpos))){
 
 
556
        _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos, size_type n) const{
 
 
557
                return find_last_not_of(basic_string<Ch, Tr, A>(s,n),pos);
 
 
559
        _UCXXEXPORT size_type find_last_not_of (const Ch* s, size_type pos = npos) const{
 
 
560
                return find_last_not_of(basic_string<Ch, Tr, A>(s),pos);
 
 
562
        _UCXXEXPORT size_type find_last_not_of (Ch c, size_type pos = npos) const{
 
 
563
                size_type xpos(length() - 1);
 
 
567
                while(xpos != npos && Tr::eq(at(xpos), c)){
 
 
574
        _UCXXEXPORT basic_string substr(size_type pos = 0, size_type n = npos) const;
 
 
576
        _UCXXEXPORT int compare(const basic_string& str) const{
 
 
577
                size_type rlen = vector<Ch, A>::elements;
 
 
578
                if(rlen >  str.elements){
 
 
581
                int retval = Tr::compare(vector<Ch, A>::data, str.vector<Ch, A>::data, rlen);
 
 
583
                        if(vector<Ch, A>::elements < str.elements){
 
 
586
                        if(vector<Ch, A>::elements > str.elements){
 
 
593
        _UCXXEXPORT int compare(size_type pos1, size_type n1, const basic_string& str,
 
 
594
                size_type pos2=0, size_type n2=npos) const{
 
 
595
                size_type len1 = vector<Ch, A>::elements - pos1;
 
 
599
                size_type len2 = str.vector<Ch, A>::elements - pos2;
 
 
603
                size_type rlen = len1;
 
 
607
                int retval = Tr::compare(vector<Ch, A>::data + pos1, str.vector<Ch, A>::data + pos2, rlen);
 
 
619
        _UCXXEXPORT int compare(const Ch* s) const{
 
 
620
                size_type slen = Tr::length(s);
 
 
621
                size_type rlen = slen;
 
 
622
                if(rlen > vector<Ch, A>::elements){
 
 
623
                        rlen=vector<Ch, A>::elements;
 
 
625
                int retval = Tr::compare(vector<Ch, A>::data, s, rlen);
 
 
627
                        if(vector<Ch, A>::elements < slen){
 
 
630
                        if(vector<Ch, A>::elements > slen){
 
 
637
        _UCXXEXPORT int compare(size_type pos1, size_type n1, const Ch* s, size_type n2 = npos) const{
 
 
638
                size_type len1 = vector<Ch, A>::elements - pos1;
 
 
642
                size_type slen = Tr::length(s);
 
 
643
                size_type len2 = slen;
 
 
647
                size_type rlen = len1;
 
 
651
                int retval  = Tr::compare(vector<Ch, A>::data + pos1, s, rlen);
 
 
668
template<class Ch,class Tr,class A> _UCXXEXPORT basic_string<Ch,Tr,A>::basic_string(const Ch* s, const A& al)
 
 
672
                size_type temp = Tr::length(s);
 
 
677
template<class Ch,class Tr,class A> _UCXXEXPORT basic_string<Ch,Tr,A>::
 
 
678
        basic_string(const basic_string& str, size_type pos, size_type n, const A& al) 
 
 
682
                __throw_out_of_range();
 
 
684
        size_type rlen = str.size() - pos;
 
 
689
        Tr::copy(vector<Ch, A>::data, str.vector<Ch, A>::data + pos, vector<Ch, A>::elements);
 
 
692
template<class Ch,class Tr,class A> _UCXXEXPORT basic_string<Ch,Tr,A>&
 
 
693
        basic_string<Ch,Tr,A>::operator=(const basic_string<Ch,Tr,A> & str)
 
 
695
        if(&str == this){       //Check if we are doing a=a 
 
 
698
        vector<Ch, A>::clear();
 
 
699
        resize(str.elements);
 
 
700
        Tr::copy( vector<Ch, A>::data, str.vector<Ch, A>::data, str.elements);
 
 
705
template<class Ch,class Tr,class A> _UCXXEXPORT typename basic_string<Ch,Tr,A>::size_type
 
 
706
        basic_string<Ch,Tr,A>::find (const basic_string<Ch,Tr,A>& str, size_type pos) const
 
 
708
        if(str.length() > length()){
 
 
711
        size_type max_string_start = 1 + length() - str.length();
 
 
712
        for(size_type i = pos; i < max_string_start; ++i){
 
 
713
                if(str == substr(i, str.length())){
 
 
721
template<class Ch,class Tr,class A>
 
 
722
        _UCXXEXPORT basic_string<Ch, Tr, A> basic_string<Ch,Tr,A>::substr(size_type pos, size_type n) const
 
 
724
        if(pos > vector<Ch, A>::elements){
 
 
725
                __throw_out_of_range();
 
 
727
        size_type rlen = vector<Ch, A>::elements - pos;
 
 
731
        return basic_string<Ch,Tr,A>(vector<Ch, A>::data + pos,rlen);
 
 
737
#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__
 
 
738
#ifndef __UCLIBCXX_COMPILE_STRING__
 
 
740
#ifdef __UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS__
 
 
742
        template <> _UCXXEXPORT string::basic_string(const allocator<char> &);
 
 
743
        template <> _UCXXEXPORT string::basic_string(size_type n, char c, const allocator<char> & );
 
 
744
        template <> _UCXXEXPORT string::basic_string(const char* s, const allocator<char>& al);
 
 
745
        template <> _UCXXEXPORT string::basic_string(const basic_string& str, size_type pos, size_type n, const allocator<char>& al);
 
 
746
        template <> _UCXXEXPORT string::~basic_string();
 
 
750
        template <> _UCXXEXPORT string & string::append(const char * s, size_type n);
 
 
753
        template <> _UCXXEXPORT string::size_type string::find(const string & str, size_type pos) const;
 
 
754
        template <> _UCXXEXPORT string::size_type string::find(const char* s, size_type pos) const;
 
 
755
        template <> _UCXXEXPORT string::size_type string::find (char c, size_type pos) const;
 
 
757
        template <> _UCXXEXPORT string::size_type string::rfind(const string & str, size_type pos) const;
 
 
758
        template <> _UCXXEXPORT string::size_type string::rfind(char c, size_type pos) const;
 
 
759
        template <> _UCXXEXPORT string::size_type string::rfind(const char* s, size_type pos) const;
 
 
761
        template <> _UCXXEXPORT string::size_type string::find_first_of(const string &, size_type) const;
 
 
762
        template <> _UCXXEXPORT string::size_type string::find_first_of(const char *, size_type pos, size_type n) const;
 
 
763
        template <> _UCXXEXPORT string::size_type string::find_first_of(const char*, size_type pos) const;
 
 
764
        template <> _UCXXEXPORT string::size_type string::find_first_of(char c, size_type pos) const;
 
 
766
        template <> _UCXXEXPORT string::size_type string::find_last_of (const string & , size_type pos) const;
 
 
767
        template <> _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos, size_type n) const;
 
 
768
        template <> _UCXXEXPORT string::size_type string::find_last_of (const char* s, size_type pos) const;
 
 
769
        template <> _UCXXEXPORT string::size_type string::find_last_of (char c, size_type pos) const;
 
 
771
        template <> _UCXXEXPORT string::size_type string::find_first_not_of(const string &, size_type) const;
 
 
772
        template <> _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type, size_type) const;
 
 
773
        template <> _UCXXEXPORT string::size_type string::find_first_not_of(const char*, size_type) const;
 
 
774
        template <> _UCXXEXPORT string::size_type string::find_first_not_of(char c, size_type) const;
 
 
776
        template <> _UCXXEXPORT int string::compare(const string & str) const;
 
 
777
        template <> _UCXXEXPORT int string::compare(
 
 
778
                size_type pos1, size_type n1, const string & str, size_type pos2, size_type n2) const;
 
 
780
        template <> _UCXXEXPORT string string::substr(size_type pos, size_type n) const;
 
 
782
        template <> _UCXXEXPORT string & string::operator=(const string & str);
 
 
783
        template <> _UCXXEXPORT string & string::operator=(const char * s);
 
 
791
//typedef basic_string<char> string;
 
 
793
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_string<charT,traits,Allocator> 
 
 
794
        operator+(const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
796
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
801
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_string<charT,traits,Allocator>
 
 
802
        operator+(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
804
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
810
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_string<charT,traits,Allocator>
 
 
811
        operator+(charT lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
813
        basic_string<charT,traits,Allocator> temp(1, lhs);
 
 
818
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_string<charT,traits,Allocator>
 
 
819
        operator+(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs)
 
 
821
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
826
template<class charT, class traits, class Allocator> _UCXXEXPORT basic_string<charT,traits,Allocator>
 
 
827
        operator+(const basic_string<charT,traits,Allocator>& lhs, charT rhs)
 
 
829
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
834
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
835
        operator==(const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
837
        if(lhs.compare(rhs) == 0){
 
 
843
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
844
        operator==(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
846
        if(rhs.compare(lhs) == 0){
 
 
852
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
853
        operator==(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs)
 
 
855
        if(lhs.compare(rhs)==0){
 
 
861
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
862
        operator!=(const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
864
        if(lhs.compare(rhs) !=0){
 
 
870
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
871
        operator!=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
873
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
874
        return (temp != rhs);
 
 
877
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
878
        operator!=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs)
 
 
880
        basic_string<charT,traits,Allocator> temp(rhs);
 
 
881
        return (lhs != temp);
 
 
884
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
885
        operator< (const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
887
        if(lhs.compare(rhs) < 0){
 
 
893
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
894
        operator< (const basic_string<charT,traits,Allocator>& lhs, const charT* rhs)
 
 
896
        basic_string<charT,traits,Allocator> temp(rhs);
 
 
897
        if(lhs.compare(rhs) < 0){
 
 
903
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
904
        operator< (const charT* lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
906
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
907
        if(temp.compare(rhs) < 0){
 
 
914
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
915
        operator> (const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
917
        if(lhs.compare(rhs) > 0){
 
 
923
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
924
        operator> (const basic_string<charT,traits,Allocator>& lhs, const charT* rhs)
 
 
926
        basic_string<charT,traits,Allocator> temp(rhs);
 
 
927
        if(lhs.compare(rhs) > 0){
 
 
933
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
934
        operator> (const charT* lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
936
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
937
        if(temp.compare(rhs) > 0){
 
 
943
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
944
        operator<=(const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
946
        if(lhs.compare(rhs) <=0){
 
 
952
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
953
        operator<=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs)
 
 
955
        basic_string<charT,traits,Allocator> temp(rhs);
 
 
956
        if(lhs.compare(temp) <=0 ){
 
 
962
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
963
        operator<=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
965
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
966
        if(temp.compare(rhs) <= 0){
 
 
972
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
973
        operator>=(const basic_string<charT,traits,Allocator>& lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
975
        if(lhs.compare(rhs) >=0){
 
 
981
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
982
        operator>=(const basic_string<charT,traits,Allocator>& lhs, const charT* rhs)
 
 
984
        basic_string<charT,traits,Allocator> temp(rhs);
 
 
985
        if(lhs.compare(temp) >=0 ){
 
 
991
template<class charT, class traits, class Allocator> _UCXXEXPORT bool 
 
 
992
        operator>=(const charT* lhs, const basic_string<charT,traits,Allocator>& rhs)
 
 
994
        basic_string<charT,traits,Allocator> temp(lhs);
 
 
995
        if(temp.compare(rhs) >=0 ){
 
 
1001
template<class charT, class traits, class Allocator> _UCXXEXPORT void 
 
 
1002
        swap(basic_string<charT,traits,Allocator>& lhs, basic_string<charT,traits,Allocator>& rhs)
 
 
1007
/*template<class charT, class traits, class Allocator> _UCXXEXPORT basic_ostream<charT, traits>&
 
 
1008
        operator<<(basic_ostream<charT, traits>& os, const basic_string<charT,traits,Allocator>& str)
 
 
1010
        return os.write(str.data(), str.length());
 
 
1013
#ifdef __UCLIBCXX_EXPAND_STRING_CHAR__
 
 
1014
#ifndef __UCLIBCXX_COMPILE_STRING__
 
 
1016
//Operators we can avoid duplication of
 
 
1018
template <> _UCXXEXPORT bool operator==(const string & lhs, const string & rhs);
 
 
1019
template <> _UCXXEXPORT bool operator==(const char * lhs, const string & rhs);
 
 
1020
template <> _UCXXEXPORT bool operator==(const string & lhs, const char * rhs);
 
 
1022
template <> _UCXXEXPORT bool operator!=(const string & lhs, const string & rhs);
 
 
1023
template <> _UCXXEXPORT bool operator!=(const char * lhs, const string & rhs);
 
 
1024
template <> _UCXXEXPORT bool operator!=(const string & lhs, const char * rhs);
 
 
1026
template <> _UCXXEXPORT string operator+(const string & lhs, const char* rhs);
 
 
1027
template <> _UCXXEXPORT string operator+(const char* lhs, const string & rhs);
 
 
1028
template <> _UCXXEXPORT string operator+(const string & lhs, const string & rhs);
 
 
1030
template <> _UCXXEXPORT bool operator> (const string & lhs, const string & rhs);
 
 
1031
template <> _UCXXEXPORT bool operator< (const string & lhs, const string & rhs);
 
 
1040
#pragma GCC visibility pop