5 #ifndef CMR_STRING_INCLUDED
6 #define CMR_STRING_INCLUDED
42 friend class Iterator;
65 enum { STRING_INCREMENT_SIZE = 16 };
122 String& operator = (
Char c) { assign_helper(c, 1);
return *
this; }
141 bool operator != (
const AChar* str)
const {
return !compare(str) == 0; }
145 bool operator != (
const String& str)
const {
return !compare(str) == 0; }
149 bool operator != (
const Char* str)
const {
return !compare(str) == 0; }
162 String& operator += (
const Char* str) {
return append(str); }
170 String& operator += (
Char c) { append_helper(c, 1);
return *
this; }
174 String& operator += (
AChar c) { append_helper(c, 1);
return *
this; }
183 inline bool operator > (
const String& s)
const;
191 append_helper(str, 0, (
size_t)
npos);
203 append_helper(str, pos, n);
213 append_helper(str, n);
223 append_helper(str, n);
232 append_helper(str, length(str));
241 append_helper(str, length(str));
272 if (*len > (s - pos))
290 assign_helper(str.data_->
data + pos, n);
299 assign_helper(str, n);
307 assign_helper(str, length(str));
323 assign_helper(str, n);
331 assign_helper(str, length(str));
359 replace_helper(pos1, 0, str, 0, (
size_t)
npos);
371 replace_helper(pos1, 0, str, pos2, n);
382 replace_helper(pos, 0, str, n);
392 replace_helper(pos, 0, str, length(str));
403 replace_helper(pos, 0, c, n);
423 replace_helper(pos, n, (
const Char*)0, 0);
435 replace_helper(pos1, n1, str, 0, str.
size());
449 replace_helper(pos1, n1, str, pos2, n2);
461 replace_helper(pos, n1, str, n2);
472 replace_helper(pos, n1, str, length(str));
484 replace_helper(pos, n1, c, n2);
494 return pos == size() ? eos() : get_at(pos);
505 return *(data_->data + pos);
526 return operator[](pos);
535 return data_ ? data_->data : nil_data();
549 return data_ ? data_->data : nil_data();
578 return (
size_t)
npos - 1;
607 return data_->capacity;
615 reserve_helper(size);
628 size_t copy(
Char* str,
size_t n,
size_t pos = 0)
const
630 if (validate_range(pos, &n))
632 copy(str, data_->data + pos, n);
657 return find(str.
data(), pos, str.
size());
659 size_t find(
const Char* s,
size_t pos,
size_t n)
const;
662 return find(str, pos, length(str));
666 return find(&c, pos, 1);
670 return find_first_of(str.
data(), pos, str.
size());
672 size_t find_first_of(
const Char* s,
size_t pos,
size_t n)
const;
675 return find_first_of(str, pos, length(str));
679 return find_first_of(&c, pos, 1);
683 return find_first_not_of(str.
data(), pos, str.
size());
685 size_t find_first_not_of(
const Char* s,
size_t pos,
size_t n)
const;
688 return find_first_not_of(&c, pos, 1);
692 return find_first_not_of(str, pos, length(str));
694 size_t rfind(
const Char* str,
size_t pos,
size_t n)
const;
695 size_t find_last_of(
const Char* s,
size_t pos,
size_t n)
const;
696 size_t find_last_not_of(
const Char* s,
size_t pos,
size_t n)
const;
699 return rfind(str.
data(), pos, str.
size());
703 return rfind(str, pos, length(str));
707 return rfind(&c, pos, 1);
711 return find_last_of(str.
data(), pos, str.
size());
715 return find_last_of(&c, pos, 1);
719 return find_last_of(str, pos, length(str));
723 return find_last_not_of(str.
data(), pos, str.
size());
727 return find_last_not_of(&c, pos, 1);
731 return find_last_not_of(str, pos, length(str));
733 String substr(
size_t pos = 0,
size_t n = (
size_t)
npos)
const;
736 return compare_helper(str, 0, (
size_t)
npos);
740 return compare_helper(str, pos, n);
742 int compare(
size_t pos1,
size_t n1,
const String& str,
size_t pos2,
size_t n2)
const
744 String temp(str, pos2, n2);
745 return compare_helper(temp, pos1, n1);
749 return compare_helper(s, 0, length(s));
753 return compare_helper(s, 0, length(s));
755 int compare(
size_t pos,
size_t n1,
const Char* str,
size_t n2 = (
size_t)
npos)
const;
759 return icompare_helper(str, 0, (
size_t)
npos);
763 return icompare_helper(str, pos, n);
765 int icompare(
size_t pos1,
size_t n1,
const String& str,
size_t pos2,
size_t n2)
const
767 String temp(str, pos2, n2);
768 return icompare_helper(temp, pos1, n1);
772 return icompare_helper(s, 0, length(s));
776 return icompare_helper(s, 0, length(s));
778 int icompare(
size_t pos,
size_t n1,
const Char* str,
size_t n2 = (
size_t)
npos)
const;
783 bool match(
const String& pattern,
785 bool match(
const String& pattern,
787 bool match(
const String& pattern,
789 bool match(
const String& pattern,
791 bool match(
const String& pattern,
794 bool match(
const String& pattern,
797 bool match(
const String& pattern,
801 bool match(
const String& pattern,
816 static int compare(
const Char* s1,
const Char* s2,
size_t n);
817 static int compare(
const Char* s1,
const AChar* s2,
size_t n);
818 static int icompare(
const Char* s1,
const Char* s2,
size_t n);
819 static const Char* find(
const Char* s,
int n,
const Char& a);
820 static size_t length(
const Char* s);
821 static size_t length(
const AChar* s);
822 static Char* copy(
Char* dest,
const Char* src,
size_t n);
824 static Char* move(
Char* dest,
const Char* src,
size_t n);
825 static Char* assign(
Char* dest,
size_t n,
const Char& c);
842 static bool ieq(
const Char& c1,
const Char& c2);
847 static bool ilt(
const Char& c1,
const Char& c2);
856 String& append(
Char c,
size_t n = 1)
862 const Char& get_at(
size_t pos)
const
866 return *(data_->data + pos);
869 void put_at(
size_t pos,
Char c);
871 void assign_helper(
const Char* data,
size_t n);
872 void assign_helper(
const AChar* data,
size_t n);
873 void assign_helper(
Char c,
size_t n);
875 void replace_helper(
size_t pos,
size_t n1,
const Char* s,
size_t n2);
876 void replace_helper(
size_t pos,
size_t n1,
Char c,
size_t n2);
877 void replace_helper(
size_t pos,
size_t n1,
const String& str,
size_t pos2,
size_t n2)
879 str.validate_range(pos2, &n2);
880 replace_helper(pos, n1, str.data_->data + pos2, n2);
883 void append_helper(
const String& str,
size_t pos,
size_t n)
885 str.validate_range(pos, &n);
886 append_helper(str.data_->data + pos, n);
889 void append_helper(
const Char* s,
size_t n);
890 void append_helper(
Char c,
size_t n);
892 void append_helper(
const AChar* s,
size_t n);
893 void append_helper(
AChar c,
size_t n);
895 int compare_helper(
const String& str,
size_t pos,
size_t n)
const;
896 int compare_helper(
const Char* s,
size_t pos,
size_t n)
const;
897 int compare_helper(
const AChar* s,
size_t pos,
size_t n)
const;
899 int icompare_helper(
const String& str,
size_t pos,
size_t n)
const;
900 int icompare_helper(
const Char* s,
size_t pos,
size_t n)
const;
902 void reserve_helper(
size_t capacity);
903 void resize_helper(
size_t new_count,
Char fill_char);
905 Char* allocate(
size_t count);
906 void reallocate(
size_t count);
909 if (n <= data_->capacity)
912 data_->data[ data_->size ] = eos();
917 static Char* nil_data();
926 PAllocator allocator_;
String & insert(size_t pos1, const String &str)
Definition: String.h:357
size_t find_first_of(const Char *str, size_t pos=0) const
Definition: String.h:673
String & append(const AChar *str)
Definition: String.h:239
int icompare(size_t pos1, size_t n1, const String &str, size_t pos2, size_t n2) const
Definition: String.h:765
void resize(size_t n)
Definition: String.h:598
String operator+(const String &str) const
Definition: String.h:940
bool validate_range(size_t pos, size_t *len) const
Definition: String.h:263
static bool ine(const Char &c1, const Char &c2)
Definition: String.h:843
String & insert(size_t pos, const Char *str)
Definition: String.h:390
Char * pointer
Definition: String.h:62
String & append(const Char *str, size_t n)
Definition: String.h:211
size_t find_last_not_of(const Char &c, size_t pos=(size_t) npos) const
Definition: String.h:725
long CMREXD write_xml(const AString &sIn, OBStream &o)
Definition: AString.cpp:27
size_t find_first_not_of(const String &str, size_t pos=0) const
Definition: String.h:681
size_t find_last_of(Char c, size_t pos=(size_t) npos) const
Definition: String.h:713
bool operator<(const String &s) const
Definition: String.h:931
bool read(IBStream &str, int &num)
Definition: Time.cpp:200
void swap(C &c1, C &c2)
Definition: Commore.h:29
const Char * const_pointer
Definition: String.h:63
const Char & const_reference
Definition: String.h:61
Char & at(size_t pos)
Definition: String.h:524
int compare(size_t pos, size_t n, const String &str) const
Definition: String.h:738
int compare(const Char *s) const
Definition: String.h:747
const PAllocator & get_allocator() const
Definition: String.h:554
int icompare(const String &str) const
Definition: String.h:757
size_t find(const String &str, size_t pos=0) const
Find content in string Searches the string for the first occurrence of the sequence specified by its ...
Definition: String.h:655
String & append(const AChar *str, size_t n)
Definition: String.h:221
String & assign(const AChar *str, size_t n)
Definition: String.h:321
void resize(size_t n, Char c)
Definition: String.h:591
String & append(const String &str)
Definition: String.h:189
size_t find_last_not_of(const Char *str, size_t pos=(size_t) npos) const
Definition: String.h:729
const Char * data() const
Definition: String.h:547
size_t find_last_not_of(const String &str, size_t pos=(size_t) npos) const
Definition: String.h:721
char AChar
Definition: Type.h:65
CMREXD void DecodeFromUTF8(const commore::AString &source, commore::String &dest)
Definition: String.cpp:1046
String & insert(size_t pos, size_t n, Char c)
Definition: String.h:401
#define CMREXD
Definition: Compiler.h:22
size_t rfind(const Char *str, size_t pos=(size_t) npos) const
Definition: String.h:701
static bool lt(const Char &c1, const Char &c2)
Definition: String.h:838
Char & operator[](size_t pos)
Definition: String.h:501
size_t max_size() const
Definition: String.h:576
static bool eq(const Char &c1, const Char &c2)
Definition: String.h:830
size_t size
Definition: String.h:23
size_t size_type
Definition: String.h:59
String & erase(size_t pos=0, size_t n=(size_t) npos)
Definition: String.h:421
RawString * PRawString
Definition: String.h:33
void reserve(size_t size)
Definition: String.h:613
String & replace(size_t pos1, size_t n1, const String &str, size_t pos2, size_t n2)
Definition: String.h:447
size_t find_last_of(const String &str, size_t pos=(size_t) npos) const
Definition: String.h:709
static void assign(Char &c1, const Char &c2)
Definition: String.h:826
int icompare(size_t pos, size_t n, const String &str) const
Definition: String.h:761
String & replace(size_t pos, size_t n1, const Char *str, size_t n2)
Definition: String.h:459
size_t rfind(Char c, size_t pos=(size_t) npos) const
Definition: String.h:705
size_t find(Char c, size_t pos=0) const
Definition: String.h:664
int compare(const AChar *s) const
Definition: String.h:751
size_t find(const Char *str, size_t pos=0) const
Definition: String.h:660
bool operator==(const pair< T1, T2 > &x, const pair< T1, T2 > &y)
Definition: HMap.h:148
size_t size() const
Definition: String.h:569
size_t find_first_of(const String &str, size_t pos=0) const
Definition: String.h:668
String & replace(size_t pos, size_t n1, const Char *str)
Definition: String.h:470
CMREXD commore::OBStream & operator<<(commore::OBStream &o, const commore::String &s)
Definition: String.cpp:891
int compare(const String &str) const
Definition: String.h:734
String & append(size_t n, Char c)
Definition: String.h:250
String & append(const Char *str)
Definition: String.h:230
CMREXD bool FromUTF8(commore::String &so, const commore::AChar *si)
int strcmp(const Char *s1, const Char *s2)
size_t find_first_not_of(const Char *str, size_t pos=0) const
Definition: String.h:690
int compare(size_t pos1, size_t n1, const String &str, size_t pos2, size_t n2) const
Definition: String.h:742
TimeDate operator+(const TimePeriod &period, const TimeDate &time_and_date)
Definition: Time.h:477
Definition: CommBuffer.h:28
String & assign(const Char *str, size_t n)
Definition: String.h:297
String & insert(size_t pos1, const String &str, size_t pos2, size_t n)
Definition: String.h:369
int Int
Definition: Type.h:37
String & insert(size_t pos, const Char *str, size_t n)
Definition: String.h:380
const unsigned int npos
Definition: Type.h:197
int stricmp(const Char *s1, const Char *s2)
String & assign(const AChar *str)
Definition: String.h:329
Char operator[](size_t pos) const
Definition: String.h:492
long CMREXD read_xml(AString &sOut, IBStream &i)
Definition: AString.cpp:65
String & replace(size_t pos, size_t n1, size_t n2, Char c)
Definition: String.h:482
size_t find_first_not_of(Char c, size_t pos=0) const
Definition: String.h:686
int icompare(const AChar *s) const
Definition: String.h:774
String & assign(const Char *str)
Definition: String.h:305
size_t copy(Char *str, size_t n, size_t pos=0) const
Copy sequence of characters from string Copies a substring of the current value of the string object ...
Definition: String.h:628
bool operator<(const pair< T1, T2 > &x, const pair< T1, T2 > &y)
Definition: HMap.h:155
String & assign(size_t n, Char c)
Definition: String.h:313
size_t find_last_of(const Char *str, size_t pos=(size_t) npos) const
Definition: String.h:717
CMREXD void EncodeToUTF8(const commore::String &source, commore::AString &dest)
Definition: String.cpp:1007
size_t capacity() const
Definition: String.h:605
Char value_type
Definition: String.h:58
Definition: IOBStream.h:166
virtual ~Allocator()
Definition: String.h:48
static bool ne(const Char &c1, const Char &c2)
Definition: String.h:834
Allocator * PAllocator
Definition: String.h:55
bool empty() const
Definition: String.h:583
Definition: IOBStream.h:29
String & clear()
Definition: String.h:410
Char at(size_t pos) const
Definition: String.h:516
String & append(const String &str, size_t pos, size_t n)
Definition: String.h:201
Char & reference
Definition: String.h:60
size_t find_first_of(Char c, size_t pos=0) const
Definition: String.h:677
size_t rfind(const String &str, size_t pos=(size_t) npos) const
Definition: String.h:697
Char data[4]
Definition: String.h:31
String & replace(size_t pos1, size_t n1, const String &str)
Definition: String.h:433
bool operator>(const String &s) const
Definition: String.h:935
static Char eos()
Definition: String.h:812
const Char * c_str() const
Definition: String.h:533
size_t length() const
Definition: String.h:562
String & assign(const String &str, size_t pos, size_t n)
Definition: String.h:286
CMREXD int init()
Definition: Commore.cpp:17
size_t capacity
Definition: String.h:27
wchar_t Char
Definition: Type.h:66
String & assign(size_t n, AChar c)
Definition: String.h:337
int icompare(const Char *s) const
Definition: String.h:770