PIString replace pibytearray by char *

This commit is contained in:
Andrey
2022-04-25 11:42:58 +03:00
parent cf48c9ebf7
commit 765ef7368e
5 changed files with 106 additions and 131 deletions

View File

@@ -39,7 +39,7 @@ class PIP_EXPORT PIString: public PIDeque<PIChar>
public:
//! \~english Contructs an empty string
//! \~russian Создает пустую строку
PIString(): PIDeque<PIChar>() {}
PIString(): PIDeque<PIChar>() {data_ = nullptr;}
//! \~english Value for elide at left
//! \~russian Значение для пропуска слева
@@ -62,18 +62,18 @@ public:
//! \~english Contructs a copy of string
//! \~russian Создает копию строки
PIString(const PIString & o): PIDeque<PIChar>(o) {}
PIString(const PIString & o): PIDeque<PIChar>(o) {data_ = nullptr;}
PIString(PIString && o): PIDeque<PIChar>(std::move(o)) {}
PIString(PIString && o): PIDeque<PIChar>(std::move(o)) {data_ = nullptr;}
//! \~english Contructs string with single symbol "c"
//! \~russian Создает строку из одного символа "c"
PIString(const PIChar c): PIDeque<PIChar>() {*this += c;}
PIString(const PIChar c): PIDeque<PIChar>() {data_ = nullptr; *this += c;}
//! \~english Contructs string with single symbol "c"
//! \~russian Создает строку из одного символа "c"
PIString(const char c): PIDeque<PIChar>() {*this += PIChar(c);}
PIString(const char c): PIDeque<PIChar>() {data_ = nullptr; *this += PIChar(c);}
//! \~english Contructs string from C-string "str" (system codepage)
//! \~russian Создает строку из C-строки "str" (кодировка системы)
@@ -85,7 +85,7 @@ public:
//! \~\code
//! PIString s("string");
//! \endcode
PIString(const char * str): PIDeque<PIChar>() {*this += str;}
PIString(const char * str): PIDeque<PIChar>() {data_ = nullptr; *this += str;}
//! \~english Contructs string from \c wchar_t C-string "str"
//! \~russian Создает строку из \c wchar_t C-строки "str"
@@ -97,15 +97,15 @@ public:
//! \~\code
//! PIString s(L"string");
//! \endcode
PIString(const wchar_t * str): PIDeque<PIChar>() {*this += str;}
PIString(const wchar_t * str): PIDeque<PIChar>() {data_ = nullptr; *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): PIDeque<PIChar>() {data_ = nullptr; *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): PIDeque<PIChar>(str, size_t(len)) {data_ = nullptr;}
//! \~english Contructs string from "len" characters of buffer "str" (system codepage)
//! \~russian Создает строку из "len" символов массива "str" (кодировка системы)
@@ -113,7 +113,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): PIDeque<PIChar>() {data_ = nullptr; appendFromChars(str, len);}
//! \~english Contructs string as sequence of characters "c" of buffer with length "len"
//! \~russian Создает строку как последовательность длиной "len" символа "c"
@@ -121,7 +121,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): PIDeque<PIChar>() {data_ = nullptr; for (int i = 0; i < len; ++i) PIDeque<PIChar>::push_back(PIChar(c));}
//! \~english Contructs string as sequence of symbols "c" of buffer with length "len"
//! \~russian Создает строку как последовательность длиной "len" символа "c"
@@ -129,9 +129,9 @@ 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): PIDeque<PIChar>() {data_ = nullptr; for (int i = 0; i < len; ++i) PIDeque<PIChar>::push_back(c);}
~PIString() {}
~PIString();
//! \~english Assign operator
@@ -749,10 +749,6 @@ public:
//! \~russian Возвращает строку между символами "start" и "end" с начала строки
PIString inBrackets(const PIChar start, const PIChar end) const;
//! \~english Returns bytes count of this string in system codepage
//! \~russian Возвращает объем строки в системной кодировке
int lengthAscii() const;
//! \~english Returns \c char * representation of this string in system codepage
//! \~russian Возвращает \c char * представление строки в системной кодировке
const char * data() const;
@@ -773,9 +769,9 @@ public:
//! \~russian Возвращает хэш
uint hash() const;
//! \~english Returns \a PIByteArray contains \a data() of this string without terminating null-char
//! \~russian Возвращает \a PIByteArray содержащий \a data() строки без завершающего нулевого байта
PIByteArray toByteArray() const {buildData(__utf8name__); return data_.resized(data_.size_s() - 1);}
//! \~english Same as \a toUTF8().
//! \~russian Тоже самое, что \a toUTF8().
PIByteArray toByteArray() const {return toUTF8();}
//! \~english Returns \a PIByteArray contains \a dataUTF8() of this string without terminating null-char
//! \~russian Возвращает \a PIByteArray содержащий \a dataUTF8() строки без завершающего нулевого байта
@@ -1402,7 +1398,7 @@ private:
void appendFromChars(const char * c, int s, const char * cp = __syslocname__);
void buildData(const char * cp = __syslocname__) const;
void trimsubstr(int &st, int &fn) const;
mutable PIByteArray data_;
mutable char * data_;
};