PIString wo pideue parent
This commit is contained in:
@@ -33,13 +33,25 @@
|
||||
|
||||
class PIStringList;
|
||||
|
||||
class PIP_EXPORT PIString: public PIDeque<PIChar>
|
||||
class PIP_EXPORT PIString
|
||||
{
|
||||
friend PIByteArray & operator >>(PIByteArray & s, PIString & v);
|
||||
friend PIByteArray & operator <<(PIByteArray & s, const PIString & v);
|
||||
public:
|
||||
typedef PIDeque<PIChar>::iterator iterator;
|
||||
typedef PIDeque<PIChar>::const_iterator const_iterator;
|
||||
typedef PIDeque<PIChar>::reverse_iterator reverse_iterator;
|
||||
typedef PIDeque<PIChar>::const_reverse_iterator const_reverse_iterator;
|
||||
typedef PIChar value_type;
|
||||
typedef PIChar* pointer;
|
||||
typedef const PIChar* const_pointer;
|
||||
typedef PIChar& reference;
|
||||
typedef const PIChar& const_reference;
|
||||
typedef size_t size_type;
|
||||
|
||||
//! \~english Contructs an empty string
|
||||
//! \~russian Создает пустую строку
|
||||
PIString(): PIDeque<PIChar>() {}
|
||||
PIString() {}
|
||||
|
||||
//! \~english Value for elide at left
|
||||
//! \~russian Значение для пропуска слева
|
||||
@@ -53,8 +65,8 @@ public:
|
||||
//! \~russian Значение для пропуска справа
|
||||
static const float ElideRight ;
|
||||
|
||||
PIString & operator +=(const PIChar & c) {PIDeque<PIChar>::push_back(c); return *this;}
|
||||
PIString & operator +=(const char c) {PIDeque<PIChar>::push_back(PIChar(c)); return *this;}
|
||||
PIString & operator +=(const PIChar & c) {d.push_back(c); return *this;}
|
||||
PIString & operator +=(const char c) {d.push_back(PIChar(c)); return *this;}
|
||||
PIString & operator +=(const char * str);
|
||||
PIString & operator +=(const wchar_t * str);
|
||||
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
|
||||
@@ -62,18 +74,18 @@ public:
|
||||
|
||||
//! \~english Contructs a copy of string
|
||||
//! \~russian Создает копию строки
|
||||
PIString(const PIString & o): PIDeque<PIChar>(o) {}
|
||||
PIString(const PIString & o) {d = o.d;}
|
||||
|
||||
PIString(PIString && o): PIDeque<PIChar>(std::move(o)) {}
|
||||
PIString(PIString && o): d(std::move(o.d)) {piSwap(data_, o.data_);}
|
||||
|
||||
|
||||
//! \~english Contructs string with single symbol "c"
|
||||
//! \~russian Создает строку из одного символа "c"
|
||||
PIString(const PIChar c): PIDeque<PIChar>() {*this += c;}
|
||||
PIString(const PIChar c) {*this += c;}
|
||||
|
||||
//! \~english Contructs string with single symbol "c"
|
||||
//! \~russian Создает строку из одного символа "c"
|
||||
PIString(const char c): PIDeque<PIChar>() {*this += PIChar(c);}
|
||||
PIString(const char c) {*this += PIChar(c);}
|
||||
|
||||
//! \~english Contructs string from C-string "str" (system codepage)
|
||||
//! \~russian Создает строку из C-строки "str" (кодировка системы)
|
||||
@@ -85,7 +97,7 @@ public:
|
||||
//! \~\code
|
||||
//! PIString s("string");
|
||||
//! \endcode
|
||||
PIString(const char * str): PIDeque<PIChar>() {*this += str;}
|
||||
PIString(const char * str) {*this += str;}
|
||||
|
||||
//! \~english Contructs string from \c wchar_t C-string "str"
|
||||
//! \~russian Создает строку из \c wchar_t C-строки "str"
|
||||
@@ -97,15 +109,15 @@ public:
|
||||
//! \~\code
|
||||
//! PIString s(L"string");
|
||||
//! \endcode
|
||||
PIString(const wchar_t * str): PIDeque<PIChar>() {*this += str;}
|
||||
PIString(const wchar_t * str) {*this += str;}
|
||||
|
||||
//! \~english Contructs string from byte array "ba" (as UTF-8)
|
||||
//! \~russian Создает строку из байтового массива "ba" (как UTF-8)
|
||||
PIString(const PIByteArray & ba): PIDeque<PIChar>() {*this += ba;}
|
||||
PIString(const PIByteArray & ba) {*this += ba;}
|
||||
|
||||
//! \~english Contructs string from "len" characters of buffer "str"
|
||||
//! \~russian Создает строку из "len" символов массива "str"
|
||||
PIString(const PIChar * str, const int len): PIDeque<PIChar>(str, size_t(len)) {}
|
||||
PIString(const PIChar * str, const int len): d(str, size_t(len)) {}
|
||||
|
||||
//! \~english Contructs string from "len" characters of buffer "str" (system codepage)
|
||||
//! \~russian Создает строку из "len" символов массива "str" (кодировка системы)
|
||||
@@ -113,7 +125,7 @@ public:
|
||||
//! \~\code
|
||||
//! PIString s("string", 3); // s = "str"
|
||||
//! \endcode
|
||||
PIString(const char * str, const int len): PIDeque<PIChar>() {appendFromChars(str, len);}
|
||||
PIString(const char * str, const int len) {appendFromChars(str, len);}
|
||||
|
||||
//! \~english Contructs string as sequence of characters "c" of buffer with length "len"
|
||||
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
||||
@@ -121,7 +133,7 @@ public:
|
||||
//! \~\code
|
||||
//! PIString s(5, 'p'); // s = "ppppp"
|
||||
//! \endcode
|
||||
PIString(const int len, const char c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) PIDeque<PIChar>::push_back(PIChar(c));}
|
||||
PIString(const int len, const char c) {for (int i = 0; i < len; ++i) d.push_back(PIChar(c));}
|
||||
|
||||
//! \~english Contructs string as sequence of symbols "c" of buffer with length "len"
|
||||
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
||||
@@ -129,16 +141,16 @@ public:
|
||||
//! \~\code
|
||||
//! PIString s(5, "№"); // s = "№№№№№"
|
||||
//! \endcode
|
||||
PIString(const int len, const PIChar c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) PIDeque<PIChar>::push_back(c);}
|
||||
PIString(const int len, const PIChar c) {for (int i = 0; i < len; ++i) d.push_back(c);}
|
||||
|
||||
~PIString();
|
||||
|
||||
|
||||
//! \~english Assign operator
|
||||
//! \~russian Оператор присваивания
|
||||
PIString & operator =(const PIString & o) {if (this == &o) return *this; clear(); *this += o; return *this;}
|
||||
PIString & operator =(const PIString & o) {if (this == &o) return *this; d = o.d; return *this;}
|
||||
|
||||
PIString & operator =(PIString && o) {swap(o); return *this;}
|
||||
PIString & operator =(PIString && o) {d.swap(o.d); piSwap(data_, o.data_); return *this;}
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
@@ -146,7 +158,7 @@ public:
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
bool operator ==(const PIChar c) const {if (size_s() != 1) return false; return at(0) == c;}
|
||||
bool operator ==(const PIChar c) const {if (d.size() != 1) return false; return d.at(0) == c;}
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
@@ -158,7 +170,7 @@ public:
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
bool operator !=(const PIChar c) const {if (size_s() != 1) return true; return at(0) != c;}
|
||||
bool operator !=(const PIChar c) const {if (d.size() != 1) return true; return d.at(0) != c;}
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
@@ -170,7 +182,7 @@ public:
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
bool operator <(const PIChar c) const {if (size_s() != 1) return size_s() < 1; return at(0) < c;}
|
||||
bool operator <(const PIChar c) const {if (d.size() != 1) return d.size() < 1; return d.at(0) < c;}
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
@@ -182,7 +194,7 @@ public:
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
bool operator >(const PIChar c) const {if (size_s() != 1) return size_s() > 1; return at(0) > c;}
|
||||
bool operator >(const PIChar c) const {if (d.size() != 1) return d.size() > 1; return d.at(0) > c;}
|
||||
|
||||
//! \~english Compare operator
|
||||
//! \~russian Оператор сравнения
|
||||
@@ -228,7 +240,7 @@ public:
|
||||
//! PIString s("stri");
|
||||
//! s << PIChar('n') << PIChar('g'); // s = "string"
|
||||
//! \endcode
|
||||
PIString & operator <<(const PIChar c) {*this += c; return *this;}
|
||||
PIString & operator <<(const PIChar c) {d.append(c); return *this;}
|
||||
|
||||
//! \~english Append symbol `c` at the end of string
|
||||
//! \~russian Добавляет в конец символ `c`
|
||||
@@ -237,7 +249,7 @@ public:
|
||||
//! PIString s("stri");
|
||||
//! s << 'n' << 'g'; // s = "string"
|
||||
//! \endcode
|
||||
PIString & operator <<(const char c) {*this += PIChar(c); return *this;}
|
||||
PIString & operator <<(const char c) {d.append(PIChar(c)); return *this;}
|
||||
|
||||
//! \~english Append С-string "str" at the end of string
|
||||
//! \~russian Добавляет в конец C-строку "str"
|
||||
@@ -298,6 +310,36 @@ public:
|
||||
//! \endcode
|
||||
PIString & operator <<(const double & num) {*this += PIString::fromNumber(num); return *this;}
|
||||
|
||||
inline iterator begin() {return d.begin();}
|
||||
inline iterator end() {return d.end();}
|
||||
|
||||
inline const_iterator begin() const {return d.begin();}
|
||||
inline const_iterator end() const {return d.end();}
|
||||
|
||||
inline reverse_iterator rbegin() {return d.rbegin();}
|
||||
inline reverse_iterator rend() {return d.rend();}
|
||||
|
||||
inline const_reverse_iterator rbegin() const {return d.rbegin();}
|
||||
inline const_reverse_iterator rend() const {return d.rend();}
|
||||
|
||||
inline PIChar & operator [](size_t index) {return d[index];}
|
||||
inline PIChar operator [](size_t index) const {return d[index];}
|
||||
|
||||
inline const PIChar at(size_t index) const {return d.at(index);}
|
||||
|
||||
inline PIChar & back() {return d.back();}
|
||||
inline PIChar back() const {return d.back();}
|
||||
|
||||
inline PIChar & front() {return d.front();}
|
||||
inline PIChar front() const {return d.front();}
|
||||
|
||||
inline PIString & resize(size_t new_size, PIChar c = PIChar()) {d.resize(new_size, c); return *this;}
|
||||
|
||||
inline PIString & pop_back() {d.pop_back(); return *this;}
|
||||
inline PIString & pop_front() {d.pop_front(); return *this;}
|
||||
|
||||
inline PIString & remove(size_t index, size_t count = 1) {d.remove(index, count); return *this;}
|
||||
inline PIString & fill(PIChar c = PIChar()) {d.fill(c); return *this;}
|
||||
|
||||
//! \~english Insert string "str" at the begin of string
|
||||
//! \~russian Вставляет "str" в начало строки
|
||||
@@ -305,15 +347,15 @@ public:
|
||||
|
||||
//! \~english Insert string "str" at the begin of string
|
||||
//! \~russian Вставляет "str" в начало строки
|
||||
PIString & prepend(const PIString & str) {insert(0, str); return *this;}
|
||||
PIString & prepend(const PIString & str) {d.prepend(str.d); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the begin of string
|
||||
//! \~russian Вставляет символ `c` в начало строки
|
||||
PIString & prepend(const PIChar c) {PIDeque<PIChar>::prepend(c); return *this;}
|
||||
PIString & prepend(const PIChar c) {d.prepend(c); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the begin of string
|
||||
//! \~russian Вставляет символ `c` в начало строки
|
||||
PIString & prepend(const char c) {PIDeque<PIChar>::prepend(PIChar(c)); return *this;}
|
||||
PIString & prepend(const char c) {d.prepend(PIChar(c)); return *this;}
|
||||
|
||||
//! \~english Insert string "str" at the begin of string
|
||||
//! \~russian Вставляет "str" в начало строки
|
||||
@@ -321,15 +363,15 @@ public:
|
||||
|
||||
//! \~english Insert string "str" at the begin of string
|
||||
//! \~russian Вставляет "str" в начало строки
|
||||
PIString & push_front(const PIString & str) {insert(0, str); return *this;}
|
||||
PIString & push_front(const PIString & str) {d.push_front(str.d); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the begin of string
|
||||
//! \~russian Вставляет символ `c` в начало строки
|
||||
PIString & push_front(const PIChar c) {PIDeque<PIChar>::push_front(c); return *this;}
|
||||
PIString & push_front(const PIChar c) {d.push_front(c); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the begin of string
|
||||
//! \~russian Вставляет символ `c` в начало строки
|
||||
PIString & push_front(const char c) {PIDeque<PIChar>::push_front(PIChar(c)); return *this;}
|
||||
PIString & push_front(const char c) {d.push_front(PIChar(c)); return *this;}
|
||||
|
||||
//! \~english Insert string "str" at the end of string
|
||||
//! \~russian Вставляет "str" в конец строки
|
||||
@@ -337,15 +379,15 @@ public:
|
||||
|
||||
//! \~english Insert string "str" at the end of string
|
||||
//! \~russian Вставляет "str" в конец строки
|
||||
PIString & append(const PIString & str) {*this += str; return *this;}
|
||||
PIString & append(const PIString & str) {d.append(str.d); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the end of string
|
||||
//! \~russian Вставляет символ `c` в конец строки
|
||||
PIString & append(const PIChar c) {PIDeque<PIChar>::append(c); return *this;}
|
||||
PIString & append(const PIChar c) {d.append(c); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the end of string
|
||||
//! \~russian Вставляет символ `c` в конец строки
|
||||
PIString & append(const char c) {PIDeque<PIChar>::append(PIChar(c)); return *this;}
|
||||
PIString & append(const char c) {d.append(PIChar(c)); return *this;}
|
||||
|
||||
//! \~english Insert string "str" at the end of string
|
||||
//! \~russian Вставляет "str" в конец строки
|
||||
@@ -353,15 +395,15 @@ public:
|
||||
|
||||
//! \~english Insert string "str" at the end of string
|
||||
//! \~russian Вставляет "str" в конец строки
|
||||
PIString & push_back(const PIString & str) {*this += str; return *this;}
|
||||
PIString & push_back(const PIString & str) {d.push_back(str.d); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the end of string
|
||||
//! \~russian Вставляет символ `c` в конец строки
|
||||
PIString & push_back(const PIChar c) {PIDeque<PIChar>::push_back(c); return *this;}
|
||||
PIString & push_back(const PIChar c) {d.push_back(c); return *this;}
|
||||
|
||||
//! \~english Insert symbol `c` at the end of string
|
||||
//! \~russian Вставляет символ `c` в конец строки
|
||||
PIString & push_back(const char c) {PIDeque<PIChar>::push_back(PIChar(c)); return *this;}
|
||||
PIString & push_back(const char c) {d.push_back(PIChar(c)); return *this;}
|
||||
|
||||
|
||||
//! \~english Returns part of string from symbol at index "start" and maximum length "len"
|
||||
@@ -513,7 +555,7 @@ public:
|
||||
|
||||
//! \~english Remove all founded symbols "what" and return this string
|
||||
//! \~russian Удаляет все найденные символы "what", возвращает эту строку
|
||||
PIString & removeAll(char c) {PIDeque<PIChar>::removeAll(PIChar(c)); return *this;}
|
||||
PIString & removeAll(char c) {d.removeAll(PIChar(c)); return *this;}
|
||||
|
||||
//! \~english Repeat content of string "times" times and return this string
|
||||
//! \~russian Повторяет содержимое строки "times" раз и возвращает эту строку
|
||||
@@ -545,7 +587,7 @@ public:
|
||||
//! s.insert(1, "i");
|
||||
//! piCout << s; // s = "pip"
|
||||
//! \endcode
|
||||
PIString & insert(const int index, const PIChar c) {PIDeque<PIChar>::insert(index, c); return *this;}
|
||||
PIString & insert(const int index, const PIChar c) {d.insert(index, c); return *this;}
|
||||
|
||||
//! \~english Insert symbol "c" after index "index" and return this string
|
||||
//! \~russian Вставляет символ "c" после позиции "index" и возвращает эту строку
|
||||
@@ -588,7 +630,7 @@ public:
|
||||
//! piCout << s; // s = "str___"
|
||||
//! \endcode
|
||||
//! \~\sa \a expandLeftTo(), \a expandedRightTo(), \a expandedLeftTo()
|
||||
PIString & expandRightTo(const int len, const PIChar c) {if (len > length()) resize(len, c); return *this;}
|
||||
PIString & expandRightTo(const int len, const PIChar c) {if (len > d.size_s()) d.resize(len, c); return *this;}
|
||||
|
||||
//! \~english Enlarge string to length "len" by addition symbols "c" at the begin, and return this string
|
||||
//! \~russian Увеличивает длину строки до "len" добавлением символов "c" в начало и возвращает эту строку
|
||||
@@ -601,7 +643,7 @@ public:
|
||||
//! piCout << s; // s = "___str"
|
||||
//! \endcode
|
||||
//! \~\sa \a expandRightTo(), \a expandedRightTo(), \a expandedLeftTo()
|
||||
PIString & expandLeftTo(const int len, const PIChar c) {if (len > length()) insert(0, PIString(len - length(), c)); return *this;}
|
||||
PIString & expandLeftTo(const int len, const PIChar c) {if (len > d.size_s()) insert(0, PIString(len - d.size_s(), c)); return *this;}
|
||||
|
||||
//! \~english Enlarge copy of this string to length "len" by addition symbols "c" at the end
|
||||
//! \~russian Увеличивает длину копии этой строки до "len" добавлением символов "c" в конец
|
||||
@@ -634,7 +676,7 @@ public:
|
||||
//! piCout << s; // s = ""str""
|
||||
//! \endcode
|
||||
//! \~\sa \a quoted()
|
||||
PIString & quote(PIChar c = PIChar('"')) {insert(0, c); *this += c; return *this;}
|
||||
PIString & quote(PIChar c = PIChar('"')) {d.prepend(c); d.append(c); return *this;}
|
||||
|
||||
//! \~english Returns quoted copy of this string
|
||||
//! \~russian Возвращает копию строки с добавленным в начало и конец символом "c"
|
||||
@@ -656,7 +698,7 @@ public:
|
||||
//! piCout << s; // s = "9876543210"
|
||||
//! \endcode
|
||||
//! \~\sa \a reversed()
|
||||
PIString & reverse() {PIDeque<PIChar>::reverse(); return *this;}
|
||||
PIString & reverse() {d.reverse(); return *this;}
|
||||
|
||||
//! \~english Reverse copy of this string
|
||||
//! \~russian Разворачивает копию этой строки
|
||||
@@ -804,7 +846,7 @@ public:
|
||||
|
||||
//! \~english Returns if string contains symbol "c"
|
||||
//! \~russian Возвращает содержит ли строка символ "c"
|
||||
bool contains(const char c) const {return PIDeque<PIChar>::contains(PIChar(c));}
|
||||
bool contains(const char c) const {return d.contains(PIChar(c));}
|
||||
|
||||
//! \~english Returns if string contains substring "str"
|
||||
//! \~russian Возвращает содержит ли строка подстроку "str"
|
||||
@@ -818,10 +860,17 @@ public:
|
||||
//! \~english Search symbol "c" from symbol at index "start" and return first occur position
|
||||
//! \~russian Ищет символ "c" от символа "start" и возвращает первое вхождение
|
||||
int find(const char c, const int start = 0) const;
|
||||
int indexOf(const char c, const int start = 0) const {return find(c, start);}
|
||||
|
||||
//! \~english Search symbol "c" from symbol at index "start" and return first occur position
|
||||
//! \~russian Ищет символ "c" от символа "start" и возвращает первое вхождение
|
||||
int find(PIChar c, const int start = 0) const {return d.indexOf(c, start);}
|
||||
int indexOf(PIChar c, const int start = 0) const {return d.indexOf(c, start);}
|
||||
|
||||
//! \~english Search substring "str" from symbol at index "start" and return first occur position
|
||||
//! \~russian Ищет подстроку "str" от символа "start" и возвращает первое вхождение
|
||||
int find(const PIString & str, const int start = 0) const;
|
||||
int indexOf(const PIString & str, const int start = 0) const {return find(str, start);}
|
||||
|
||||
//! \~english Search substring "str" from symbol at index "start" and return first occur position
|
||||
//! \~russian Ищет подстроку "str" от символа "start" и возвращает первое вхождение
|
||||
@@ -835,6 +884,7 @@ public:
|
||||
//! \endcode
|
||||
//! \~\sa \a findAny(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||
int find(const char * str, const int start = 0) const {return find(PIString(str), start);}
|
||||
int indexOf(const char * str, const int start = 0) const {return find(str, start);}
|
||||
|
||||
//! \~english Search any symbol of "str" from symbol at index "start" and return first occur position
|
||||
//! \~russian Ищет любой символ строки "str" от симола "start" и возвращает первое вхождение
|
||||
@@ -854,10 +904,17 @@ public:
|
||||
//! \~english Search symbol "c" from symbol at index "start" and return last occur position
|
||||
//! \~russian Ищет символ "c" от символа "start" и возвращает последнее вхождение
|
||||
int findLast(const char c, const int start = 0) const;
|
||||
int lastIndexOf(const char c, const int start = 0) const {return findLast(c, start);}
|
||||
|
||||
//! \~english Search symbol "c" from symbol at index "start" and return last occur position
|
||||
//! \~russian Ищет символ "c" от символа "start" и возвращает последнее вхождение
|
||||
int findLast(PIChar c, const int start = 0) const;
|
||||
int lastIndexOf(PIChar c, const int start = 0) const {return findLast(c, start);}
|
||||
|
||||
//! \~english Search substring "str" from symbol at index "start" and return last occur position
|
||||
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение
|
||||
int findLast(const PIString & str, const int start = 0) const;
|
||||
int lastIndexOf(const PIString & str, const int start = 0) const {return findLast(str, start);}
|
||||
|
||||
//! \~english Search substring "str" from symbol at index "start" and return last occur position
|
||||
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение
|
||||
@@ -871,6 +928,7 @@ public:
|
||||
//! \endcode
|
||||
//! \~\sa \a find(), \a findAny(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
|
||||
int findLast(const char * str, const int start = 0) const {return findLast(PIString(str), start);}
|
||||
int lastIndexOf(const char * str, const int start = 0) const {return findLast(str, start);}
|
||||
|
||||
//! \~english Search any symbol of "str" from symbol at index "start" and return last occur position
|
||||
//! \~russian Ищет любой символ строки "str" от символа "start" и возвращает последнее вхождение
|
||||
@@ -924,19 +982,28 @@ public:
|
||||
//! \~english Returns if string ends with "str"
|
||||
//! \~russian Возвращает оканчивается ли строка на "str"
|
||||
bool endsWith(const PIString & str) const;
|
||||
|
||||
|
||||
//! \~english Returns symbols length of string
|
||||
//! \~russian Возвращает длину строки в символах
|
||||
int length() const {return size();}
|
||||
int length() const {return d.size_s();}
|
||||
|
||||
//! \~english Returns symbols length of string
|
||||
//! \~russian Возвращает длину строки в символах
|
||||
size_t size() const {return d.size();}
|
||||
|
||||
//! \~english Returns symbols length of string
|
||||
//! \~russian Возвращает длину строки в символах
|
||||
ssize_t size_s() const {return d.size_s();}
|
||||
|
||||
//! \~english Returns \c true if string is empty, i.e. length = 0
|
||||
//! \~russian Возвращает \c true если строка пустая, т.е. длина = 0
|
||||
bool isEmpty() const {return (size() == 0 || *this == "");}
|
||||
bool isEmpty() const {if (d.isEmpty()) return true; if (d.at(0) == PIChar()) return true; return false;}
|
||||
|
||||
//! \~english Returns \c true if string is not empty, i.e. length > 0
|
||||
//! \~russian Возвращает \c true если строка непустая, т.е. длина > 0
|
||||
bool isNotEmpty() const {return !isEmpty();}
|
||||
|
||||
void clear() {d.clear();}
|
||||
|
||||
//! \~english Returns \c true if string equal "true", "yes", "on" or positive not null numeric value
|
||||
//! \~russian Возвращает \c true если строка равна "true", "yes", "on" или числу > 0
|
||||
@@ -1090,7 +1157,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const short value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const short value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||
@@ -1102,7 +1169,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const ushort value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const ushort value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||
@@ -1114,7 +1181,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const int value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const int value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||
@@ -1126,7 +1193,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const uint value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const uint value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||
@@ -1138,7 +1205,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const long value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const long value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||
@@ -1150,7 +1217,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const ulong value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const ulong value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||
@@ -1162,7 +1229,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const llong & value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const llong & value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||
@@ -1174,7 +1241,7 @@ public:
|
||||
//! s.setNumber(123, 16);
|
||||
//! piCout << s; // 7B
|
||||
//! \endcode
|
||||
PIString & setNumber(const ullong & value, int base = 10, bool * ok = 0) {clear(); *this += PIString::fromNumber(value, base, ok); return *this;}
|
||||
PIString & setNumber(const ullong & value, int base = 10, bool * ok = 0) {*this = PIString::fromNumber(value, base, ok); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||
@@ -1192,7 +1259,7 @@ public:
|
||||
//! s.setNumber(123456789., 'f', 0);
|
||||
//! piCout << s; // 123456789
|
||||
//! \endcode
|
||||
PIString & setNumber(const float value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
||||
PIString & setNumber(const float value, char format = 'f', int precision = 8) {*this = PIString::fromNumber(value, format, precision); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||
@@ -1210,7 +1277,7 @@ public:
|
||||
//! s.setNumber(123456789., 'f', 0);
|
||||
//! piCout << s; // 123456789
|
||||
//! \endcode
|
||||
PIString & setNumber(const double & value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
||||
PIString & setNumber(const double & value, char format = 'f', int precision = 8) {*this = PIString::fromNumber(value, format, precision); return *this;}
|
||||
|
||||
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||
@@ -1228,7 +1295,7 @@ public:
|
||||
//! s.setNumber(123456789., 'f', 0);
|
||||
//! piCout << s; // 123456789
|
||||
//! \endcode
|
||||
PIString & setNumber(const ldouble & value, char format = 'f', int precision = 8) {clear(); *this += PIString::fromNumber(value, format, precision); return *this;}
|
||||
PIString & setNumber(const ldouble & value, char format = 'f', int precision = 8) {*this = PIString::fromNumber(value, format, precision); return *this;}
|
||||
|
||||
//! \~english Set string content to human readable size in B/kB/MB/GB/TB/PB
|
||||
//! \~russian Устанавливает содержимое в строку с читаемым размером B/kB/MB/GB/TB/PB
|
||||
@@ -1345,7 +1412,7 @@ public:
|
||||
|
||||
//! \~english Returns "true" or "false"
|
||||
//! \~russian Возвращает "true" или "false"
|
||||
static PIString fromBool(const bool value) {return PIString(value ? "true" : "false");}
|
||||
static PIString fromBool(const bool value) {return PIString(value ? PIStringAscii("true") : PIStringAscii("false"));}
|
||||
|
||||
//! \~english Returns string constructed from terminal codepage
|
||||
//! \~russian Возвращает строку созданную из кодировки консоли
|
||||
@@ -1380,6 +1447,11 @@ public:
|
||||
//! \~\sa PIString::setReadableSize()
|
||||
static PIString readableSize(llong bytes);
|
||||
|
||||
void swap(PIString & str) {
|
||||
d.swap(str.d);
|
||||
piSwap(data_, str.data_);
|
||||
}
|
||||
|
||||
private:
|
||||
static const char toBaseN[];
|
||||
static const int fromBaseN[];
|
||||
@@ -1400,6 +1472,7 @@ private:
|
||||
void deleteData() const;
|
||||
void trimsubstr(int &st, int &fn) const;
|
||||
|
||||
PIDeque<PIChar> d;
|
||||
mutable char * data_ = nullptr;
|
||||
};
|
||||
|
||||
@@ -1412,12 +1485,12 @@ PIP_EXPORT PICout operator <<(PICout s, const PIString & v);
|
||||
//! \relatesalso PIByteArray
|
||||
//! \~english Store operator
|
||||
//! \~russian Оператор сохранения
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIString & v) {s << *(PIDeque<PIChar>*)&v; return s;}
|
||||
inline PIByteArray & operator <<(PIByteArray & s, const PIString & v) {s << v.d; return s;}
|
||||
|
||||
//! \relatesalso PIByteArray
|
||||
//! \~english Restore operator
|
||||
//! \~russian Оператор извлечения
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.clear(); s >> *(PIDeque<PIChar>*)&v; return s;}
|
||||
inline PIByteArray & operator >>(PIByteArray & s, PIString & v) {v.d.clear(); s >> v.d; return s;}
|
||||
|
||||
|
||||
//! \~english Returns concatenated string
|
||||
@@ -1457,6 +1530,8 @@ PIString PIP_EXPORT versionNormalize(const PIString & v);
|
||||
//! \~russian Возвращает хэш строки
|
||||
template<> inline uint piHash(const PIString & s) {return s.hash();}
|
||||
|
||||
template<> inline void piSwap(PIString & f, PIString & s) {f.swap(s);}
|
||||
template<> inline void piSwap(PIString & f, PIString & s) {
|
||||
f.swap(s);
|
||||
}
|
||||
|
||||
#endif // PISTRING_H
|
||||
|
||||
Reference in New Issue
Block a user