70 typedef std::size_t size_type;
71 typedef char_traits< Pt::Char > traits_type;
72 typedef std::allocator<Pt::Char> allocator_type;
73 typedef allocator_type::difference_type difference_type;
74 typedef allocator_type::reference reference;
75 typedef allocator_type::const_reference const_reference;
76 typedef allocator_type::pointer pointer;
77 typedef allocator_type::const_pointer const_pointer;
78 typedef value_type* iterator;
79 typedef const value_type* const_iterator;
81#ifdef _RWSTD_NO_CLASS_PARTIAL_SPEC
82 typedef std::reverse_iterator<const_iterator,
83 random_access_iterator_tag, value_type>
84 const_reverse_iterator;
86 typedef std::reverse_iterator<iterator,
87 random_access_iterator_tag, value_type>
90 typedef std::reverse_iterator<iterator> reverse_iterator;
91 typedef const std::reverse_iterator<const_iterator> const_reverse_iterator;
94 static const size_type npos =
static_cast<size_type
>(-1);
99 explicit String(
const allocator_type& a = allocator_type());
107 String(
const Pt::Char* str, size_type n,
const allocator_type& a = allocator_type());
111 String(
const wchar_t* str,
const allocator_type& a = allocator_type());
115 String(
const wchar_t* str, size_type n,
const allocator_type& a = allocator_type());
119 String(
const char* str,
const allocator_type& a = allocator_type());
123 String(
const char* str, size_type n,
const allocator_type& a = allocator_type());
139 String(
const String& str, size_type pos, size_type n = npos,
const allocator_type& a = allocator_type());
145 template <
typename InputIterator>
146 String(InputIterator
begin, InputIterator
end,
const allocator_type& a = allocator_type());
156 {
return privdata_rw(); }
161 {
return privdata_rw() +
length(); }
166 {
return privdata_ro(); }
170 const_iterator
end()
const
171 {
return privdata_ro() +
length(); }
176 {
return reverse_iterator( this->end() ); }
181 {
return reverse_iterator( this->begin() ); }
186 {
return const_reverse_iterator( this->end() ); }
190 const_reverse_iterator
rend()
const
191 {
return const_reverse_iterator( this->begin() ); }
196 {
return privdata_rw()[n]; }
201 {
return privdata_ro()[n]; }
205 reference
at(size_type n)
208 throw out_of_range(
"at");
210 return privdata_rw()[n];
215 const_reference
at(size_type n)
const
218 throw out_of_range(
"at");
220 return privdata_ro()[n];
253 {
return String(*
this, pos, n); }
259 {
return isShortString() ? shortStringLength() : longStringLength(); }
274 {
return ( size_type(-1) /
sizeof(
Pt::Char) ) - 1; }
279 {
return isShortString() ? shortStringCapacity() : longStringCapacity(); }
284 {
return privdata_ro(); }
289 {
return privdata_ro(); }
327 template <
typename InputIterator>
350 template <
typename InputIterator>
404 iterator
erase(iterator first, iterator last);
460 int compare(
const wchar_t* str, size_type n)
const;
468 int compare(
const char* str, size_type n)
const;
476 int compare(size_type pos, size_type n,
const String& str, size_type pos2, size_type n2)
const;
530 {
return this->
find_first_of( str, pos, traits_type::length(str) ); }
535 {
return this->
find(ch, pos); }
549 {
return this->
find_last_of( str, pos, traits_type::length(str) ); }
554 {
return this->
rfind(ch, pos); }
595 std::string
narrow(
char dfault =
'?')
const;
607 template <
typename OutIterT>
612 template <
typename InIterT>
619 {
return this->
assign(str); }
624 {
return this->
assign(str); }
629 {
return this->
assign(str); }
634 {
return this->
assign(str); }
651 {
return this->
append(str); }
656 {
return this->
append(str); }
671 static const unsigned _minN = (
sizeof(Ptr) /
sizeof(
Pt::Char)) + 1;
674 static const unsigned _nN = _minN < 8 ? 8 : _minN;
677 static const unsigned _nS = _nN *
sizeof(
Pt::Char);
679 struct Data :
public allocator_type
681 Data(
const allocator_type& a)
687 _u._s[_nS - 1] = _nN - 1;
693 unsigned char _s[_nS];
698 const Pt::Char* privdata_ro()
const
699 {
return isShortString() ? shortStringData() : longStringData(); }
701 Pt::Char* privdata_rw()
702 {
return isShortString() ? shortStringData() : longStringData(); }
704 void privreserve(std::size_t n);
706 bool isShortString()
const
707 {
return shortStringMagic() != 0xff; }
709 void markLongString()
710 { shortStringMagic() = 0xff; }
712 const Pt::Char* shortStringData()
const
713 {
return reinterpret_cast<const Pt::Char*
>(&_d._u._s[0]); }
715 Pt::Char* shortStringData()
716 {
return reinterpret_cast<Pt::Char*
>(&_d._u._s[0]); }
718 unsigned char shortStringMagic()
const
719 {
return _d._u._s[_nS - 1]; }
721 unsigned char& shortStringMagic()
722 {
return _d._u._s[_nS - 1]; }
724 size_type shortStringLength()
const
725 {
return _nN - 1 - shortStringMagic(); }
727 size_type shortStringCapacity()
const
730 void setShortStringLength(size_type n)
732 shortStringData()[n] = Pt::Char(0);
733 shortStringMagic() =
static_cast<unsigned char>(_nN - n - 1);
736 void shortStringAssign(
const Pt::Char* str, size_type n)
738 traits_type::copy(shortStringData(), str, n);
739 shortStringData()[n] = Pt::Char(0);
740 shortStringMagic() =
static_cast<unsigned char>(_nN - n - 1);
742 void shortStringAssign(
const wchar_t* str, size_type n)
744 for (size_type nn = 0; nn < n; ++nn)
745 shortStringData()[nn] = str[nn];
746 shortStringData()[n] = Pt::Char(0);
747 shortStringMagic() =
static_cast<unsigned char>(_nN - n - 1);
750 const Pt::Char* longStringData()
const
751 {
return _d._u._p._begin; }
753 Pt::Char* longStringData()
754 {
return _d._u._p._begin; }
756 size_type longStringLength()
const
757 {
return _d._u._p._end - _d._u._p._begin; }
759 size_type longStringCapacity()
const
760 {
return _d._u._p._capacity - _d._u._p._begin; }
762 void setLength(size_type n)
765 setShortStringLength(n);
768 _d._u._p._end = _d._u._p._begin + n;
769 _d._u._p._begin[n] = 0;
788{
String temp; temp += a; temp += b;
return temp; }
795{
String temp; temp += a; temp += b;
return temp; }
802{
String temp; temp += a; temp += b;
return temp; }
809{
String temp; temp += a; temp += b;
return temp; }
816{
String temp; temp += a; temp += b;
return temp; }
1128PT_API ostream& operator<< (ostream& out,
const String& str);
void swap(String &str)
Swaps with another string.
String(const char *str, size_type n, const allocator_type &a=allocator_type())
Constructor.
String & operator=(const String &str)
Assignment operator.
Definition Api-String.h:618
String & assign(const Pt::Char *str)
Assign content to the string.
const_reverse_iterator rend() const
Returns an reverse iterator to the begin of the string.
Definition Api-String.h:190
size_type find_last_not_of(const Pt::Char *str, size_type pos=npos) const
Find content in the string.
Definition Api-String.h:585
bool operator<=(const wchar_t *b, const String &a)
Compares two strings.
Definition Api-String.h:1005
size_type rfind(const Pt::Char *str, size_type pos, size_type n) const
Find content in the string.
size_type find_last_not_of(const Pt::Char *tok, size_type pos, size_type n) const
Find content in the string.
String & operator+=(const String &str)
Append a string.
Definition Api-String.h:650
bool operator<=(const char *b, const String &a)
Compares two strings.
Definition Api-String.h:1019
String & replace(iterator i1, iterator i2, const Pt::Char *str, size_type n)
Replace portion of the string.
size_type find_first_not_of(const Pt::Char *s, size_type pos, size_type n) const
Find content in the string.
bool operator!=(const String &a, const char *b)
Compares two strings.
Definition Api-String.h:910
void swap(String &a, String &b)
Swaps two strings.
Definition Api-String.h:778
String & insert(size_type pos, size_type n, Pt::Char ch)
Insert into string.
String & replace(iterator i1, iterator i2, const String &str)
Replace portion of the string.
String & assign(const wchar_t *str)
Assign content to the string.
String & assign(const wchar_t *str, size_type n)
Assign content to the string.
bool operator<(const String &a, const Pt::Char *b)
Compares two strings.
Definition Api-String.h:940
bool operator==(const char *b, const String &a)
Compares two strings.
Definition Api-String.h:866
bool operator<(const wchar_t *b, const String &a)
Compares two strings.
Definition Api-String.h:954
bool operator>(const Pt::Char *a, const String &b)
Compares two strings.
Definition Api-String.h:1035
bool operator<(const char *b, const String &a)
Compares two strings.
Definition Api-String.h:968
bool operator!=(const String &a, const String &b)
Compares two strings.
Definition Api-String.h:875
const_iterator begin() const
Returns an iterator to the begin of the string.
Definition Api-String.h:165
size_type rfind(const Pt::Char *str, size_type pos=npos) const
Find content in the string.
size_type find_first_not_of(const Pt::Char *str, size_type pos=0) const
Find content in the string.
Definition Api-String.h:567
bool operator>(const String &a, const char *b)
Compares two strings.
Definition Api-String.h:1063
String(const wchar_t *str, size_type n, const allocator_type &a=allocator_type())
Constructor.
bool operator<(const Pt::Char *a, const String &b)
Compares two strings.
Definition Api-String.h:933
size_type find(const Pt::Char *str, size_type pos=0) const
Find content in the string.
String(const String &str)
Copy Constructor.
int compare(const char *str, size_type n) const
Compare strings.
size_type find_last_not_of(const String &str, size_type pos=npos) const
Find content in the string.
Definition Api-String.h:576
String & replace(size_type pos, size_type n, size_type n2, Pt::Char ch)
Replace portion of the string.
String operator+(Pt::Char a, const String &b)
Concatenates two strings.
Definition Api-String.h:815
String & replace(size_type pos, size_type n, const String &str)
Replace portion of the string.
String & append(const Pt::Char *str, size_type n)
Append content to the string.
int compare(size_type pos, size_type n, const Pt::Char *str) const
Compare strings.
String & operator+=(Pt::Char c)
Append a character.
String(const Pt::Char *str, size_type n, const allocator_type &a=allocator_type())
Constructor.
bool operator>=(const char *b, const String &a)
Compares two strings.
Definition Api-String.h:1121
bool operator>(const String &a, const Pt::Char *b)
Compares two strings.
Definition Api-String.h:1042
int compare(const String &str) const
Compare strings.
void resize(std::size_t n, Pt::Char ch=value_type())
Resizes the string.
String & assign(const char *str)
Assign content to the string.
bool operator<=(const String &a, const String &b)
Compares two strings.
Definition Api-String.h:977
String(const Pt::Char *str, const allocator_type &a=allocator_type())
Constructor.
size_type find_first_not_of(const String &str, size_type pos=0) const
Find content in the string.
Definition Api-String.h:558
bool operator==(const String &a, const String &b)
Compares two strings.
Definition Api-String.h:824
size_type find_last_of(const String &str, size_type pos=npos) const
Find content in the string.
Definition Api-String.h:539
String(const Pt::Char *begin, const Pt::Char *end, const allocator_type &a=allocator_type())
Constructor.
String & insert(size_type pos, const Pt::Char *str)
Insert into string.
static String widen(const char *str)
Widen 8-bit string .
String & replace(iterator i1, iterator i2, const Pt::Char *str)
Replace portion of the string.
size_type find_first_of(const String &str, size_type pos=0) const
Find content in the string.
Definition Api-String.h:520
bool operator>=(const Pt::Char *a, const String &b)
Compares two strings.
Definition Api-String.h:1086
size_type rfind(Pt::Char ch, size_type pos=npos) const
Find content in the string.
size_type find(const String &str, size_type pos=0) const
Find content in the string.
size_type size() const
Returns the length of the string.
Definition Api-String.h:263
int compare(size_type pos, size_type n, const Pt::Char *str, size_type n2) const
Compare strings.
int compare(const wchar_t *str, size_type n) const
Compare strings.
bool empty() const
Returns true if empty.
Definition Api-String.h:268
bool operator<=(const Pt::Char *a, const String &b)
Compares two strings.
Definition Api-String.h:984
size_type find_last_of(const Pt::Char ch, size_type pos=npos) const
Find content in the string.
Definition Api-String.h:553
reverse_iterator rend()
Returns an reverse iterator to the begin of the string.
Definition Api-String.h:180
String & operator=(Pt::Char ch)
Assignment operator.
Definition Api-String.h:638
String operator+(const String &a, const Pt::Char *b)
Concatenates two strings.
Definition Api-String.h:794
String & insert(size_type pos, const String &str)
Insert into string.
allocator_type get_allocator() const
Returns the used allocator.
Definition Api-String.h:243
String & replace(size_type pos, size_type n, const String &str, size_type pos2, size_type n2)
Replace portion of the string.
bool operator>=(const String &a, const Pt::Char *b)
Compares two strings.
Definition Api-String.h:1093
size_type copy(Pt::Char *a, size_type n, size_type pos=0) const
Copy characters to a buffer.
int compare(size_type pos, size_type n, const String &str) const
Compare strings.
bool operator<(const String &a, const String &b)
Compares two strings.
Definition Api-String.h:926
size_type find_first_of(const Pt::Char *s, size_type pos, size_type n) const
Find content in the string.
std::string narrow(char dfault='?') const
Narrow string to 8-bit.
String operator+(const String &a, Pt::Char b)
Concatenates two strings.
Definition Api-String.h:808
bool operator>=(const String &a, const wchar_t *b)
Compares two strings.
Definition Api-String.h:1100
bool operator<=(const String &a, const char *b)
Compares two strings.
Definition Api-String.h:1012
void reserve(std::size_t n=0)
Reserves space.
String & replace(size_type pos, size_type n, const Pt::Char *str)
Replace portion of the string.
bool operator==(const String &a, const char *b)
Compares two strings.
Definition Api-String.h:859
String(const String &str, const allocator_type &a)
Constructor.
OutIterT toUtf16(OutIterT to) const
Convert to UTF-16.
String(const String &str, size_type pos, size_type n=npos, const allocator_type &a=allocator_type())
Constructor.
String & append(const String &str)
Append content to the string.
String(const char *str, const allocator_type &a=allocator_type())
Constructor.
int compare(const Pt::Char *str) const
Compare strings.
size_type find(Pt::Char ch, size_type pos=0) const
Find content in the string.
void push_back(Pt::Char ch)
Append a character.
Definition Api-String.h:226
bool operator!=(const Pt::Char *a, const String &b)
Compares two strings.
Definition Api-String.h:882
String & assign(const String &str)
Assign content to the string.
size_type max_size() const
Returns the maximum possible length.
Definition Api-String.h:273
const_reference at(size_type n) const
Random access to characters.
Definition Api-String.h:215
String & replace(size_type pos, size_type n, const Pt::Char *str, size_type n2)
Replace portion of the string.
int compare(size_type pos, size_type n, const String &str, size_type pos2, size_type n2) const
Compare strings.
static String widen(const std::string &str)
Widen 8-bit string .
bool operator!=(const char *b, const String &a)
Compares two strings.
Definition Api-String.h:917
String & assign(const String &str, size_type pos, size_type n)
Assign content to the string.
String & append(const Pt::Char *begin, const Pt::Char *end)
Append content to the string.
bool operator<(const String &a, const char *b)
Compares two strings.
Definition Api-String.h:961
String & append(const Pt::Char *str)
Append content to the string.
bool operator!=(const wchar_t *b, const String &a)
Compares two strings.
Definition Api-String.h:903
size_type find(const Pt::Char *str, size_type pos, size_type n) const
Find content in the string.
reference operator[](size_type n)
Random access to characters.
Definition Api-String.h:195
String & append(const String &str, size_type pos, size_type n)
Append content to the string.
bool operator==(const String &a, const Pt::Char *b)
Compares two strings.
Definition Api-String.h:838
String & operator=(const wchar_t *str)
Assignment operator.
Definition Api-String.h:623
size_type find_last_of(const Pt::Char *s, size_type pos, size_type n) const
Find content in the string.
String & operator+=(const Pt::Char *str)
Append a string.
Definition Api-String.h:655
bool operator<(const String &a, const wchar_t *b)
Compares two strings.
Definition Api-String.h:947
const_reference operator[](size_type n) const
Random access to characters.
Definition Api-String.h:200
String & erase(size_type pos=0, size_type n=npos)
Erase characters from the string.
bool operator>(const String &a, const String &b)
Compares two strings.
Definition Api-String.h:1028
bool operator>(const char *b, const String &a)
Compares two strings.
Definition Api-String.h:1070
String(const wchar_t *str, const allocator_type &a=allocator_type())
Constructor.
String & insert(size_type pos, const Pt::Char *str, size_type n)
Insert into string.
String(const allocator_type &a=allocator_type())
Default Constructor.
String & assign(const Pt::Char *str, size_type length)
Assign content to the string.
bool operator>(const String &a, const wchar_t *b)
Compares two strings.
Definition Api-String.h:1049
String & assign(const char *str, size_type length)
Assign content to the string.
size_type length() const
Returns the length of the string.
Definition Api-String.h:258
size_type find_first_of(const Pt::Char *str, size_type pos=0) const
Find content in the string.
Definition Api-String.h:529
bool operator==(const String &a, const wchar_t *b)
Compares two strings.
Definition Api-String.h:845
void clear()
Clears the string.
Definition Api-String.h:391
String operator+(const String &a, const String &b)
Concatenates two strings.
Definition Api-String.h:787
iterator end()
Returns an iterator to the end of the string.
Definition Api-String.h:160
size_type find_last_of(const Pt::Char *str, size_type pos=npos) const
Find content in the string.
Definition Api-String.h:548
bool operator<=(const String &a, const Pt::Char *b)
Compares two strings.
Definition Api-String.h:991
const Pt::Char * c_str() const
Returns a null terminated C string.
Definition Api-String.h:288
const_iterator end() const
Returns an iterator to the end of the string.
Definition Api-String.h:170
reverse_iterator rbegin()
Returns an reverse iterator to the end of the string.
Definition Api-String.h:175
bool operator!=(const String &a, const Pt::Char *b)
Compares two strings.
Definition Api-String.h:889
String & insert(size_type pos, const String &str, size_type pos2, size_type n)
Insert into string.
size_type capacity() const
Returns the capacity.
Definition Api-String.h:278
int compare(const wchar_t *str) const
Compare strings.
String & replace(iterator i1, iterator i2, size_type n, Pt::Char ch)
Replace portion of the string.
String & insert(iterator p, Pt::Char ch)
Insert into string.
size_type find_last_not_of(Pt::Char ch, size_type pos=npos) const
Find content in the string.
bool operator>=(const wchar_t *b, const String &a)
Compares two strings.
Definition Api-String.h:1107
iterator begin()
Returns an iterator to the begin of the string.
Definition Api-String.h:155
int compare(const char *str) const
Compare strings.
String(size_type n, Pt::Char c, const allocator_type &a=allocator_type())
Constructor.
size_type find_first_of(const Pt::Char ch, size_type pos=0) const
Find content in the string.
Definition Api-String.h:534
String & append(size_type n, Pt::Char ch)
Append content to the string.
bool operator!=(const String &a, const wchar_t *b)
Compares two strings.
Definition Api-String.h:896
bool operator>=(const String &a, const char *b)
Compares two strings.
Definition Api-String.h:1114
reference at(size_type n)
Random access to characters.
Definition Api-String.h:205
size_type rfind(const String &str, size_type pos=npos) const
Find content in the string.
String & insert(iterator p, size_type n, Pt::Char ch)
Insert into string.
bool operator<=(const String &a, const wchar_t *b)
Compares two strings.
Definition Api-String.h:998
static String fromUtf16(InIterT from, InIterT fromEnd)
Convert from UTF-16.
bool operator>=(const String &a, const String &b)
Compares two strings.
Definition Api-String.h:1079
String operator+(const Pt::Char *a, const String &b)
Concatenates two strings.
Definition Api-String.h:801
const_reverse_iterator rbegin() const
Returns an reverse iterator to the end of the string.
Definition Api-String.h:185
int compare(const Pt::Char *str, size_type n) const
Compare strings.
bool operator>(const wchar_t *b, const String &a)
Compares two strings.
Definition Api-String.h:1056
String & operator=(const char *str)
Assignment operator.
Definition Api-String.h:628
String & operator=(const Pt::Char *str)
Assignment operator.
Definition Api-String.h:633
String & assign(size_type n, Pt::Char c)
Assign content to the string.
iterator erase(iterator pos)
Erase characters from the string.
const Pt::Char * data() const
Returns the string character buffer.
Definition Api-String.h:283
iterator erase(iterator first, iterator last)
Erase characters from the string.
size_type find_first_not_of(const Pt::Char ch, size_type pos=0) const
Find content in the string.
bool operator==(const Pt::Char *a, const String &b)
Compares two strings.
Definition Api-String.h:831
String substr(size_type pos=0, size_type n=npos) const
Returns a substring.
Definition Api-String.h:252
bool operator==(const wchar_t *b, const String &a)
Compares two strings.
Definition Api-String.h:852
Core module.
Definition Allocator.h:33
Unicode character type.
Definition String.h:67