6 #ifndef CMR_ASTRING_INCLUDED
7 #define CMR_ASTRING_INCLUDED
41 friend class Iterator;
58 AString(
const AChar* str,
size_t n);
83 AString(
const void* v,
size_t n,
size_t base = 16);
111 operator const AChar* ()
const
119 typedef AChar value_type;
120 typedef size_t size_type;
121 typedef AChar& reference;
122 typedef const AChar& const_reference;
123 typedef AChar* pointer;
124 typedef const AChar* const_pointer;
126 enum { STRING_INCREMENT_SIZE = 16 };
134 return compare(str) == 0;
139 bool operator == (
const AChar* str)
const
141 return compare(str) == 0;
148 return !compare(str) == 0;
153 bool operator != (
const AChar* str)
const
155 return !compare(str) == 0;
162 return compare(str) < 0;
169 return compare(str) > 0;
204 append_helper(str, 0, (
size_t)npos);
216 append_helper(str, pos, n);
226 append_helper(str, n);
235 append_helper(str, length(str));
266 if (*len > (s - pos))
284 assign_helper(str.data_->
data + pos, n);
293 assign_helper(str, n);
301 assign_helper(str, length(str));
329 replace_helper(pos1, 0, str, 0, (
size_t)npos);
341 replace_helper(pos1, 0, str, pos2, n);
352 replace_helper(pos, 0, str, n);
362 replace_helper(pos, 0, str, length(str));
373 replace_helper(pos, 0, c, n);
392 replace_helper(pos, n, (
const AChar*)0, 0);
398 void Delete(
size_t pos = 0,
size_t n = 1)
400 replace_helper(pos, n, (
const AChar*)0, 0);
410 replace_helper(pos1, n, str, 0, str.
size());
424 replace_helper(pos1, n1, str, pos2, n2);
436 replace_helper(pos1, n1, str, n2);
447 replace_helper(pos, n1, str, length(str));
459 replace_helper(pos, n1, c, n2);
467 AString& replace(
const AChar* s1,
const AChar* s2,
bool case_sensitive =
true);
473 return replace(s1, s2, case_sensitive);
482 return pos == size() ? eos() : get_at(pos);
492 return *(data_->data + pos);
505 return pos == (int)size() ? eos() : get_at((
size_t)pos);
513 if (pos < (
int)size())
515 return *(data_->data + pos);
525 AChar
at(
size_t pos)
const
533 AChar&
at(
size_t pos)
535 return operator[](pos);
544 return data_ ? data_->data : nil_data();
551 return data_ ? data_->data : nil_data();
578 return (
size_t)npos - 1;
602 void resize(
size_t n)
619 return data_->capacity;
634 reserve_helper(size);
645 return allocate(size);
656 size_t copy(AChar* str,
size_t n,
size_t pos = 0)
const
658 if (validate_range(pos, &n))
660 copy(str, data_->data + pos, n);
684 size_t find(
const AChar* s,
size_t pos,
size_t n)
const;
685 size_t find(
const AChar* str,
size_t pos = 0)
const {
return find(str, pos, length(str)); }
686 size_t find(AChar c,
size_t pos = 0)
const {
return find(&c, pos, 1); }
687 size_t find_first_of(
const AString& str,
size_t pos = 0)
const {
return find_first_of(str.data(), pos, str.size()); }
688 size_t find_first_of(
const AChar* s,
size_t pos,
size_t n)
const;
689 size_t find_first_of(
const AChar* str,
size_t pos = 0)
const {
return find_first_of(str, pos, length(str)); }
690 size_t find_first_of(AChar c,
size_t pos = 0)
const {
return find_first_of(&c, pos, 1); }
691 size_t find_first_not_of(
const AString& str,
size_t pos = 0)
const {
return find_first_not_of(str.data(), pos, str.size()); }
692 size_t find_first_not_of(
const AChar* s,
size_t pos,
size_t n)
const;
693 size_t find_first_not_of(AChar c,
size_t pos = 0)
const {
return find_first_not_of(&c, pos, 1); }
694 size_t find_first_not_of(
const AChar* str,
size_t pos = 0)
const {
return find_first_not_of(str, pos, length(str)); }
695 size_t rfind(
const AChar* str,
size_t pos,
size_t n)
const;
696 size_t find_last_of(
const AChar* s,
size_t pos,
size_t n)
const;
697 size_t find_last_not_of(
const AChar* s,
size_t pos,
size_t n)
const;
698 size_t rfind(
const AString& str,
size_t pos = (
size_t)npos)
const {
return rfind(str.data(), pos, str.size()); }
699 size_t rfind(
const AChar* str,
size_t pos = (
size_t)npos)
const {
return rfind(str, pos, length(str)); }
700 size_t rfind(AChar c,
size_t pos = (
size_t)npos)
const {
return rfind(&c, pos, 1); }
701 size_t find_last_of(
const AString& str,
size_t pos = (
size_t)npos)
const {
return find_last_of(str.data(), pos, str.size()); }
702 size_t find_last_of(AChar c,
size_t pos = (
size_t)npos)
const {
return find_last_of(&c, pos, 1); }
703 size_t find_last_of(
const AChar* str,
size_t pos = (
size_t)npos)
const {
return find_last_of(str, pos, length(str)); }
704 size_t find_last_not_of(
const AString& str,
size_t pos = (
size_t)npos)
const {
return find_last_not_of(str.data(), pos, str.size()); }
705 size_t find_last_not_of(
const AChar& c,
size_t pos = (
size_t)npos)
const {
return find_last_not_of(&c, pos, 1); }
706 size_t find_last_not_of(
const AChar* str,
size_t pos = (
size_t)npos)
const {
return find_last_not_of(str, pos, length(str)); }
716 AString substr(
size_t pos = 0,
size_t n = (
size_t)npos)
const;
739 int compare(
const AString& str)
const {
return compare_helper(str, 0, (
size_t)npos); }
740 int compare(
size_t pos,
size_t n,
const AString& str)
const {
return compare_helper(str, pos, n); }
741 int compare(
size_t pos1,
size_t n1,
const AString& str,
size_t pos2,
size_t n2)
const
743 AString temp(str, pos2, n2);
744 return compare_helper(temp, pos1, n1);
746 int compare(
const AChar* s)
const
748 return compare_helper(s, 0, length(s));
750 int compare(
size_t pos,
size_t n1,
const AChar* str,
size_t n2 = (
size_t)npos)
const;
759 return icompare_helper(str, 0, (
size_t)npos);
761 int icompare(
size_t pos,
size_t n,
const AString& str)
const
763 return icompare_helper(str, pos, n);
765 int icompare(
size_t pos1,
size_t n1,
const AString& str,
size_t pos2,
size_t n2)
const
767 AString temp(str, pos2, n2);
768 return icompare_helper(temp, pos1, n1);
770 int icompare(
const AChar* s)
const
772 return icompare_helper(s, 0, length(s));
774 int icompare(
size_t pos,
size_t n1,
const AChar* str,
size_t n2 = (
size_t)npos)
const;
778 return icompare_helper(s, 0, length(s));
805 bool match(
const AString& pattern)
const;
839 static int compare(
const AChar* s1,
const AChar* s2,
size_t n);
843 static int icompare(
const AChar* s1,
const AChar* s2,
size_t n);
847 static const AChar* find(
const AChar* s,
int n,
const AChar& a);
851 static size_t length(
const AChar* s);
856 static AChar* copy(AChar* dest,
const AChar* src,
size_t n);
861 static AChar* move(AChar* dest,
const AChar* src,
size_t n);
865 static AChar* assign(AChar* dest,
size_t n,
const AChar& c);
866 static void assign(AChar& c1,
const AChar& c2)
870 static bool eq(
const AChar& c1,
const AChar& c2)
874 static bool ne(
const AChar& c1,
const AChar& c2)
878 static bool lt(
const AChar& c1,
const AChar& c2)
882 static bool ieq(
const AChar& c1,
const AChar& c2);
883 static bool ine(
const AChar& c1,
const AChar& c2)
887 static bool ilt(
const AChar& c1,
const AChar& c2);
890 AString& assign(AChar c,
size_t n = 1)
896 AString& append(AChar c,
size_t n = 1)
902 const AChar& get_at(
size_t pos)
const
906 return *(data_->data + pos);
910 return *(
const AChar*)0;
914 void put_at(
size_t pos, AChar c);
916 void assign_helper(
const AChar* data,
size_t n);
917 void assign_helper(AChar c,
size_t n);
918 void replace_helper(
size_t pos,
size_t n1,
const AChar* s,
size_t n2);
919 void replace_helper(
size_t pos,
size_t n1, AChar c,
size_t n2);
920 void replace_helper(
size_t pos,
size_t n1,
const AString& str,
size_t pos2,
size_t n2);
921 void append_helper(
const AString& str,
size_t pos,
size_t n);
922 void append_helper(
const AChar* s,
size_t n);
923 void append_helper(AChar c,
size_t n);
925 int compare_helper(
const AString& str,
size_t pos,
size_t n)
const;
926 int compare_helper(
const AChar* s,
size_t pos,
size_t n)
const;
928 int icompare_helper(
const AString& str,
size_t pos,
size_t n)
const;
929 int icompare_helper(
const AChar* s,
size_t pos,
size_t n)
const;
931 void reserve_helper(
size_t capacity);
932 void resize_helper(
size_t new_count, AChar fill_char);
934 AChar* allocate(
size_t count);
935 void reallocate(
size_t count);
942 void assign_(PRawAString& dest, PRawAString src);
943 PRawAString reallocate_nocopy_(PRawAString p,
size_t new_size);
944 PRawAString allocate_(
size_t size);
945 void release_(PRawAString p);
946 PRawAString reallocate_(PRawAString p,
size_t new_size);
952 static AChar* nil_data();
954 AString& Format(
const AChar* format, ...);
957 long CMREXD read_xml(AString& sOut, IBStream& i);
958 long CMREXD write_xml(
const AString& sIn, OBStream& o);
959 AString CMREXD create_guid();
960 AString CMREXD create_cmr_guid();
AChar operator[](int pos) const
Definition: AString.h:503
AString & insert(size_t pos1, const AString &str, size_t pos2, size_t n)
Definition: AString.h:339
size_t capacity
Definition: AString.h:26
void Delete(size_t pos=0, size_t n=1)
Definition: AString.h:398
AString & MakeLower()
Definition: AString.h:795
AString & replace(size_t pos, size_t n1, size_t n2, AChar c)
Definition: AString.h:457
AString & erase(size_t pos=0, size_t n=(size_t) npos)
Definition: AString.h:390
AChar operator[](size_t pos) const
Definition: AString.h:480
const AChar * data() const
Definition: AString.h:549
AString & Replace(const AChar *s1, const AChar *s2, bool case_sensitive=true)
Definition: AString.h:471
AString & replace(size_t pos1, size_t n, const AString &str)
Definition: AString.h:408
AString & insert(size_t pos1, const AString &str)
Definition: AString.h:327
AString & append(const AString &str, size_t pos, size_t n)
Definition: AString.h:214
AString & append(size_t n, AChar c)
Definition: AString.h:244
size_t length() const
Definition: AString.h:566
bool is_empty() const
Definition: AString.h:583
bool validate_range(size_t pos, size_t *len) const
Definition: AString.h:257
size_t max_size() const
Definition: AString.h:576
size_t capacity() const
Return size of allocated storage.
Definition: AString.h:617
AChar & operator[](int pos)
Definition: AString.h:511
AString & insert(size_t pos, const AChar *str)
Definition: AString.h:360
void resize(size_t n, AChar c)
Definition: AString.h:598
AString & append(const AChar *str)
Definition: AString.h:233
int compare(const AString &str) const
Compare string.
Definition: AString.h:739
char * set_buffer(size_t size)
Definition: AString.h:643
size_t find(const AString &str, size_t pos=0) const
Find content in string Searches the string for the first occurrence of the sequence specified by its ...
Definition: AString.h:683
const AChar * c_str() const
Definition: AString.h:542
AString & clear()
Definition: AString.h:380
size_t copy(AChar *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: AString.h:656
AString & assign(const AChar *str)
Definition: AString.h:299
int icompare(const AString &str) const
Compare string but do not care caracter case (acii charecter only)
Definition: AString.h:757
int CompareNoCase(const AChar *s) const
Definition: AString.h:776
AString & replace(size_t pos, size_t n1, const AChar *str)
Definition: AString.h:445
AString & insert(size_t pos, const AChar *str, size_t n)
Definition: AString.h:350
static AChar eos()
Definition: AString.h:830
AString & append(const AChar *str, size_t n)
Definition: AString.h:224
AString & MakeUpper()
Definition: AString.h:792
AString & replace(size_t pos1, size_t n1, const AString &str, size_t pos2, size_t n2)
Definition: AString.h:422
void reserve(size_t size)
Request a change in capacity Requests that the string capacity be adapted to a planned change in size...
Definition: AString.h:632
AString & assign(size_t n, AChar c)
Definition: AString.h:307
size_t size() const
Definition: AString.h:559
AString & assign(const AChar *str, size_t n)
Definition: AString.h:291
AChar & operator[](size_t pos)
Definition: AString.h:488
size_t size
Definition: AString.h:22
AString & assign(const AString &str, size_t pos, size_t n)
Definition: AString.h:280
AChar & at(size_t pos)
Definition: AString.h:533
AChar data[4]
Definition: AString.h:30
Definition: IOBStream.h:166
AString & insert(size_t pos, size_t n, AChar c)
Definition: AString.h:371
AString & append(const AString &str)
Definition: AString.h:202
Definition: IOBStream.h:29
AString & replace(size_t pos1, size_t n1, const AChar *str, size_t n2)
Definition: AString.h:434
AChar at(size_t pos) const
Definition: AString.h:525