version 3.17.0
finally properly works PIIOString inside PIIOStream
This commit is contained in:
@@ -71,10 +71,12 @@ public:
|
||||
|
||||
PIString & operator+=(const PIChar & c) {
|
||||
d.push_back(c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
PIString & operator+=(const char c) {
|
||||
d.push_back(PIChar(c));
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
PIString & operator+=(const char * str);
|
||||
@@ -105,11 +107,17 @@ public:
|
||||
|
||||
//! \~english Contructs a copy of string.
|
||||
//! \~russian Создает копию строки.
|
||||
PIString(const PIString & o) { d = o.d; }
|
||||
PIString(const PIString & o) {
|
||||
d = o.d;
|
||||
changed_ = true;
|
||||
}
|
||||
|
||||
//! \~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_);
|
||||
changed_ = true;
|
||||
}
|
||||
|
||||
//! \~english Contructs string with single character "c".
|
||||
//! \~russian Создает строку из одного символа "c".
|
||||
@@ -197,7 +205,8 @@ public:
|
||||
//! \~russian Оператор присваивания.
|
||||
PIString & operator=(const PIString & o) {
|
||||
if (this == &o) return *this;
|
||||
d = o.d;
|
||||
d = o.d;
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -206,6 +215,7 @@ public:
|
||||
PIString & operator=(PIString && o) {
|
||||
d.swap(o.d);
|
||||
piSwap(data_, o.data_);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -367,7 +377,10 @@ public:
|
||||
//! \~russian Индекс элемента считается от `0`.
|
||||
//! Индекс символа должен лежать в пределах от `0` до `size()-1`.
|
||||
//! Иначе это приведёт к неопределённому поведению программы и ошибкам памяти.
|
||||
inline PIChar & operator[](size_t index) { return d[index]; }
|
||||
inline PIChar & operator[](size_t index) {
|
||||
changed_ = true;
|
||||
return d[index];
|
||||
}
|
||||
inline PIChar operator[](size_t index) const { return d[index]; }
|
||||
|
||||
//! \~english Read only access to character by `index`.
|
||||
@@ -383,10 +396,16 @@ public:
|
||||
|
||||
//! \~english Returns the last character of the string.
|
||||
//! \~russian Возвращает последний символ строки.
|
||||
inline PIChar & back() { return d.back(); }
|
||||
inline PIChar & back() {
|
||||
changed_ = true;
|
||||
return d.back();
|
||||
}
|
||||
inline PIChar back() const { return d.back(); }
|
||||
|
||||
inline PIChar & front() { return d.front(); }
|
||||
inline PIChar & front() {
|
||||
changed_ = true;
|
||||
return d.front();
|
||||
}
|
||||
inline PIChar front() const { return d.front(); }
|
||||
|
||||
//! \~english Sets size of the string, new characters are copied from `c`.
|
||||
@@ -402,6 +421,7 @@ public:
|
||||
//! \~\sa \a size(), \a clear()
|
||||
inline PIString & resize(size_t new_size, PIChar c = PIChar()) {
|
||||
d.resize(new_size, c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -409,6 +429,7 @@ public:
|
||||
//! \~russian Удаляет один символ с конца строки.
|
||||
inline PIString & pop_back() {
|
||||
d.pop_back();
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -416,6 +437,7 @@ public:
|
||||
//! \~russian Удаляет один символ с начала строки.
|
||||
inline PIString & pop_front() {
|
||||
d.pop_front();
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -423,6 +445,7 @@ public:
|
||||
//! \~russian Удаляет символы из строки, начиная с позиции `index` в количестве `count`.
|
||||
inline PIString & remove(size_t index, size_t count = 1) {
|
||||
d.remove(index, count);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -430,6 +453,7 @@ public:
|
||||
//! \~russian Заполняет всю строку символами `c`.
|
||||
inline PIString & fill(PIChar c = PIChar()) {
|
||||
d.fill(c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -444,6 +468,7 @@ public:
|
||||
//! \~russian Вставляет "str" в начало строки.
|
||||
PIString & prepend(const PIString & str) {
|
||||
d.prepend(str.d);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -451,6 +476,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в начало строки.
|
||||
PIString & prepend(const PIChar c) {
|
||||
d.prepend(c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -458,6 +484,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в начало строки.
|
||||
PIString & prepend(const char c) {
|
||||
d.prepend(PIChar(c));
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -465,6 +492,7 @@ public:
|
||||
//! \~russian Вставляет "str" в начало строки.
|
||||
PIString & push_front(const char * str) {
|
||||
insert(0, str);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -479,6 +507,7 @@ public:
|
||||
//! \~russian Вставляет "str" в начало строки.
|
||||
PIString & push_front(const PIString & str) {
|
||||
d.push_front(str.d);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -486,6 +515,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в начало строки.
|
||||
PIString & push_front(const PIChar c) {
|
||||
d.push_front(c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -493,6 +523,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в начало строки.
|
||||
PIString & push_front(const char c) {
|
||||
d.push_front(PIChar(c));
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -514,6 +545,7 @@ public:
|
||||
//! \~russian Вставляет "str" в конец строки.
|
||||
PIString & append(const PIString & str) {
|
||||
d.append(str.d);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -526,6 +558,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в конец строки.
|
||||
PIString & append(const PIChar c) {
|
||||
d.append(c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -533,6 +566,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в конец строки.
|
||||
PIString & append(const char c) {
|
||||
d.append(PIChar(c));
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -547,6 +581,7 @@ public:
|
||||
//! \~russian Вставляет "str" в конец строки.
|
||||
PIString & push_back(const PIString & str) {
|
||||
d.push_back(str.d);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -559,6 +594,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в конец строки.
|
||||
PIString & push_back(const PIChar c) {
|
||||
d.push_back(c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -566,6 +602,7 @@ public:
|
||||
//! \~russian Вставляет символ `c` в конец строки.
|
||||
PIString & push_back(const char c) {
|
||||
d.push_back(PIChar(c));
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -741,6 +778,7 @@ public:
|
||||
//! \~russian Удаляет все найденные символы "what", возвращает эту строку.
|
||||
PIString & removeAll(char c) {
|
||||
d.removeAll(PIChar(c));
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -757,6 +795,7 @@ public:
|
||||
PIString ss(*this);
|
||||
times--;
|
||||
piForTimes(times) * this += ss;
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -784,6 +823,7 @@ public:
|
||||
//! \endcode
|
||||
PIString & insert(const int index, const PIChar c) {
|
||||
d.insert(index, c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -840,6 +880,7 @@ public:
|
||||
//! \~\sa \a expandLeftTo(), \a expandedRightTo(), \a expandedLeftTo()
|
||||
PIString & expandRightTo(const int len, const PIChar c) {
|
||||
if (len > d.size_s()) d.resize(len, c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -856,6 +897,7 @@ public:
|
||||
//! \~\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));
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -893,6 +935,7 @@ public:
|
||||
PIString & quote(PIChar c = PIChar('"')) {
|
||||
d.prepend(c);
|
||||
d.append(c);
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -918,6 +961,7 @@ public:
|
||||
//! \~\sa \a reversed()
|
||||
PIString & reverse() {
|
||||
d.reverse();
|
||||
changed_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -1051,6 +1095,10 @@ public:
|
||||
//! \~russian Возвращает \c char * представление строки в кодировке ASCII.
|
||||
const char * dataAscii() const;
|
||||
|
||||
//! \~english Returns data size of last data*() call.
|
||||
//! \~russian Возвращает размер данных последнего вызова data*().
|
||||
const size_t lastDataSize() const { return data_size_; }
|
||||
|
||||
//! \~english Returns hash of string
|
||||
//! \~russian Возвращает хэш строки
|
||||
uint hash() const;
|
||||
@@ -1279,7 +1327,10 @@ public:
|
||||
//! \~english Reserved memory will not be released.
|
||||
//! \~russian Зарезервированная память не освободится.
|
||||
//! \~\sa \a resize()
|
||||
void clear() { d.clear(); }
|
||||
void clear() {
|
||||
d.clear();
|
||||
changed_ = true;
|
||||
}
|
||||
|
||||
//! \~english Returns \c true if string equal "true", "yes", "on" or positive not null numeric value.
|
||||
//! \~russian Возвращает \c true если строка равна "true", "yes", "on" или числу > 0.
|
||||
@@ -1804,7 +1855,10 @@ private:
|
||||
void trimsubstr(int & st, int & fn) const;
|
||||
|
||||
PIDeque<PIChar> d;
|
||||
mutable char * data_ = nullptr;
|
||||
mutable bool changed_ = true;
|
||||
mutable const char * last_loc_ = nullptr;
|
||||
mutable char * data_ = nullptr;
|
||||
mutable size_t data_size_ = 0;
|
||||
};
|
||||
|
||||
//! \relatesalso PIBinaryStream
|
||||
@@ -1820,6 +1874,7 @@ BINARY_STREAM_WRITE(PIString) {
|
||||
//! \~russian Оператор извлечения.
|
||||
BINARY_STREAM_READ(PIString) {
|
||||
s >> v.d;
|
||||
v.changed_ = true;
|
||||
if (s.wasReadError()) v.clear();
|
||||
return s;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user