code format

This commit is contained in:
2022-12-14 14:13:52 +03:00
parent 430a41fefc
commit c2b8a8d6da
297 changed files with 27331 additions and 24162 deletions

View File

@@ -3,24 +3,24 @@
* \brief
* \~english String class
* \~russian Класс строки
*/
*/
/*
PIP - Platform Independent Primitives
String
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
PIP - Platform Independent Primitives
String
Ivan Pelipenko peri4ko@yandex.ru, Andrey Bychkov work.a.b@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PISTRING_H
@@ -38,19 +38,19 @@ class PIStringList;
//! \~\brief
//! \~english String class.
//! \~russian Класс строки.
class PIP_EXPORT PIString
{
class PIP_EXPORT PIString {
BINARY_STREAM_FRIEND(PIString);
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 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.
@@ -59,7 +59,7 @@ public:
//! \~english Value for elide at left.
//! \~russian Значение для пропуска слева.
static const float ElideLeft ;
static const float ElideLeft;
//! \~english Value for elide at center.
//! \~russian Значение для пропуска в середине.
@@ -67,52 +67,58 @@ public:
//! \~english Value for elide at right.
//! \~russian Значение для пропуска справа.
static const float ElideRight ;
static const float ElideRight;
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);
PIString & operator +=(const PIString & str);
PIString & operator +=(const PIConstChars & str);
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);
PIString & operator+=(const PIString & str);
PIString & operator+=(const PIConstChars & str);
PIString(uchar ) = delete;
PIString( short) = delete;
PIString(ushort) = delete;
PIString( int ) = delete;
PIString(uint ) = delete;
PIString( long ) = delete;
PIString(ulong ) = delete;
PIString( llong) = delete;
PIString(ullong) = delete;
PIString(uchar) = delete;
PIString(short) = delete;
PIString(ushort) = delete;
PIString(int) = delete;
PIString(uint) = delete;
PIString(long) = delete;
PIString(ulong) = delete;
PIString(llong) = delete;
PIString(ullong) = delete;
PIString & operator +=(uchar ) = delete;
PIString & operator +=( short) = delete;
PIString & operator +=(ushort) = delete;
PIString & operator +=( int ) = delete;
PIString & operator +=(uint ) = delete;
PIString & operator +=( long ) = delete;
PIString & operator +=(ulong ) = delete;
PIString & operator +=( llong) = delete;
PIString & operator +=(ullong) = delete;
PIString & operator+=(uchar) = delete;
PIString & operator+=(short) = delete;
PIString & operator+=(ushort) = delete;
PIString & operator+=(int) = delete;
PIString & operator+=(uint) = delete;
PIString & operator+=(long) = delete;
PIString & operator+=(ulong) = delete;
PIString & operator+=(llong) = delete;
PIString & operator+=(ullong) = delete;
//! \~english Contructs a copy of string.
//! \~russian Создает копию строки.
PIString(const PIString & o) {d = o.d;}
PIString(const PIString & o) { d = o.d; }
//! \~english Move constructor.
//! \~russian Перемещающий конструктор.
PIString(PIString && o): d(std::move(o.d)) {piSwap(data_, o.data_);}
PIString(PIString && o): d(std::move(o.d)) { piSwap(data_, o.data_); }
//! \~english Contructs string with single character "c".
//! \~russian Создает строку из одного символа "c".
PIString(const PIChar c) {d.push_back(c);}
PIString(const PIChar c) { d.push_back(c); }
//! \~english Contructs string with single character "c".
//! \~russian Создает строку из одного символа "c".
PIString(const char c) {d.push_back(PIChar(c));}
PIString(const char c) { d.push_back(PIChar(c)); }
//! \~english Contructs string from C-string "str" (system codepage).
//! \~russian Создает строку из C-строки "str" (кодировка системы).
//! \~\details
@@ -123,8 +129,8 @@ public:
//! \~\code
//! PIString s("string");
//! \endcode
PIString(const char * str) {*this += str;}
PIString(const char * str) { *this += str; }
//! \~english Contructs string from \c wchar_t C-string "str".
//! \~russian Создает строку из \c wchar_t C-строки "str".
//! \~\details
@@ -135,11 +141,11 @@ public:
//! \~\code
//! PIString s(L"string");
//! \endcode
PIString(const wchar_t * str) {*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) {*this += ba;}
PIString(const PIByteArray & ba) { *this += ba; }
//! \~english Contructs string from "len" characters of buffer "str".
//! \~russian Создает строку из "len" символов массива "str".
@@ -151,7 +157,7 @@ public:
//! \~\code
//! PIString s("string", 3); // s = "str"
//! \endcode
PIString(const char * str, const int len) {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".
@@ -159,7 +165,10 @@ public:
//! \~\code
//! PIString s(5, 'p'); // s = "ppppp"
//! \endcode
PIString(const int len, const char c) {for (int i = 0; i < len; ++i) d.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 characters "c" of buffer with length "len".
//! \~russian Создает строку как последовательность длиной "len" символа "c".
@@ -167,116 +176,147 @@ public:
//! \~\code
//! PIString s(5, "№"); // s = "№№№№№"
//! \endcode
PIString(const int len, const PIChar c) {for (int i = 0; i < len; ++i) d.push_back(c);}
PIString(const int len, const PIChar c) {
for (int i = 0; i < len; ++i)
d.push_back(c);
}
PIString(const PIConstChars & c) { *this += c; }
PIString(const PIConstChars & c) {*this += c;}
~PIString();
//! \~english Assign operator.
//! \~russian Оператор присваивания.
PIString & operator =(const PIString & o) {if (this == &o) return *this; d = o.d; return *this;}
PIString & operator=(const PIString & o) {
if (this == &o) return *this;
d = o.d;
return *this;
}
//! \~english Assign move operator.
//! \~russian Оператор перемещающего присваивания.
PIString & operator =(PIString && o) {d.swap(o.d); piSwap(data_, o.data_); return *this;}
PIString & operator=(PIString && o) {
d.swap(o.d);
piSwap(data_, o.data_);
return *this;
}
//! \~english Assign operator.
//! \~russian Оператор присваивания.
PIString & operator =(const PIConstChars & o) {d.clear(); *this += o; return *this;}
PIString & operator=(const PIConstChars & o) {
d.clear();
*this += o;
return *this;
}
//! \~english Assign operator.
//! \~russian Оператор присваивания.
PIString & operator =(const char * o) {d.clear(); *this += o; return *this;}
PIString & operator=(const char * o) {
d.clear();
*this += o;
return *this;
}
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator ==(const PIString & str) const;
bool operator==(const PIString & str) const;
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator ==(const PIChar c) const {if (d.size() != 1) return false; return d.at(0) == c;}
bool operator==(const PIChar c) const {
if (d.size() != 1) return false;
return d.at(0) == c;
}
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator ==(const char * str) const {return *this == PIString(str);}
bool operator==(const char * str) const { return *this == PIString(str); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator !=(const PIString & str) const;
bool operator!=(const PIString & str) const;
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator !=(const PIChar c) const {if (d.size() != 1) return true; return d.at(0) != c;}
bool operator!=(const PIChar c) const {
if (d.size() != 1) return true;
return d.at(0) != c;
}
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator !=(const char * str) const {return *this != PIString(str);}
bool operator!=(const char * str) const { return *this != PIString(str); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator <(const PIString & str) const;
bool operator<(const PIString & str) const;
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator <(const PIChar c) const {if (d.size() != 1) return d.size() < 1; return d.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 Оператор сравнения.
bool operator <(const char * str) const {return *this < PIString(str);}
bool operator<(const char * str) const { return *this < PIString(str); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator >(const PIString & str) const;
bool operator>(const PIString & str) const;
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator >(const PIChar c) const {if (d.size() != 1) return d.size() > 1; return d.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 Оператор сравнения.
bool operator >(const char * str) const {return *this > PIString(str);}
bool operator>(const char * str) const { return *this > PIString(str); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator <=(const PIString & str) const {return !(*this > str);}
bool operator<=(const PIString & str) const { return !(*this > str); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator <=(const PIChar c) const {return !(*this > c);}
bool operator<=(const PIChar c) const { return !(*this > c); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator <=(const char * str) const {return *this <= PIString(str);}
bool operator<=(const char * str) const { return *this <= PIString(str); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator >=(const PIString & str) const {return !(*this < str);}
bool operator>=(const PIString & str) const { return !(*this < str); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator >=(const PIChar c) const {return !(*this < c);}
bool operator>=(const PIChar c) const { return !(*this < c); }
//! \~english Compare operator.
//! \~russian Оператор сравнения.
bool operator >=(const char * str) const {return *this >= PIString(str);}
bool operator>=(const char * str) const { return *this >= PIString(str); }
//! \~english Iterator to the first element.
//! \~russian Итератор на первый элемент.
//! \~\details
//! \~\return \ref stl_iterators
//! \~\sa \a end(), \a rbegin(), \a rend()
inline iterator begin() {return d.begin();}
inline iterator begin() { return d.begin(); }
//! \~english Iterator to the element following the last element.
//! \~russian Итератор на элемент, следующий за последним элементом.
//! \~\details
//! \~\return \ref stl_iterators
//! \~\sa \a begin(), \a rbegin(), \a rend()
inline iterator end() {return d.end();}
inline iterator end() { return d.end(); }
inline const_iterator begin() const {return d.begin();}
inline const_iterator end() const {return d.end();}
inline const_iterator begin() const { return d.begin(); }
inline const_iterator end() const { return d.end(); }
//! \~english Returns a reverse iterator to the first element of the reversed array.
//! \~russian Обратный итератор на первый элемент.
@@ -286,7 +326,7 @@ public:
//! Указывает на последний элемент.
//! \~\return \ref stl_iterators
//! \~\sa \a rend(), \a begin(), \a end()
inline reverse_iterator rbegin() {return d.rbegin();}
inline reverse_iterator rbegin() { return d.rbegin(); }
//! \~english Returns a reverse iterator to the element.
//! following the last element of the reversed array.
@@ -297,10 +337,10 @@ public:
//! Указывает на элемент, предшествующий первому элементу.
//! \~\return \ref stl_iterators
//! \~\sa \a rbegin(), \a begin(), \a end()
inline reverse_iterator rend() {return d.rend();}
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 const_reverse_iterator rbegin() const { return d.rbegin(); }
inline const_reverse_iterator rend() const { return d.rend(); }
//! \~english Full access to character by `index`.
//! \~russian Полный доступ к символу по индексу `index`.
@@ -311,8 +351,8 @@ public:
//! \~russian Индекс элемента считается от `0`.
//! Индекс символа должен лежать в пределах от `0` до `size()-1`.
//! Иначе это приведёт к неопределённому поведению программы и ошибкам памяти.
inline PIChar & operator [](size_t index) {return d[index];}
inline PIChar operator [](size_t index) const {return d[index];}
inline PIChar & operator[](size_t index) { return d[index]; }
inline PIChar operator[](size_t index) const { return d[index]; }
//! \~english Read only access to character by `index`.
//! \~russian Доступ исключительно на чтение к символу по индексу `index`.
@@ -323,15 +363,15 @@ public:
//! \~russian Индекс символа считается от `0`.
//! Индекс символа должен лежать в пределах от `0` до `size()-1`.
//! Иначе это приведёт к неопределённому поведению программы и ошибкам памяти.
inline const PIChar at(size_t index) const {return d.at(index);}
inline const PIChar at(size_t index) const { return d.at(index); }
//! \~english Returns the last character of the string.
//! \~russian Возвращает последний символ строки.
inline PIChar & back() {return d.back();}
inline PIChar back() const {return d.back();}
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 PIChar & front() { return d.front(); }
inline PIChar front() const { return d.front(); }
//! \~english Sets size of the string, new characters are copied from `c`.
//! \~russian Устанавливает размер строки, новые символы копируются из `c`.
@@ -344,101 +384,170 @@ public:
//! Если `new_size` меньше чем текущий размер строки \a size(),
//! лишние символы удаляются с конца строки.
//! \~\sa \a size(), \a clear()
inline PIString & resize(size_t new_size, PIChar c = PIChar()) {d.resize(new_size, c); return *this;}
inline PIString & resize(size_t new_size, PIChar c = PIChar()) {
d.resize(new_size, c);
return *this;
}
//! \~english Delete one character at the end of string.
//! \~russian Удаляет один символ с конца строки.
inline PIString & pop_back() {d.pop_back(); return *this;}
inline PIString & pop_back() {
d.pop_back();
return *this;
}
//! \~english Delete one character at the benig of string.
//! \~russian Удаляет один символ с начала строки.
inline PIString & pop_front() {d.pop_front(); return *this;}
inline PIString & pop_front() {
d.pop_front();
return *this;
}
//! \~english Removes `count` characters from the string, starting at `index` position.
//! \~russian Удаляет символы из строки, начиная с позиции `index` в количестве `count`.
inline PIString & remove(size_t index, size_t count = 1) {d.remove(index, count); return *this;}
inline PIString & remove(size_t index, size_t count = 1) {
d.remove(index, count);
return *this;
}
//! \~english Assigns character 'c' to all string characters.
//! \~russian Заполняет всю строку символами `c`.
inline PIString & fill(PIChar c = PIChar()) {d.fill(c); return *this;}
inline PIString & fill(PIChar c = PIChar()) {
d.fill(c);
return *this;
}
//! \~english Insert string "str" at the begin of string.
//! \~russian Вставляет "str" в начало строки.
PIString & prepend(const char * str) {insert(0, str); return *this;}
//! \~english Insert string "str" at the begin of string.
//! \~russian Вставляет "str" в начало строки.
PIString & prepend(const PIString & str) {d.prepend(str.d); return *this;}
//! \~english Insert character `c` at the begin of string.
//! \~russian Вставляет символ `c` в начало строки.
PIString & prepend(const PIChar c) {d.prepend(c); return *this;}
//! \~english Insert character `c` at the begin of string.
//! \~russian Вставляет символ `c` в начало строки.
PIString & prepend(const char c) {d.prepend(PIChar(c)); return *this;}
PIString & prepend(const char * str) {
insert(0, str);
return *this;
}
//! \~english Insert string "str" at the begin of string.
//! \~russian Вставляет "str" в начало строки.
PIString & push_front(const char * str) {insert(0, str); return *this;}
PIString & prepend(const PIString & str) {
d.prepend(str.d);
return *this;
}
//! \~english Insert character `c` at the begin of string.
//! \~russian Вставляет символ `c` в начало строки.
PIString & prepend(const PIChar c) {
d.prepend(c);
return *this;
}
//! \~english Insert character `c` at the begin of string.
//! \~russian Вставляет символ `c` в начало строки.
PIString & prepend(const char c) {
d.prepend(PIChar(c));
return *this;
}
//! \~english Insert string "str" at the begin of string.
//! \~russian Вставляет "str" в начало строки.
PIString & push_front(const PIString & str) {d.push_front(str.d); return *this;}
PIString & push_front(const char * str) {
insert(0, str);
return *this;
}
//! \~english Insert string "str" at the begin of string.
//! \~russian Вставляет "str" в начало строки.
PIString & push_front(const PIString & str) {
d.push_front(str.d);
return *this;
}
//! \~english Insert character `c` at the begin of string.
//! \~russian Вставляет символ `c` в начало строки.
PIString & push_front(const PIChar c) {d.push_front(c); return *this;}
PIString & push_front(const PIChar c) {
d.push_front(c);
return *this;
}
//! \~english Insert character `c` at the begin of string.
//! \~russian Вставляет символ `c` в начало строки.
PIString & push_front(const char c) {d.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" в конец строки.
PIString & append(const char * str) {*this += str; return *this;}
PIString & append(const char * str) {
*this += str;
return *this;
}
//! \~english Insert string "str" at the end of string.
//! \~russian Вставляет "str" в конец строки.
PIString & append(const PIString & str) {d.append(str.d); return *this;}
PIString & append(const PIString & str) {
d.append(str.d);
return *this;
}
PIString & append(const PIConstChars & str) {*this += str; return *this;}
PIString & append(const PIConstChars & str) {
*this += str;
return *this;
}
//! \~english Insert character `c` at the end of string.
//! \~russian Вставляет символ `c` в конец строки.
PIString & append(const PIChar c) {d.append(c); return *this;}
PIString & append(const PIChar c) {
d.append(c);
return *this;
}
//! \~english Insert character `c` at the end of string.
//! \~russian Вставляет символ `c` в конец строки.
PIString & append(const char c) {d.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" в конец строки.
PIString & push_back(const char * str) {*this += str; return *this;}
PIString & push_back(const char * str) {
*this += str;
return *this;
}
//! \~english Insert string "str" at the end of string.
//! \~russian Вставляет "str" в конец строки.
PIString & push_back(const PIString & str) {d.push_back(str.d); return *this;}
PIString & push_back(const PIString & str) {
d.push_back(str.d);
return *this;
}
PIString & push_back(const PIConstChars & str) {*this += str; return *this;}
PIString & push_back(const PIConstChars & str) {
*this += str;
return *this;
}
//! \~english Insert character `c` at the end of string.
//! \~russian Вставляет символ `c` в конец строки.
PIString & push_back(const PIChar c) {d.push_back(c); return *this;}
PIString & push_back(const PIChar c) {
d.push_back(c);
return *this;
}
//! \~english Insert character `c` at the end of string.
//! \~russian Вставляет символ `c` в конец строки.
PIString & push_back(const char c) {d.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 character at index "start" and maximum length "len".
//! \~russian Возвращает подстроку от символа "start" и максимальной длиной "len".
PIString mid(int start, int len = -1) const;
//! \~english Synonym of \a mid().
//! \~russian Аналог \a mid().
PIString subString(int start, int len = -1) const {return mid(start, len);}
PIString subString(int start, int len = -1) const { return mid(start, len); }
//! \~english Returns part of string from start and maximum length "len".
//! \~russian Возвращает подстроку от начала и максимальной длиной "len".
//! \~\details
@@ -450,8 +559,8 @@ public:
//! piCout << s.left(15); // s = "0123456789"
//! \endcode
//! \~\sa \a mid(), \a right()
PIString left(int len) const {return len <= 0 ? PIString() : mid(0, len);}
PIString left(int len) const { return len <= 0 ? PIString() : mid(0, len); }
//! \~english Returns part of string at end and maximum length "len".
//! \~russian Возвращает подстроку максимальной длиной "len" и до конца.
//! \~\details
@@ -463,12 +572,12 @@ public:
//! piCout << s.right(15); // s = "0123456789"
//! \endcode
//! \~\sa \a mid(), \a left()
PIString right(int len) const {return len <= 0 ? PIString() : mid(size() - len, len);}
PIString right(int len) const { return len <= 0 ? PIString() : mid(size() - len, len); }
//! \~english Remove part of string from character as index "start" and maximum length "len" and return this string.
//! \~russian Удаляет часть строки от символа "start" и максимальной длины "len", возвращает эту строку.
PIString & cutMid(int start, int len);
//! \~english Remove part of string from start and maximum length "len" and return this string.
//! \~russian Удаляет часть строки от начала и максимальной длины "len", возвращает эту строку.
//! \~\details
@@ -482,8 +591,8 @@ public:
//! piCout << s; // s = ""
//! \endcode
//! \~\sa \a cutMid(), \a cutRight()
PIString & cutLeft(int len) {return len <= 0 ? *this : cutMid(0, len);}
PIString & cutLeft(int len) { return len <= 0 ? *this : cutMid(0, len); }
//! \~english Remove part of string at end and maximum length "len" and return this string.
//! \~russian Удаляет часть строки максимальной длины "len" от конца, возвращает эту строку.
//! \~\details
@@ -497,7 +606,7 @@ public:
//! piCout << s; // s = ""
//! \endcode
//! \~\sa \a cutMid(), \a cutLeft()
PIString & cutRight(int len) {return len <= 0 ? *this : cutMid(size() - len, len);}
PIString & cutRight(int len) { return len <= 0 ? *this : cutMid(size() - len, len); }
//! \~english Remove spaces at the start and at the end of string and return this string.
//! \~russian Удаляет пробельные символы с начала и конца строки и возвращает эту строку.
@@ -512,12 +621,12 @@ public:
//! piCout << s; // s = " string "
//! \endcode
//! \~\sa \a trim()
PIString trimmed() const;
PIString trimmed() const;
//! \~english Replace part of string from index "from" and maximum length "len" with string "with" and return this string.
//! \~russian Заменяет часть строки от символа "from" и максимальной длины "len" строкой "with", возвращает эту строку.
PIString & replace(const int from, const int count, const PIString & with);
//! \~english Replace part copy of this string from index "from" and maximum length "len" with string "with".
//! \~russian Заменяет часть копии этой строки от символа "from" и максимальной длины "len" строкой "with".
//! \~\details
@@ -527,12 +636,16 @@ public:
//! piCout << s.replaced(0, 1, "one_"); // s = "one_123456789"
//! \endcode
//! \~\sa \a replace(), \a replaceAll()
PIString replaced(const int from, const int count, const PIString & with) const {PIString str(*this); str.replace(from, count, with); return str;}
PIString replaced(const int from, const int count, const PIString & with) const {
PIString str(*this);
str.replace(from, count, with);
return str;
}
//! \~english Replace first founded substring "what" with string "with" and return this string.
//! \~russian Заменяет первую найденную подстроку "what" строкой "with", возвращает эту строку.
PIString & replace(const PIString & what, const PIString & with, bool * ok = 0);
//! \~english Replace in string copy first founded substring "what" with string "with".
//! \~russian Заменяет в копии строки первую найденную подстроку "what" строкой "with".
//! \~\details
@@ -545,8 +658,12 @@ public:
//! piCout << s.replace("PIP", "PlInPr", &ok); // s = "pip string", false
//! \endcode
//! \~\sa \a replaced(), \a replaceAll()
PIString replaced(const PIString & what, const PIString & with, bool * ok = 0) const {PIString str(*this); str.replace(what, with, ok); return str;}
PIString replaced(const PIString & what, const PIString & with, bool * ok = 0) const {
PIString str(*this);
str.replace(what, with, ok);
return str;
}
//! \~english Replace all founded substrings "what" with strings "with" and return this string.
//! \~russian Заменяет все найденные подстроки "what" строками "with", возвращает эту строку.
PIString & replaceAll(const PIString & what, const PIString & with);
@@ -562,17 +679,29 @@ public:
//! \~english Replace all founded substrings "what" with strings "with" in string copy.
//! \~russian Заменяет в копии строки все найденные подстроки "what" строками "with".
//! \~\sa \a replaceAll()
PIString replacedAll(const PIString & what, const PIString & with) const {PIString str(*this); str.replaceAll(what, with); return str;}
PIString replacedAll(const PIString & what, const PIString & with) const {
PIString str(*this);
str.replaceAll(what, with);
return str;
}
//! \~english Replace all founded substrings "what" with characters "with" in string copy.
//! \~russian Заменяет в копии строки все найденные подстроки "what" символами "with".
//! \~\sa \a replaceAll()
PIString replacedAll(const PIString & what, const char with) const {PIString str(*this); str.replaceAll(what, with); return str;}
PIString replacedAll(const PIString & what, const char with) const {
PIString str(*this);
str.replaceAll(what, with);
return str;
}
//! \~english Replace all founded characters "what" with characters "with" in string copy.
//! \~russian Заменяет в копии строки все найденные символы "what" символами "with".
//! \~\sa \a replaceAll()
PIString replacedAll(const char what, const char with) const {PIString str(*this); str.replaceAll(what, with); return str;}
PIString replacedAll(const char what, const char with) const {
PIString str(*this);
str.replaceAll(what, with);
return str;
}
//! \~english Remove all founded substrings "what" and return this string.
//! \~russian Удаляет все найденные подстроки "what", возвращает эту строку.
@@ -580,7 +709,10 @@ public:
//! \~english Remove all founded characters "what" and return this string.
//! \~russian Удаляет все найденные символы "what", возвращает эту строку.
PIString & removeAll(char c) {d.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" раз и возвращает эту строку.
@@ -591,8 +723,13 @@ public:
//! piCout << s; // :-) :-) :-)
//! \endcode
//! \~\sa \a repeated()
PIString & repeat(int times) {PIString ss(*this); times--; piForTimes (times) *this += ss; return *this;}
PIString & repeat(int times) {
PIString ss(*this);
times--;
piForTimes(times) * this += ss;
return *this;
}
//! \~english Returns repeated "times" times string.
//! \~russian Возвращает повторённую "times" раз строку.
//! \~\details
@@ -602,8 +739,11 @@ public:
//! piCout << s; // :-)
//! \endcode
//! \~\sa \a repeat()
PIString repeated(int times) const {PIString ss(*this); return ss.repeat(times);}
PIString repeated(int times) const {
PIString ss(*this);
return ss.repeat(times);
}
//! \~english Insert character "c" after index "index" and return this string.
//! \~russian Вставляет символ "c" после позиции "index" и возвращает эту строку.
//! \~\details
@@ -612,8 +752,11 @@ public:
//! s.insert(1, "i");
//! piCout << s; // s = "pip"
//! \endcode
PIString & insert(const int index, const PIChar c) {d.insert(index, c); return *this;}
PIString & insert(const int index, const PIChar c) {
d.insert(index, c);
return *this;
}
//! \~english Insert character "c" after index "index" and return this string.
//! \~russian Вставляет символ "c" после позиции "index" и возвращает эту строку.
//! \~\details
@@ -622,8 +765,8 @@ public:
//! s.insert(1, 'i');
//! piCout << s; // s = "pip"
//! \endcode
PIString & insert(const int index, const char c) {return insert(index, PIChar(c));}
PIString & insert(const int index, const char c) { return insert(index, PIChar(c)); }
//! \~english Insert string "str" after index "index" and return this string.
//! \~russian Вставляет строку "str" после позиции "index" и возвращает эту строку.
//! \~\details
@@ -633,7 +776,7 @@ public:
//! piCout << s; // s = "string"
//! \endcode
PIString & insert(const int index, const PIString & str);
//! \~english Insert string "str" after index "index" and return this string.
//! \~russian Вставляет строку "str" после позиции "index" и возвращает эту строку.
//! \~\details
@@ -642,8 +785,8 @@ public:
//! s.insert(2, "rin");
//! piCout << s; // s = "string"
//! \endcode
PIString & insert(const int index, const char * c) {return insert(index, PIString(c));}
PIString & insert(const int index, const char * c) { return insert(index, PIString(c)); }
//! \~english Enlarge string to length "len" by addition characters "c" at the end, and return this string.
//! \~russian Увеличивает длину строки до "len" добавлением символов "c" в конец и возвращает эту строку.
//! \~\details
@@ -655,8 +798,11 @@ public:
//! piCout << s; // s = "str___"
//! \endcode
//! \~\sa \a expandLeftTo(), \a expandedRightTo(), \a expandedLeftTo()
PIString & expandRightTo(const int len, const PIChar c) {if (len > d.size_s()) d.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 characters "c" at the begin, and return this string.
//! \~russian Увеличивает длину строки до "len" добавлением символов "c" в начало и возвращает эту строку.
//! \~\details
@@ -668,7 +814,10 @@ public:
//! piCout << s; // s = "___str"
//! \endcode
//! \~\sa \a expandRightTo(), \a expandedRightTo(), \a expandedLeftTo()
PIString & expandLeftTo(const int len, const PIChar c) {if (len > d.size_s()) insert(0, PIString(len - d.size_s(), 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 characters "c" at the end.
//! \~russian Увеличивает длину копии этой строки до "len" добавлением символов "c" в конец.
@@ -679,7 +828,7 @@ public:
//! piCout << s; // s = "str"
//! \endcode
//! \~\sa \a expandRightTo(), \a expandLeftTo(), \a expandedLeftTo()
PIString expandedRightTo(const int len, const PIChar c) const {return PIString(*this).expandRightTo(len, c);}
PIString expandedRightTo(const int len, const PIChar c) const { return PIString(*this).expandRightTo(len, c); }
//! \~english Enlarge copy of this string to length "len" by addition characters "c" at the begin.
//! \~russian Увеличивает длину копии этой строки до "len" добавлением символов "c" в начало.
@@ -690,7 +839,7 @@ public:
//! piCout << s; // s = "str"
//! \endcode
//! \~\sa \a expandRightTo(), \a expandLeftTo(), \a expandedRightTo()
PIString expandedLeftTo(const int len, const PIChar c) const {return PIString(*this).expandLeftTo(len, c);}
PIString expandedLeftTo(const int len, const PIChar c) const { return PIString(*this).expandLeftTo(len, c); }
//! \~english Add "c" characters at the beginning and end, and return this string.
//! \~russian Добавляет символ "c" в начало и конец и возвращает эту строку.
@@ -701,7 +850,11 @@ public:
//! piCout << s; // s = ""str""
//! \endcode
//! \~\sa \a quoted()
PIString & quote(PIChar c = PIChar('"')) {d.prepend(c); d.append(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".
@@ -712,8 +865,8 @@ public:
//! piCout << s; // s = "str"
//! \endcode
//! \~\sa \a quote()
PIString quoted(PIChar c = PIChar('"')) {return PIString(*this).quote(c);}
PIString quoted(PIChar c = PIChar('"')) { return PIString(*this).quote(c); }
//! \~english Reverse string and return this string.
//! \~russian Разворачивает и возвращает эту строку.
//! \~\details
@@ -723,8 +876,11 @@ public:
//! piCout << s; // s = "9876543210"
//! \endcode
//! \~\sa \a reversed()
PIString & reverse() {d.reverse(); return *this;}
PIString & reverse() {
d.reverse();
return *this;
}
//! \~english Reverse copy of this string.
//! \~russian Разворачивает копию этой строки.
//! \~\details
@@ -734,7 +890,10 @@ public:
//! piCout << s; // s = "0123456789"
//! \endcode
//! \~\sa \a reverse()
PIString reversed() const {PIString ret(*this); return ret.reverse();}
PIString reversed() const {
PIString ret(*this);
return ret.reverse();
}
//! \~english Fit string to maximum size "size" by inserting ".." at position "pos" and return this string.
//! \~russian Уменьшает строку до размера "size", вставляя ".." в положение "pos" и возвращает эту строку.
@@ -751,9 +910,13 @@ public:
//! piCout << PIString("123456789ABCDEF").elided(8, 0.25); // 12..CDEF
//! \endcode
//! \~\sa \a elide()
PIString elided(int size, float pos = ElideCenter) const {PIString str(*this); str.elide(size, pos); return str;}
PIString elided(int size, float pos = ElideCenter) const {
PIString str(*this);
str.elide(size, pos);
return str;
}
//! \~english Take a part of string from character at index "start" and maximum length "len" and return it.
//! \~russian Извлекает часть строки от символа "start" максимальной длины "len" и возвращает её.
//! \~\details
@@ -763,8 +926,12 @@ public:
//! piCout << s; // s = "0456789"
//! \endcode
//! \~\sa \a takeLeft, \a takeRight()
PIString takeMid(const int start, const int len = -1) {PIString ret(mid(start, len)); cutMid(start, len); return ret;}
PIString takeMid(const int start, const int len = -1) {
PIString ret(mid(start, len));
cutMid(start, len);
return ret;
}
//! \~english Take a part from the begin of string with maximum length "len" and return it.
//! \~russian Извлекает часть строки от начала максимальной длины "len" и возвращает её.
//! \~\details
@@ -774,8 +941,12 @@ public:
//! piCout << s; // s = "3456789"
//! \endcode
//! \~\sa \a takeMid(), \a takeRight()
PIString takeLeft(const int len) {PIString ret(left(len)); cutLeft(len); return ret;}
PIString takeLeft(const int len) {
PIString ret(left(len));
cutLeft(len);
return ret;
}
//! \~english Take a part from the end of string with maximum length "len" and return it.
//! \~russian Извлекает часть строки с конца максимальной длины "len" и возвращает её.
//! \~\details
@@ -785,24 +956,28 @@ public:
//! piCout << s; // s = "0123456"
//! \endcode
//! \~\sa \a takeMid(), \a takeLeft()
PIString takeRight(const int len) {PIString ret(right(len)); cutRight(len); return ret;}
PIString takeRight(const int len) {
PIString ret(right(len));
cutRight(len);
return ret;
}
//! \~english Take a character from the begin of this string and return it.
//! \~russian Извлекает символ с начала строки и возвращает его как строку.
PIString takeSymbol();
//! \~english Take a word from the begin of this string and return it.
//! \~russian Извлекает слово с начала строки и возвращает его.
PIString takeWord();
//! \~english Take a word with letters, numbers and '_' characters from the begin of this string and return it.
//! \~russian Извлекает слово из букв, цифр и симолов '_' с начала строки и возвращает его.
PIString takeCWord();
//! \~english Take a line from the begin of this string and return it.
//! \~russian Извлекает строку текста (до новой строки) с начала строки и возвращает её.
PIString takeLine();
//! \~english Take a number with C-format from the begin of this string and return it.
//! \~russian Извлекает число в C-формате с начала строки и возвращает его как строку.
PIString takeNumber();
@@ -810,7 +985,7 @@ public:
//! \~english Take a digits from the begin of this string and return it.
//! \~russian Извлекает цифры с начала строки и возвращает их как строку.
PIString takeInteger();
//! \~english Take a range between "start" and "end" characters from the begin of this string and return it.
//! \~russian Извлекает диапазон между символами "start" и "end" с начала строки и возвращает его.
PIString takeRange(const PIChar start, const PIChar end, const PIChar shield = '\\');
@@ -819,19 +994,19 @@ public:
//! \~english Returns string in brackets "start" and "end" characters from the beginning.
//! \~russian Возвращает строку между символами "start" и "end" с начала строки.
PIString inBrackets(const PIChar start, const PIChar end) const;
//! \~english Returns \c char * representation of this string in system codepage.
//! \~russian Возвращает \c char * представление строки в системной кодировке.
const char * data() const;
//! \~english Returns \c char * representation of this string in terminal codepage.
//! \~russian Возвращает \c char * представление строки в кодировке консоли.
const char * dataConsole() const;
//! \~english Returns \c char * representation of this string in UTF-8.
//! \~russian Возвращает \c char * представление строки в кодировке UTF-8.
const char * dataUTF8() const;
//! \~english Returns \c char * representation of this string in ASCII.
//! \~russian Возвращает \c char * представление строки в кодировке ASCII.
const char * dataAscii() const;
@@ -842,7 +1017,7 @@ public:
//! \~english Same as \a toUTF8().
//! \~russian Тоже самое, что \a toUTF8().
PIByteArray toByteArray() const {return toUTF8();}
PIByteArray toByteArray() const { return toUTF8(); }
//! \~english Returns \a PIByteArray contains \a data() of this string without terminating null-char.
//! \~russian Возвращает \a PIByteArray содержащий \a data() строки без завершающего нулевого байта.
@@ -864,13 +1039,13 @@ public:
//! \~russian Вставляет перед любым символом из "symbols" символ "mc" и возвращает эту строку.
PIString & mask(const PIString & symbols, const PIChar mc = '\\');
PIString masked(const PIString & symbols, const PIChar mc = '\\') const {return PIString(*this).mask(symbols, mc);}
PIString masked(const PIString & symbols, const PIChar mc = '\\') const { return PIString(*this).mask(symbols, mc); }
//! \~english Remove symbol "mc" before any symbol from "symbols" and return this string.
//! \~russian Удаляет символ "mc" перед любым символом из "symbols" и возвращает эту строку.
PIString & unmask(const PIString & symbols, const PIChar mc = '\\');
PIString unmasked(const PIString & symbols, const PIChar mc = '\\') const {return PIString(*this).unmask(symbols, mc);}
PIString unmasked(const PIString & symbols, const PIChar mc = '\\') const { return PIString(*this).unmask(symbols, mc); }
//! \~english Split string with delimiter "delim" to \a PIStringList.
//! \~russian Разделяет строку в \a PIStringList через разделитель "delim".
@@ -885,7 +1060,7 @@ public:
//! \~english Convert each character in copied string to upper case.
//! \~russian Преобразует каждый символ в скопированной строке в верхний регистр.
PIString toUpperCase() const;
//! \~english Convert each character in copied string to lower case.
//! \~russian Преобразует каждый символ в скопированной строке в нижний регистр.
PIString toLowerCase() const;
@@ -893,29 +1068,29 @@ public:
//! \~english Returns if string contains character "c".
//! \~russian Возвращает содержит ли строка символ "c".
bool contains(const char c) const {return d.contains(PIChar(c));}
bool contains(const char c) const { return d.contains(PIChar(c)); }
//! \~english Returns if string contains character "c".
//! \~russian Возвращает содержит ли строка символ "c".
bool contains(const PIChar c) const {return d.contains(c);}
bool contains(const PIChar c) const { return d.contains(c); }
//! \~english Returns if string contains substring "str".
//! \~russian Возвращает содержит ли строка подстроку "str".
bool contains(const char * str) const {return contains(PIString(str));}
bool contains(const char * str) const { return contains(PIString(str)); }
//! \~english Returns if string contains substring "str".
//! \~russian Возвращает содержит ли строка подстроку "str".
bool contains(const PIString & str) const {return find(str) >= 0;}
bool contains(const PIString & str) const { return find(str) >= 0; }
//! \~english Search character "c" from character at index "start" and return first occur position.
//! \~russian Ищет символ "c" от символа "start" и возвращает первое вхождение.
int find(const char c, const int start = 0) const;
//! \~english Search character "c" from character 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 find(PIChar c, const int start = 0) const { return d.indexOf(c, start); }
//! \~english Search substring "str" from character at index "start" and return first occur position.
//! \~russian Ищет подстроку "str" от символа "start" и возвращает первое вхождение.
int find(const PIString & str, const int start = 0) const;
@@ -931,7 +1106,7 @@ public:
//! piCout << s.find("3", 10); // -1
//! \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 find(const char * str, const int start = 0) const { return find(PIString(str), start); }
//! \~english Search any character of "str" from character at index "start" and return first occur position.
//! \~russian Ищет любой символ строки "str" от симола "start" и возвращает первое вхождение.
@@ -946,12 +1121,12 @@ public:
//! piCout << PIString("1:str").findAny(".,:"); // 1
//! \endcode
//! \~\sa \a find(), \a findLast(), \a findAnyLast(), \a findWord(), \a findCWord(), \a findRange()
int findAny(const char * str, const int start = 0) const {return findAny(PIString(str), start);}
int findAny(const char * str, const int start = 0) const { return findAny(PIString(str), start); }
//! \~english Search character "c" from character at index "start" and return last occur position.
//! \~russian Ищет символ "c" от символа "start" и возвращает последнее вхождение.
int findLast(const char c, const int start = 0) const;
//! \~english Search character "c" from character at index "start" and return last occur position.
//! \~russian Ищет символ "c" от символа "start" и возвращает последнее вхождение.
int findLast(PIChar c, const int start = 0) const;
@@ -959,7 +1134,7 @@ public:
//! \~english Search substring "str" from character at index "start" and return last occur position.
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение.
int findLast(const PIString & str, const int start = 0) const;
//! \~english Search substring "str" from character at index "start" and return last occur position.
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение.
//! \~\details
@@ -971,7 +1146,7 @@ public:
//! piCout << s.findLast("3", 10); // -1
//! \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 findLast(const char * str, const int start = 0) const { return findLast(PIString(str), start); }
//! \~english Search any character of "str" from character at index "start" and return last occur position.
//! \~russian Ищет любой символ строки "str" от символа "start" и возвращает последнее вхождение.
@@ -986,12 +1161,12 @@ public:
//! piCout << PIString(".str:0").findAnyLast(".,:"); // 4
//! \endcode
//! \~\sa \a find(), \a findAny(), \a findLast(), \a findWord(), \a findCWord(), \a findRange()
int findAnyLast(const char * str, const int start = 0) const {return findAnyLast(PIString(str), start);}
int findAnyLast(const char * str, const int start = 0) const { return findAnyLast(PIString(str), start); }
//! \~english Search word "word" from character at index "start" and return first occur position.
//! \~russian Ищет слово "word" от симола "start" и возвращает первое вхождение.
int findWord(const PIString & word, const int start = 0) const;
//! \~english Search C-word "word" from character at index "start" and return first occur position.
//! \~russian Ищет C-слово "word" от симола "start" и возвращает первое вхождение.
int findCWord(const PIString & word, const int start = 0) const;
@@ -1016,35 +1191,39 @@ public:
//! piCout << PIString(".str.0").entries('.'); // 2
//! piCout << PIString(".str.0").entries('0'); // 1
//! \endcode
int entries(char c) const {return entries(PIChar(c));}
int entries(char c) const { return entries(PIChar(c)); }
//! \~english Returns if string starts with "str".
//! \~russian Возвращает начинается ли строка со "str".
bool startsWith(const PIString & str) const;
//! \~english Returns if string ends with "str".
//! \~russian Возвращает оканчивается ли строка на "str".
bool endsWith(const PIString & str) const;
//! \~english Returns characters length of string.
//! \~russian Возвращает длину строки в символах.
int length() const {return d.size_s();}
int length() const { return d.size_s(); }
//! \~english Returns characters length of string.
//! \~russian Возвращает длину строки в символах.
size_t size() const {return d.size();}
size_t size() const { return d.size(); }
//! \~english Returns characters length of string.
//! \~russian Возвращает длину строки в символах.
ssize_t size_s() const {return d.size_s();}
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 {if (d.isEmpty()) return true; if (d.at(0) == PIChar()) return true; return false;}
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();}
bool isNotEmpty() const { return !isEmpty(); }
//! \~english Clear string, will be empty string.
//! \~russian Очищает строку, строка становится пустой.
@@ -1053,16 +1232,16 @@ public:
//! \~english Reserved memory will not be released.
//! \~russian Зарезервированная память не освободится.
//! \~\sa \a resize()
void clear() {d.clear();}
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.
bool toBool() const;
//! \~english Returns \c char numeric value of string.
//! \~russian Возвращает \c char числовое значение строки.
char toChar() const;
//! \~english Returns \c short numeric value of string in base "base".
//! \~russian Возвращает \c short числовое значение строки по основанию "base".
//! \~\details
@@ -1074,8 +1253,8 @@ public:
//! piCout << PIString("0x123").toShort(); // 291
//! piCout << PIString("1001").toShort(2); // 9
//! \endcode
short toShort(int base = -1, bool * ok = 0) const {return short(toNumberBase(*this, base, ok));}
short toShort(int base = -1, bool * ok = 0) const { return short(toNumberBase(*this, base, ok)); }
//! \~english Returns \c ushort numeric value of string in base "base".
//! \~russian Возвращает \c ushort числовое значение строки по основанию "base".
//! \~\details
@@ -1087,8 +1266,8 @@ public:
//! piCout << PIString("0x123").toUShort(); // 291
//! piCout << PIString("1001").toUShort(2); // 9
//! \endcode
ushort toUShort(int base = -1, bool * ok = 0) const {return ushort(toNumberBase(*this, base, ok));}
ushort toUShort(int base = -1, bool * ok = 0) const { return ushort(toNumberBase(*this, base, ok)); }
//! \~english Returns \c int numeric value of string in base "base".
//! \~russian Возвращает \c int числовое значение строки по основанию "base".
//! \~\details
@@ -1100,8 +1279,8 @@ public:
//! piCout << PIString("0x123").toInt(); // 291
//! piCout << PIString("1001").toInt(2); // 9
//! \endcode
int toInt(int base = -1, bool * ok = 0) const {return int(toNumberBase(*this, base, ok));}
int toInt(int base = -1, bool * ok = 0) const { return int(toNumberBase(*this, base, ok)); }
//! \~english Returns \c uint numeric value of string in base "base".
//! \~russian Возвращает \c uint числовое значение строки по основанию "base".
//! \~\details
@@ -1113,8 +1292,8 @@ public:
//! piCout << PIString("0x123").toUInt(); // 291
//! piCout << PIString("1001").toUInt(2); // 9
//! \endcode
uint toUInt(int base = -1, bool * ok = 0) const {return uint(toNumberBase(*this, base, ok));}
uint toUInt(int base = -1, bool * ok = 0) const { return uint(toNumberBase(*this, base, ok)); }
//! \~english Returns \c long numeric value of string in base "base".
//! \~russian Возвращает \c long числовое значение строки по основанию "base".
//! \~\details
@@ -1126,8 +1305,8 @@ public:
//! piCout << PIString("0x123").toLong(); // 291
//! piCout << PIString("1001").toLong(2); // 9
//! \endcode
long toLong(int base = -1, bool * ok = 0) const {return long(toNumberBase(*this, base, ok));}
long toLong(int base = -1, bool * ok = 0) const { return long(toNumberBase(*this, base, ok)); }
//! \~english Returns \c ulong numeric value of string in base "base".
//! \~russian Возвращает \c ulong числовое значение строки по основанию "base".
//! \~\details
@@ -1139,8 +1318,8 @@ public:
//! piCout << PIString("0x123").toULong(); // 291
//! piCout << PIString("1001").toULong(2); // 9
//! \endcode
ulong toULong(int base = -1, bool * ok = 0) const {return ulong(toNumberBase(*this, base, ok));}
ulong toULong(int base = -1, bool * ok = 0) const { return ulong(toNumberBase(*this, base, ok)); }
//! \~english Returns \c llong numeric value of string in base "base".
//! \~russian Возвращает \c llong числовое значение строки по основанию "base".
//! \~\details
@@ -1152,8 +1331,8 @@ public:
//! piCout << PIString("0x123").toLLong(); // 291
//! piCout << PIString("1001").toLLong(2); // 9
//! \endcode
llong toLLong(int base = -1, bool * ok = 0) const {return toNumberBase(*this, base, ok);}
llong toLLong(int base = -1, bool * ok = 0) const { return toNumberBase(*this, base, ok); }
//! \~english Returns \c ullong numeric value of string in base "base".
//! \~russian Возвращает \c ullong числовое значение строки по основанию "base".
//! \~\details
@@ -1165,8 +1344,8 @@ public:
//! piCout << PIString("0x123").toULLong(); // 291
//! piCout << PIString("1001").toULLong(2); // 9
//! \endcode
ullong toULLong(int base = -1, bool * ok = 0) const {return ullong(toNumberBase(*this, base, ok));}
ullong toULLong(int base = -1, bool * ok = 0) const { return ullong(toNumberBase(*this, base, ok)); }
//! \~english Returns \c float numeric value of string.
//! \~russian Возвращает \c float числовое значение строки.
//! \~\details
@@ -1176,7 +1355,7 @@ public:
//! piCout << PIString("0.01").toFloat(); // 0.01
//! \endcode
float toFloat() const;
//! \~english Returns \c double numeric value of string.
//! \~russian Возвращает \c double числовое значение строки.
//! \~\details
@@ -1186,7 +1365,7 @@ public:
//! piCout << PIString("0.01").toDouble(); // 0.01
//! \endcode
double toDouble() const;
//! \~english Returns \c ldouble numeric value of string.
//! \~russian Возвращает \c ldouble числовое значение строки.
//! \~\details
@@ -1207,8 +1386,11 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
PIString & setNumber(const short value, int base = 10, bool * ok = 0) {*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" и возвращает эту строку.
//! \~\details
@@ -1219,8 +1401,11 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
PIString & setNumber(const ushort value, int base = 10, bool * ok = 0) {*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" и возвращает эту строку.
//! \~\details
@@ -1231,8 +1416,11 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
PIString & setNumber(const int value, int base = 10, bool * ok = 0) {*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" и возвращает эту строку.
//! \~\details
@@ -1243,8 +1431,11 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
PIString & setNumber(const uint value, int base = 10, bool * ok = 0) {*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" и возвращает эту строку.
//! \~\details
@@ -1255,8 +1446,11 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
PIString & setNumber(const long value, int base = 10, bool * ok = 0) {*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" и возвращает эту строку.
//! \~\details
@@ -1267,8 +1461,11 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
PIString & setNumber(const ulong value, int base = 10, bool * ok = 0) {*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" и возвращает эту строку.
//! \~\details
@@ -1279,8 +1476,11 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
PIString & setNumber(const llong & value, int base = 10, bool * ok = 0) {*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" и возвращает эту строку.
//! \~\details
@@ -1291,10 +1491,15 @@ public:
//! s.setNumber(123, 16);
//! piCout << s; // 7B
//! \endcode
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" и возвращает эту строку.
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" и возвращает
//! эту строку.
//! \~\details
//! \~\code
//! PIString s;
@@ -1309,10 +1514,15 @@ public:
//! s.setNumber(123456789., 'f', 0);
//! piCout << s; // 123456789
//! \endcode
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" и возвращает эту строку.
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" и возвращает
//! эту строку.
//! \~\details
//! \~\code
//! PIString s;
@@ -1327,10 +1537,15 @@ public:
//! s.setNumber(123456789., 'f', 0);
//! piCout << s; // 123456789
//! \endcode
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" и возвращает эту строку.
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" и возвращает
//! эту строку.
//! \~\details
//! \~\code
//! PIString s;
@@ -1345,8 +1560,11 @@ public:
//! s.setNumber(123456789., 'f', 0);
//! piCout << s; // 123456789
//! \endcode
PIString & setNumber(const ldouble & value, char format = 'f', int precision = 8) {*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.
//! \~\sa PIString::readableSize()
@@ -1359,8 +1577,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const short value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
static PIString fromNumber(const short value, int base = 10, bool * ok = 0) { return fromNumberBaseS(llong(value), base, ok); }
//! \~english Returns string contains numeric representation of "value" in base "base".
//! \~russian Возвращает строковое представление числа "value" по основанию "base".
//! \~\details
@@ -1368,8 +1586,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const ushort value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
static PIString fromNumber(const ushort value, int base = 10, bool * ok = 0) { return fromNumberBaseU(ullong(value), base, ok); }
//! \~english Returns string contains numeric representation of "value" in base "base".
//! \~russian Возвращает строковое представление числа "value" по основанию "base".
//! \~\details
@@ -1377,8 +1595,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const int value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
static PIString fromNumber(const int value, int base = 10, bool * ok = 0) { return fromNumberBaseS(llong(value), base, ok); }
//! \~english Returns string contains numeric representation of "value" in base "base".
//! \~russian Возвращает строковое представление числа "value" по основанию "base".
//! \~\details
@@ -1386,8 +1604,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const uint value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
static PIString fromNumber(const uint value, int base = 10, bool * ok = 0) { return fromNumberBaseU(ullong(value), base, ok); }
//! \~english Returns string contains numeric representation of "value" in base "base".
//! \~russian Возвращает строковое представление числа "value" по основанию "base".
//! \~\details
@@ -1395,8 +1613,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const long value, int base = 10, bool * ok = 0) {return fromNumberBaseS(llong(value), base, ok);}
static PIString fromNumber(const long value, int base = 10, bool * ok = 0) { return fromNumberBaseS(llong(value), base, ok); }
//! \~english Returns string contains numeric representation of "value" in base "base".
//! \~russian Возвращает строковое представление числа "value" по основанию "base".
//! \~\details
@@ -1404,8 +1622,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const ulong value, int base = 10, bool * ok = 0) {return fromNumberBaseU(ullong(value), base, ok);}
static PIString fromNumber(const ulong value, int base = 10, bool * ok = 0) { return fromNumberBaseU(ullong(value), base, ok); }
//! \~english Returns string contains numeric representation of "value" in base "base".
//! \~russian Возвращает строковое представление числа "value" по основанию "base".
//! \~\details
@@ -1413,8 +1631,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const llong & value, int base = 10, bool * ok = 0) {return fromNumberBaseS(value, base, ok);}
static PIString fromNumber(const llong & value, int base = 10, bool * ok = 0) { return fromNumberBaseS(value, base, ok); }
//! \~english Returns string contains numeric representation of "value" in base "base".
//! \~russian Возвращает строковое представление числа "value" по основанию "base".
//! \~\details
@@ -1422,8 +1640,8 @@ public:
//! piCout << PIString::fromNumber(123); // 123
//! piCout << PIString::fromNumber(123, 16); // 7B
//! \endcode
static PIString fromNumber(const ullong & value, int base = 10, bool * ok = 0) {return fromNumberBaseU(value, base, ok);}
static PIString fromNumber(const ullong & value, int base = 10, bool * ok = 0) { return fromNumberBaseU(value, base, ok); }
//! \~english Returns string contains numeric representation of "value" with format "format" and precision "precision".
//! \~russian Возвращает строковое представление числа "value" в формате "format" и точностью "precision".
//! \~\details
@@ -1434,8 +1652,8 @@ public:
//! piCout << PIString::fromNumber(123456789., 'g', 2); // 1.2e+08
//! piCout << PIString::fromNumber(123456789., 'f', 0); // 123456789
//! \endcode
static PIString fromNumber(const float value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
static PIString fromNumber(const float value, char format = 'f', int precision = 8) { return dtos(value, format, precision); }
//! \~english Returns string contains numeric representation of "value" with format "format" and precision "precision".
//! \~russian Возвращает строковое представление числа "value" в формате "format" и точностью "precision".
//! \~\details
@@ -1446,8 +1664,8 @@ public:
//! piCout << PIString::fromNumber(123456789., 'g', 2); // 1.2e+08
//! piCout << PIString::fromNumber(123456789., 'f', 0); // 123456789
//! \endcode
static PIString fromNumber(const double & value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
static PIString fromNumber(const double & value, char format = 'f', int precision = 8) { return dtos(value, format, precision); }
//! \~english Returns string contains numeric representation of "value" with format "format" and precision "precision".
//! \~russian Возвращает строковое представление числа "value" в формате "format" и точностью "precision".
//! \~\details
@@ -1458,16 +1676,16 @@ public:
//! piCout << PIString::fromNumber(123456789., 'g', 2); // 1.2e+08
//! piCout << PIString::fromNumber(123456789., 'f', 0); // 123456789
//! \endcode
static PIString fromNumber(const ldouble & value, char format = 'f', int precision = 8) {return dtos(value, format, precision);}
static PIString fromNumber(const ldouble & value, char format = 'f', int precision = 8) { return dtos(value, format, precision); }
//! \~english Returns "true" or "false"
//! \~russian Возвращает "true" или "false"
static PIString fromBool(const bool value) {return PIString(value ? PIStringAscii("true") : PIStringAscii("false"));}
static PIString fromBool(const bool value) { return PIString(value ? PIStringAscii("true") : PIStringAscii("false")); }
//! \~english Returns string constructed from terminal codepage.
//! \~russian Возвращает строку созданную из кодировки консоли.
static PIString fromConsole(const PIByteArray & s);
//! \~english Returns string constructed from terminal codepage.
//! \~russian Возвращает строку созданную из кодировки консоли.
static PIString fromConsole(const char * s);
@@ -1475,15 +1693,15 @@ public:
//! \~english Returns string constructed from system codepage.
//! \~russian Возвращает строку созданную из кодировки системы.
static PIString fromSystem(const PIByteArray & s);
//! \~english Returns string constructed from system codepage.
//! \~russian Возвращает строку созданную из кодировки системы.
static PIString fromSystem(const char * s);
//! \~english Returns string constructed from UTF-8.
//! \~russian Возвращает строку созданную из UTF-8.
static PIString fromUTF8(const char * s);
//! \~english Returns string constructed from UTF-8.
//! \~russian Возвращает строку созданную из UTF-8.
static PIString fromUTF8(const PIByteArray & utf);
@@ -1518,7 +1736,7 @@ public:
private:
static const char toBaseN[];
static const char fromBaseN[];
static PIString itos(const int num);
static PIString ltos(const long num);
static PIString lltos(const llong num);
@@ -1532,7 +1750,7 @@ private:
void appendFromChars(const char * c, int s, const char * cp = __syslocname__);
void buildData(const char * cp = __syslocname__) const;
void deleteData() const;
void trimsubstr(int &st, int &fn) const;
void trimsubstr(int & st, int & fn) const;
PIDeque<PIChar> d;
mutable char * data_ = nullptr;
@@ -1541,33 +1759,55 @@ private:
//! \relatesalso PIBinaryStream
//! \~english Store operator.
//! \~russian Оператор сохранения.
BINARY_STREAM_WRITE(PIString) {s << v.d; return s;}
BINARY_STREAM_WRITE(PIString) {
s << v.d;
return s;
}
//! \relatesalso PIBinaryStream
//! \~english Restore operator.
//! \~russian Оператор извлечения.
BINARY_STREAM_READ(PIString) {s >> v.d; return s;}
BINARY_STREAM_READ(PIString) {
s >> v.d;
return s;
}
//! \~english Returns concatenated string.
//! \~russian Возвращает соединение строк.
inline PIString operator +(const PIString & str, const PIString & f) {PIString s(str); s += f; return s;}
inline PIString operator+(const PIString & str, const PIString & f) {
PIString s(str);
s += f;
return s;
}
//! \~english Returns concatenated string.
//! \~russian Возвращает соединение строк.
inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;}
inline PIString operator+(const PIString & f, const char * str) {
PIString s(f);
s += str;
return s;
}
//! \~english Returns concatenated string.
//! \~russian Возвращает соединение строк.
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
inline PIString operator+(const char * str, const PIString & f) {
return PIString(str) + f;
}
//! \~english Returns concatenated string.
//! \~russian Возвращает соединение строк.
inline PIString operator +(const char c, const PIString & f) {return PIString(c) + f;}
inline PIString operator+(const char c, const PIString & f) {
return PIString(c) + f;
}
//! \~english Returns concatenated string.
//! \~russian Возвращает соединение строк.
inline PIString operator +(const PIString & f, const char c) {PIString s(f); s.push_back(c); return s;}
inline PIString operator+(const PIString & f, const char c) {
PIString s(f);
s.push_back(c);
return s;
}
//! \relatesalso PIString
@@ -1581,9 +1821,13 @@ int PIP_EXPORT versionCompare(const PIString & v0, const PIString & v1, int comp
PIString PIP_EXPORT versionNormalize(const PIString & v);
template<> inline uint piHash(const PIString & s) {return s.hash();}
template<>
inline uint piHash(const PIString & s) {
return s.hash();
}
template<> inline void piSwap(PIString & f, PIString & s) {
template<>
inline void piSwap(PIString & f, PIString & s) {
f.swap(s);
}