Merge pull request 'PIString wo pideue parent' (#91) from pistring_unparent into master
Reviewed-on: https://git.shs.tools/SHS/pip/pulls/91
This commit was merged in pull request #91.
This commit is contained in:
@@ -85,11 +85,7 @@ const float PIString::ElideCenter = .5f;
|
|||||||
const float PIString::ElideRight = 1.f;
|
const float PIString::ElideRight = 1.f;
|
||||||
|
|
||||||
|
|
||||||
#ifndef CC_VC
|
#define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); snprintf(ch, 256, f, v); return PIStringAscii(ch);
|
||||||
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf(ch, f, v); return PIString(ch);
|
|
||||||
#else
|
|
||||||
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf_s(ch, 256, f, v); return PIString(ch);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PIString PIString::itos(const int num) {pisprintf("%d", num);}
|
PIString PIString::itos(const int num) {pisprintf("%d", num);}
|
||||||
PIString PIString::ltos(const long num) {pisprintf("%ld", num);}
|
PIString PIString::ltos(const long num) {pisprintf("%ld", num);}
|
||||||
@@ -99,14 +95,14 @@ PIString PIString::ultos(const ulong num) {pisprintf("%lu", num);}
|
|||||||
PIString PIString::ulltos(const ullong num) {pisprintf("%llu", num);}
|
PIString PIString::ulltos(const ullong num) {pisprintf("%llu", num);}
|
||||||
PIString PIString::ftos(const float num, char format, int precision) {
|
PIString PIString::ftos(const float num, char format, int precision) {
|
||||||
char f[8] = "%.";
|
char f[8] = "%.";
|
||||||
int wr = sprintf(&(f[2]), "%d", precision);
|
int wr = snprintf(&(f[2]), 8, "%d", precision);
|
||||||
f[2 + wr] = format;
|
f[2 + wr] = format;
|
||||||
f[3 + wr] = 0;
|
f[3 + wr] = 0;
|
||||||
pisprintf(f, num);
|
pisprintf(f, num);
|
||||||
}
|
}
|
||||||
PIString PIString::dtos(const double num, char format, int precision) {
|
PIString PIString::dtos(const double num, char format, int precision) {
|
||||||
char f[8] = "%.";
|
char f[8] = "%.";
|
||||||
int wr = sprintf(&(f[2]), "%d", precision);
|
int wr = snprintf(&(f[2]), 8, "%d", precision);
|
||||||
f[2 + wr] = format;
|
f[2 + wr] = format;
|
||||||
f[3 + wr] = 0;
|
f[3 + wr] = 0;
|
||||||
pisprintf(f, num);
|
pisprintf(f, num);
|
||||||
@@ -117,7 +113,7 @@ PIString PIString::dtos(const double num, char format, int precision) {
|
|||||||
|
|
||||||
PIString PIString::fromNumberBaseS(const llong value, int base, bool * ok) {
|
PIString PIString::fromNumberBaseS(const llong value, int base, bool * ok) {
|
||||||
if (value == 0LL) return PIString('0');
|
if (value == 0LL) return PIString('0');
|
||||||
if (base < 2 || base > 40) {
|
if ((base < 2) || (base > 40)) {
|
||||||
if (ok != 0) *ok = false;
|
if (ok != 0) *ok = false;
|
||||||
return PIString();
|
return PIString();
|
||||||
}
|
}
|
||||||
@@ -139,7 +135,7 @@ PIString PIString::fromNumberBaseS(const llong value, int base, bool * ok) {
|
|||||||
|
|
||||||
PIString PIString::fromNumberBaseU(const ullong value, int base, bool * ok) {
|
PIString PIString::fromNumberBaseU(const ullong value, int base, bool * ok) {
|
||||||
if (value == 0ULL) return PIString('0');
|
if (value == 0ULL) return PIString('0');
|
||||||
if (base < 2 || base > 40) {
|
if ((base < 2) || (base > 40)) {
|
||||||
if (ok != 0) *ok = false;
|
if (ok != 0) *ok = false;
|
||||||
return PIString();
|
return PIString();
|
||||||
}
|
}
|
||||||
@@ -170,7 +166,7 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
|
|||||||
} else {
|
} else {
|
||||||
base = 10;
|
base = 10;
|
||||||
}
|
}
|
||||||
} else if (base < 2 || base > 40) {
|
} else if ((base < 2) || (base > 40)) {
|
||||||
if (ok != 0) *ok = false;
|
if (ok != 0) *ok = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -201,6 +197,7 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
|
|||||||
|
|
||||||
|
|
||||||
void PIString::appendFromChars(const char * c, int s, const char * codepage) {
|
void PIString::appendFromChars(const char * c, int s, const char * codepage) {
|
||||||
|
// piCout << "appendFromChars";
|
||||||
if (s == 0) return;
|
if (s == 0) return;
|
||||||
int old_sz = size_s();
|
int old_sz = size_s();
|
||||||
if (s == -1) s = strlen(c);
|
if (s == -1) s = strlen(c);
|
||||||
@@ -208,10 +205,10 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) {
|
|||||||
UErrorCode e((UErrorCode)0);
|
UErrorCode e((UErrorCode)0);
|
||||||
UConverter * cc = ucnv_open(codepage, &e);
|
UConverter * cc = ucnv_open(codepage, &e);
|
||||||
if (cc) {
|
if (cc) {
|
||||||
enlarge(s);
|
d.enlarge(s);
|
||||||
e = (UErrorCode)0;
|
e = (UErrorCode)0;
|
||||||
int sz = ucnv_toUChars(cc, (UChar*)(PIDeque<PIChar>::data(old_sz)), s, c, s, &e);
|
int sz = ucnv_toUChars(cc, (UChar*)(d.data(old_sz)), s, c, s, &e);
|
||||||
resize(old_sz+sz);
|
d.resize(old_sz+sz);
|
||||||
ucnv_close(cc);
|
ucnv_close(cc);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -219,13 +216,13 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) {
|
|||||||
# ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
int sz = MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, 0, 0);
|
int sz = MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, 0, 0);
|
||||||
if (sz <= 0) return;
|
if (sz <= 0) return;
|
||||||
enlarge(sz);
|
d.enlarge(sz);
|
||||||
MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, (LPWSTR)PIDeque<PIChar>::data(old_sz), sz);
|
MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, (LPWSTR)d.data(old_sz), sz);
|
||||||
# else
|
# else
|
||||||
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> ucs2conv;
|
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> ucs2conv;
|
||||||
std::u16string ucs2 = ucs2conv.from_bytes(c, c+s);
|
std::u16string ucs2 = ucs2conv.from_bytes(c, c+s);
|
||||||
enlarge(ucs2.size());
|
d.enlarge(ucs2.size());
|
||||||
ucs2.copy((char16_t *)PIDeque<PIChar>::data(old_sz), ucs2.size());
|
ucs2.copy((char16_t *)d.data(old_sz), ucs2.size());
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -314,38 +311,33 @@ PIString PIString::readableSize(llong bytes) {
|
|||||||
|
|
||||||
|
|
||||||
void PIString::buildData(const char * cp) const {
|
void PIString::buildData(const char * cp) const {
|
||||||
//data_.clear();
|
|
||||||
deleteData();
|
deleteData();
|
||||||
int sz = 0;
|
|
||||||
#ifdef PIP_ICU
|
#ifdef PIP_ICU
|
||||||
UErrorCode e((UErrorCode)0);
|
UErrorCode e((UErrorCode)0);
|
||||||
UConverter * cc = ucnv_open(cp, &e);
|
UConverter * cc = ucnv_open(cp, &e);
|
||||||
if (cc) {
|
if (cc) {
|
||||||
const size_t len = MB_CUR_MAX*size()+1;
|
const size_t len = MB_CUR_MAX*size()+1;
|
||||||
data_ = (char *)malloc(len);
|
data_ = (char *)malloc(len);
|
||||||
sz = ucnv_fromUChars(cc, data_, len, (const UChar*)(PIDeque<PIChar>::data()), size_s(), &e);
|
int sz = ucnv_fromUChars(cc, data_, len, (const UChar*)(d.data()), d.size_s(), &e);
|
||||||
ucnv_close(cc);
|
ucnv_close(cc);
|
||||||
data_[sz] = '\0';
|
data_[sz] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# ifdef WINDOWS
|
# ifdef WINDOWS
|
||||||
sz = WideCharToMultiByte((uint)(uintptr_t)cp, 0, (LPCWCH)PIDeque<PIChar>::data(), PIDeque<PIChar>::size_s(), 0, 0, NULL, NULL);
|
int sz = WideCharToMultiByte((uint)(uintptr_t)cp, 0, (LPCWCH)d.data(), d.size_s(), 0, 0, NULL, NULL);
|
||||||
//printf("WideCharToMultiByte %d %d\n", (uint)(uintptr_t)cp, sz);
|
|
||||||
if (sz <= 0) {
|
if (sz <= 0) {
|
||||||
//printf("WideCharToMultiByte erro %d\n", GetLastError());
|
|
||||||
data_ = (char *)malloc(1);
|
data_ = (char *)malloc(1);
|
||||||
data_[0] = '\0';
|
data_[0] = '\0';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data_ = (char *)malloc(sz+1);
|
data_ = (char *)malloc(sz+1);
|
||||||
//data_.resize(sz);
|
WideCharToMultiByte((uint)(uintptr_t)cp, 0, (LPCWCH)d.data(), d.size_s(), (LPSTR)data_, sz, NULL, NULL);
|
||||||
WideCharToMultiByte((uint)(uintptr_t)cp, 0, (LPCWCH)PIDeque<PIChar>::data(), PIDeque<PIChar>::size_s(), (LPSTR)data_, sz, NULL, NULL);
|
|
||||||
data_[sz] = '\0';
|
data_[sz] = '\0';
|
||||||
return;
|
return;
|
||||||
# else
|
# else
|
||||||
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> ucs2conv;
|
std::wstring_convert<std::codecvt_utf8<char16_t>, char16_t> ucs2conv;
|
||||||
std::string u8str = ucs2conv.to_bytes((char16_t*)PIDeque<PIChar>::data(), (char16_t*)PIDeque<PIChar>::data()+size());
|
std::string u8str = ucs2conv.to_bytes((char16_t*)d.data(), (char16_t*)d.data() + d.size());
|
||||||
data_ = (char *)malloc(u8str.size()+1);
|
data_ = (char *)malloc(u8str.size()+1);
|
||||||
strcpy(data_, u8str.c_str());
|
strcpy(data_, u8str.c_str());
|
||||||
# endif
|
# endif
|
||||||
@@ -361,14 +353,14 @@ void PIString::deleteData() const {
|
|||||||
|
|
||||||
|
|
||||||
void PIString::trimsubstr(int &st, int &fn) const {
|
void PIString::trimsubstr(int &st, int &fn) const {
|
||||||
for (int i = 0; i < length(); ++i) {
|
for (int i = 0; i < d.size_s(); ++i) {
|
||||||
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12) && at(i) != uchar(0)) {
|
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12) && at(i) != uchar(0)) {
|
||||||
st = i;
|
st = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (st < 0) return;
|
if (st < 0) return;
|
||||||
for (int i = length() - 1; i >= 0; --i) {
|
for (int i = d.size_s() - 1; i >= 0; --i) {
|
||||||
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12) && at(i) != uchar(0)) {
|
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12) && at(i) != uchar(0)) {
|
||||||
fn = i;
|
fn = i;
|
||||||
break;
|
break;
|
||||||
@@ -378,7 +370,7 @@ void PIString::trimsubstr(int &st, int &fn) const {
|
|||||||
|
|
||||||
|
|
||||||
uint PIString::hash() const {
|
uint PIString::hash() const {
|
||||||
return piHashData((const uchar*)PIDeque<PIChar>::data(), size() * sizeof(PIChar));
|
return piHashData((const uchar*)d.data(), d.size() * sizeof(PIChar));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -420,45 +412,35 @@ PIString & PIString::operator +=(const wchar_t * str) {
|
|||||||
if (!str) return *this;
|
if (!str) return *this;
|
||||||
int i = -1;
|
int i = -1;
|
||||||
while (str[++i]) {
|
while (str[++i]) {
|
||||||
push_back(PIChar(str[i]));
|
d.push_back(PIChar(str[i]));
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PIString & PIString::operator +=(const PIString & str) {
|
PIString & PIString::operator +=(const PIString & str) {
|
||||||
PIDeque<PIChar>::append(*(const PIDeque<PIChar>*)&str);
|
d.append(str.d);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIString::operator ==(const PIString & str) const {
|
bool PIString::operator ==(const PIString & str) const {
|
||||||
uint l = str.size();
|
return d == str.d;
|
||||||
if (size() != l) return false;
|
|
||||||
for (uint i = 0; i < l; ++i) {
|
|
||||||
if (str[i] != at(i)) return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIString::operator !=(const PIString & str) const {
|
bool PIString::operator !=(const PIString & str) const {
|
||||||
uint l = str.size();
|
return d != str.d;
|
||||||
if (size() != l) return true;
|
|
||||||
for (uint i = 0; i < l; ++i) {
|
|
||||||
if (str[i] != at(i)) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PIString::operator <(const PIString & str) const {
|
bool PIString::operator <(const PIString & str) const {
|
||||||
uint l = str.size();
|
size_t l = str.size();
|
||||||
if (size() < l) return true;
|
if (size() < l) return true;
|
||||||
if (size() > l) return false;
|
if (size() > l) return false;
|
||||||
for (uint i = 0; i < l; ++i) {
|
for (size_t i = 0; i < l; ++i) {
|
||||||
if (at(i) == str[i]) continue;
|
if (at(i) == str.at(i)) continue;
|
||||||
if (at(i) < str[i]) return true;
|
if (at(i) < str.at(i)) return true;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -466,12 +448,12 @@ bool PIString::operator <(const PIString & str) const {
|
|||||||
|
|
||||||
|
|
||||||
bool PIString::operator >(const PIString & str) const {
|
bool PIString::operator >(const PIString & str) const {
|
||||||
uint l = str.size();
|
size_t l = str.size();
|
||||||
if (size() < l) return false;
|
if (size() < l) return false;
|
||||||
if (size() > l) return true;
|
if (size() > l) return true;
|
||||||
for (uint i = 0; i < l; ++i) {
|
for (size_t i = 0; i < l; ++i) {
|
||||||
if (at(i) == str[i]) continue;
|
if (at(i) == str.at(i)) continue;
|
||||||
if (at(i) < str[i]) return false;
|
if (at(i) < str.at(i)) return false;
|
||||||
else return true;
|
else return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -502,10 +484,10 @@ PIString PIString::mid(const int start, const int len) const {
|
|||||||
s = 0;
|
s = 0;
|
||||||
}
|
}
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
return PIString(&(at(s)), size_s() - s);
|
return PIString(d.data(s), size_s() - s);
|
||||||
} else {
|
} else {
|
||||||
if (l > length() - s) l = length() - s;
|
if (l > length() - s) l = length() - s;
|
||||||
return PIString(&(at(s)), l);
|
return PIString(d.data(s), l);
|
||||||
}
|
}
|
||||||
return PIString();
|
return PIString();
|
||||||
}
|
}
|
||||||
@@ -530,10 +512,10 @@ PIString & PIString::cutMid(const int start, const int len) {
|
|||||||
s = 0;
|
s = 0;
|
||||||
}
|
}
|
||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
remove(s, size() - s);
|
d.remove(s, size() - s);
|
||||||
} else {
|
} else {
|
||||||
if (l > length() - s) l = length() - s;
|
if (l > length() - s) l = length() - s;
|
||||||
remove(s, l);
|
d.remove(s, l);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -582,10 +564,10 @@ PIString PIString::trimmed() const {
|
|||||||
PIString & PIString::replace(int from, int count, const PIString & with) {
|
PIString & PIString::replace(int from, int count, const PIString & with) {
|
||||||
count = piMini(count, length() - from);
|
count = piMini(count, length() - from);
|
||||||
if (count == with.size_s()) {
|
if (count == with.size_s()) {
|
||||||
memcpy(PIDeque<PIChar>::data(from), static_cast<PIDeque<PIChar>>(with).data(), count * sizeof(PIChar));
|
memcpy(d.data(from), with.d.data(), count * sizeof(PIChar));
|
||||||
} else {
|
} else {
|
||||||
remove(from, count);
|
d.remove(from, count);
|
||||||
PIDeque<PIChar>::insert(from, with);
|
d.insert(from, with.d);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -637,9 +619,9 @@ PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!match) continue;
|
if (!match) continue;
|
||||||
if (dl > 0) PIDeque<PIChar>::insert(i, PIDeque<PIChar>((size_t)dl));
|
if (dl > 0) d.insert(i, PIDeque<PIChar>((size_t)dl));
|
||||||
if (dl < 0) PIDeque<PIChar>::remove(i, -dl);
|
if (dl < 0) d.remove(i, -dl);
|
||||||
memcpy(PIDeque<PIChar>::data(i), &(with.at(0)), with.length() * sizeof(PIChar));
|
memcpy(d.data(i), with.d.data(), with.size() * sizeof(PIChar));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@@ -665,8 +647,8 @@ PIString & PIString::replaceAll(const PIString & what, const char with) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!match) continue;
|
if (!match) continue;
|
||||||
if (dl > 0) PIDeque<PIChar>::remove(i, dl);
|
if (dl > 0) d.remove(i, dl);
|
||||||
(*this)[i] = PIChar(with);
|
d[i] = PIChar(with);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -682,7 +664,7 @@ PIString & PIString::replaceAll(const PIString & what, const char with) {
|
|||||||
PIString & PIString::replaceAll(const char what, const char with) {
|
PIString & PIString::replaceAll(const char what, const char with) {
|
||||||
int l = length();
|
int l = length();
|
||||||
for (int i = 0; i < l; ++i) {
|
for (int i = 0; i < l; ++i) {
|
||||||
if (at(i) == what) (*this)[i] = with;
|
if (at(i) == what) d[i] = with;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -694,13 +676,13 @@ PIString & PIString::removeAll(const PIString & str) {
|
|||||||
for (int i = 0; i < length() - l + 1; ++i) {
|
for (int i = 0; i < length() - l + 1; ++i) {
|
||||||
bool match = true;
|
bool match = true;
|
||||||
for (int j = 0; j < l; ++j) {
|
for (int j = 0; j < l; ++j) {
|
||||||
if (at(j + i) != str[j]) {
|
if (d.at(j + i) != str.at(j)) {
|
||||||
match = false;
|
match = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!match) continue;
|
if (!match) continue;
|
||||||
PIDeque<PIChar>::remove(i, l);
|
d.remove(i, l);
|
||||||
i -= l;
|
i -= l;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@@ -708,7 +690,7 @@ PIString & PIString::removeAll(const PIString & str) {
|
|||||||
|
|
||||||
|
|
||||||
PIString & PIString::insert(int index, const PIString & str) {
|
PIString & PIString::insert(int index, const PIString & str) {
|
||||||
PIDeque<PIChar>::insert(index, *((const PIDeque<PIChar>*)&str));
|
d.insert(index, str.d);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -723,8 +705,8 @@ PIString & PIString::elide(int size, float pos) {
|
|||||||
pos = piClampf(pos, 0.f, 1.f);
|
pos = piClampf(pos, 0.f, 1.f);
|
||||||
int ns = size - 2;
|
int ns = size - 2;
|
||||||
int ls = piRoundf(ns * pos);
|
int ls = piRoundf(ns * pos);
|
||||||
remove(ls, length() - ns);
|
d.remove(ls, length() - ns);
|
||||||
insert(ls, s_dotdot);
|
d.insert(ls, s_dotdot.d);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -810,6 +792,14 @@ int PIString::findLast(const char c, const int start) const {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int PIString::findLast(PIChar c, const int start) const
|
||||||
|
{
|
||||||
|
for (int i = length() - 1; i >= start; --i) {
|
||||||
|
if (at(i) == c) return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \~\details
|
//! \~\details
|
||||||
//! \~\code
|
//! \~\code
|
||||||
@@ -859,14 +849,14 @@ int PIString::findWord(const PIString & word, const int start) const {
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
PIChar c;
|
PIChar c;
|
||||||
if (f > 0) {
|
if (f > 0) {
|
||||||
c = (*this)[f - 1];
|
c = at(f - 1);
|
||||||
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (f + wl < tl) {
|
if (f + wl < tl) {
|
||||||
c = (*this)[f + wl];
|
c = at(f + wl);
|
||||||
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
@@ -893,14 +883,14 @@ int PIString::findCWord(const PIString & word, const int start) const {
|
|||||||
bool ok = true;
|
bool ok = true;
|
||||||
PIChar c;
|
PIChar c;
|
||||||
if (f > 0) {
|
if (f > 0) {
|
||||||
c = (*this)[f - 1];
|
c = at(f - 1);
|
||||||
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (f + wl < tl) {
|
if (f + wl < tl) {
|
||||||
c = (*this)[f + wl];
|
c = at(f + wl);
|
||||||
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {
|
||||||
ok = false;
|
ok = false;
|
||||||
continue;
|
continue;
|
||||||
@@ -1398,7 +1388,7 @@ PIString PIString::toUpperCase() const {
|
|||||||
PIString str(*this);
|
PIString str(*this);
|
||||||
int l = str.size();
|
int l = str.size();
|
||||||
for (int i = 0; i < l; ++i) {
|
for (int i = 0; i < l; ++i) {
|
||||||
str[i] = str[i].toUpper();
|
str.d[i] = str.d[i].toUpper();
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
@@ -1408,7 +1398,7 @@ PIString PIString::toLowerCase() const {
|
|||||||
PIString str(*this);
|
PIString str(*this);
|
||||||
int l = str.size();
|
int l = str.size();
|
||||||
for (int i = 0; i < l; ++i) {
|
for (int i = 0; i < l; ++i) {
|
||||||
str[i] = str[i].toLower();
|
str.d[i] = str.d[i].toLower();
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,13 +33,25 @@
|
|||||||
|
|
||||||
class PIStringList;
|
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, PIString & v);
|
||||||
|
friend PIByteArray & operator <<(PIByteArray & s, const PIString & v);
|
||||||
public:
|
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
|
//! \~english Contructs an empty string
|
||||||
//! \~russian Создает пустую строку
|
//! \~russian Создает пустую строку
|
||||||
PIString(): PIDeque<PIChar>() {}
|
PIString() {}
|
||||||
|
|
||||||
//! \~english Value for elide at left
|
//! \~english Value for elide at left
|
||||||
//! \~russian Значение для пропуска слева
|
//! \~russian Значение для пропуска слева
|
||||||
@@ -53,8 +65,8 @@ public:
|
|||||||
//! \~russian Значение для пропуска справа
|
//! \~russian Значение для пропуска справа
|
||||||
static const float ElideRight ;
|
static const float ElideRight ;
|
||||||
|
|
||||||
PIString & operator +=(const PIChar & c) {PIDeque<PIChar>::push_back(c); return *this;}
|
PIString & operator +=(const PIChar & c) {d.push_back(c); return *this;}
|
||||||
PIString & operator +=(const char c) {PIDeque<PIChar>::push_back(PIChar(c)); return *this;}
|
PIString & operator +=(const char c) {d.push_back(PIChar(c)); return *this;}
|
||||||
PIString & operator +=(const char * str);
|
PIString & operator +=(const char * str);
|
||||||
PIString & operator +=(const wchar_t * str);
|
PIString & operator +=(const wchar_t * str);
|
||||||
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
|
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
|
//! \~english Contructs a copy of string
|
||||||
//! \~russian Создает копию строки
|
//! \~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"
|
//! \~english Contructs string with single symbol "c"
|
||||||
//! \~russian Создает строку из одного символа "c"
|
//! \~russian Создает строку из одного символа "c"
|
||||||
PIString(const PIChar c): PIDeque<PIChar>() {*this += c;}
|
PIString(const PIChar c) {*this += c;}
|
||||||
|
|
||||||
//! \~english Contructs string with single symbol "c"
|
//! \~english Contructs string with single symbol "c"
|
||||||
//! \~russian Создает строку из одного символа "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)
|
//! \~english Contructs string from C-string "str" (system codepage)
|
||||||
//! \~russian Создает строку из C-строки "str" (кодировка системы)
|
//! \~russian Создает строку из C-строки "str" (кодировка системы)
|
||||||
@@ -85,7 +97,7 @@ public:
|
|||||||
//! \~\code
|
//! \~\code
|
||||||
//! PIString s("string");
|
//! PIString s("string");
|
||||||
//! \endcode
|
//! \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"
|
//! \~english Contructs string from \c wchar_t C-string "str"
|
||||||
//! \~russian Создает строку из \c wchar_t C-строки "str"
|
//! \~russian Создает строку из \c wchar_t C-строки "str"
|
||||||
@@ -97,15 +109,15 @@ public:
|
|||||||
//! \~\code
|
//! \~\code
|
||||||
//! PIString s(L"string");
|
//! PIString s(L"string");
|
||||||
//! \endcode
|
//! \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)
|
//! \~english Contructs string from byte array "ba" (as UTF-8)
|
||||||
//! \~russian Создает строку из байтового массива "ba" (как 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"
|
//! \~english Contructs string from "len" characters of buffer "str"
|
||||||
//! \~russian Создает строку из "len" символов массива "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)
|
//! \~english Contructs string from "len" characters of buffer "str" (system codepage)
|
||||||
//! \~russian Создает строку из "len" символов массива "str" (кодировка системы)
|
//! \~russian Создает строку из "len" символов массива "str" (кодировка системы)
|
||||||
@@ -113,7 +125,7 @@ public:
|
|||||||
//! \~\code
|
//! \~\code
|
||||||
//! PIString s("string", 3); // s = "str"
|
//! PIString s("string", 3); // s = "str"
|
||||||
//! \endcode
|
//! \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"
|
//! \~english Contructs string as sequence of characters "c" of buffer with length "len"
|
||||||
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
||||||
@@ -121,7 +133,7 @@ public:
|
|||||||
//! \~\code
|
//! \~\code
|
||||||
//! PIString s(5, 'p'); // s = "ppppp"
|
//! PIString s(5, 'p'); // s = "ppppp"
|
||||||
//! \endcode
|
//! \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"
|
//! \~english Contructs string as sequence of symbols "c" of buffer with length "len"
|
||||||
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
//! \~russian Создает строку как последовательность длиной "len" символа "c"
|
||||||
@@ -129,16 +141,16 @@ public:
|
|||||||
//! \~\code
|
//! \~\code
|
||||||
//! PIString s(5, "№"); // s = "№№№№№"
|
//! PIString s(5, "№"); // s = "№№№№№"
|
||||||
//! \endcode
|
//! \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();
|
~PIString();
|
||||||
|
|
||||||
|
|
||||||
//! \~english Assign operator
|
//! \~english Assign operator
|
||||||
//! \~russian Оператор присваивания
|
//! \~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
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~russian Оператор сравнения
|
||||||
@@ -146,7 +158,7 @@ public:
|
|||||||
|
|
||||||
//! \~english Compare operator
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~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
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~russian Оператор сравнения
|
||||||
@@ -158,7 +170,7 @@ public:
|
|||||||
|
|
||||||
//! \~english Compare operator
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~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
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~russian Оператор сравнения
|
||||||
@@ -170,7 +182,7 @@ public:
|
|||||||
|
|
||||||
//! \~english Compare operator
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~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
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~russian Оператор сравнения
|
||||||
@@ -182,7 +194,7 @@ public:
|
|||||||
|
|
||||||
//! \~english Compare operator
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~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
|
//! \~english Compare operator
|
||||||
//! \~russian Оператор сравнения
|
//! \~russian Оператор сравнения
|
||||||
@@ -228,7 +240,7 @@ public:
|
|||||||
//! PIString s("stri");
|
//! PIString s("stri");
|
||||||
//! s << PIChar('n') << PIChar('g'); // s = "string"
|
//! s << PIChar('n') << PIChar('g'); // s = "string"
|
||||||
//! \endcode
|
//! \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
|
//! \~english Append symbol `c` at the end of string
|
||||||
//! \~russian Добавляет в конец символ `c`
|
//! \~russian Добавляет в конец символ `c`
|
||||||
@@ -237,7 +249,7 @@ public:
|
|||||||
//! PIString s("stri");
|
//! PIString s("stri");
|
||||||
//! s << 'n' << 'g'; // s = "string"
|
//! s << 'n' << 'g'; // s = "string"
|
||||||
//! \endcode
|
//! \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
|
//! \~english Append С-string "str" at the end of string
|
||||||
//! \~russian Добавляет в конец C-строку "str"
|
//! \~russian Добавляет в конец C-строку "str"
|
||||||
@@ -298,6 +310,36 @@ public:
|
|||||||
//! \endcode
|
//! \endcode
|
||||||
PIString & operator <<(const double & num) {*this += PIString::fromNumber(num); return *this;}
|
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
|
//! \~english Insert string "str" at the begin of string
|
||||||
//! \~russian Вставляет "str" в начало строки
|
//! \~russian Вставляет "str" в начало строки
|
||||||
@@ -305,15 +347,15 @@ public:
|
|||||||
|
|
||||||
//! \~english Insert string "str" at the begin of string
|
//! \~english Insert string "str" at the begin of string
|
||||||
//! \~russian Вставляет "str" в начало строки
|
//! \~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
|
//! \~english Insert symbol `c` at the begin of string
|
||||||
//! \~russian Вставляет символ `c` в начало строки
|
//! \~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
|
//! \~english Insert symbol `c` at the begin of string
|
||||||
//! \~russian Вставляет символ `c` в начало строки
|
//! \~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
|
//! \~english Insert string "str" at the begin of string
|
||||||
//! \~russian Вставляет "str" в начало строки
|
//! \~russian Вставляет "str" в начало строки
|
||||||
@@ -321,15 +363,15 @@ public:
|
|||||||
|
|
||||||
//! \~english Insert string "str" at the begin of string
|
//! \~english Insert string "str" at the begin of string
|
||||||
//! \~russian Вставляет "str" в начало строки
|
//! \~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
|
//! \~english Insert symbol `c` at the begin of string
|
||||||
//! \~russian Вставляет символ `c` в начало строки
|
//! \~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
|
//! \~english Insert symbol `c` at the begin of string
|
||||||
//! \~russian Вставляет символ `c` в начало строки
|
//! \~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
|
//! \~english Insert string "str" at the end of string
|
||||||
//! \~russian Вставляет "str" в конец строки
|
//! \~russian Вставляет "str" в конец строки
|
||||||
@@ -337,15 +379,15 @@ public:
|
|||||||
|
|
||||||
//! \~english Insert string "str" at the end of string
|
//! \~english Insert string "str" at the end of string
|
||||||
//! \~russian Вставляет "str" в конец строки
|
//! \~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
|
//! \~english Insert symbol `c` at the end of string
|
||||||
//! \~russian Вставляет символ `c` в конец строки
|
//! \~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
|
//! \~english Insert symbol `c` at the end of string
|
||||||
//! \~russian Вставляет символ `c` в конец строки
|
//! \~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
|
//! \~english Insert string "str" at the end of string
|
||||||
//! \~russian Вставляет "str" в конец строки
|
//! \~russian Вставляет "str" в конец строки
|
||||||
@@ -353,15 +395,15 @@ public:
|
|||||||
|
|
||||||
//! \~english Insert string "str" at the end of string
|
//! \~english Insert string "str" at the end of string
|
||||||
//! \~russian Вставляет "str" в конец строки
|
//! \~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
|
//! \~english Insert symbol `c` at the end of string
|
||||||
//! \~russian Вставляет символ `c` в конец строки
|
//! \~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
|
//! \~english Insert symbol `c` at the end of string
|
||||||
//! \~russian Вставляет символ `c` в конец строки
|
//! \~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"
|
//! \~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
|
//! \~english Remove all founded symbols "what" and return this string
|
||||||
//! \~russian Удаляет все найденные символы "what", возвращает эту строку
|
//! \~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
|
//! \~english Repeat content of string "times" times and return this string
|
||||||
//! \~russian Повторяет содержимое строки "times" раз и возвращает эту строку
|
//! \~russian Повторяет содержимое строки "times" раз и возвращает эту строку
|
||||||
@@ -545,7 +587,7 @@ public:
|
|||||||
//! s.insert(1, "i");
|
//! s.insert(1, "i");
|
||||||
//! piCout << s; // s = "pip"
|
//! piCout << s; // s = "pip"
|
||||||
//! \endcode
|
//! \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
|
//! \~english Insert symbol "c" after index "index" and return this string
|
||||||
//! \~russian Вставляет символ "c" после позиции "index" и возвращает эту строку
|
//! \~russian Вставляет символ "c" после позиции "index" и возвращает эту строку
|
||||||
@@ -588,7 +630,7 @@ public:
|
|||||||
//! piCout << s; // s = "str___"
|
//! piCout << s; // s = "str___"
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//! \~\sa \a expandLeftTo(), \a expandedRightTo(), \a expandedLeftTo()
|
//! \~\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
|
//! \~english Enlarge string to length "len" by addition symbols "c" at the begin, and return this string
|
||||||
//! \~russian Увеличивает длину строки до "len" добавлением символов "c" в начало и возвращает эту строку
|
//! \~russian Увеличивает длину строки до "len" добавлением символов "c" в начало и возвращает эту строку
|
||||||
@@ -601,7 +643,7 @@ public:
|
|||||||
//! piCout << s; // s = "___str"
|
//! piCout << s; // s = "___str"
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//! \~\sa \a expandRightTo(), \a expandedRightTo(), \a expandedLeftTo()
|
//! \~\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
|
//! \~english Enlarge copy of this string to length "len" by addition symbols "c" at the end
|
||||||
//! \~russian Увеличивает длину копии этой строки до "len" добавлением символов "c" в конец
|
//! \~russian Увеличивает длину копии этой строки до "len" добавлением символов "c" в конец
|
||||||
@@ -634,7 +676,7 @@ public:
|
|||||||
//! piCout << s; // s = ""str""
|
//! piCout << s; // s = ""str""
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//! \~\sa \a quoted()
|
//! \~\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
|
//! \~english Returns quoted copy of this string
|
||||||
//! \~russian Возвращает копию строки с добавленным в начало и конец символом "c"
|
//! \~russian Возвращает копию строки с добавленным в начало и конец символом "c"
|
||||||
@@ -656,7 +698,7 @@ public:
|
|||||||
//! piCout << s; // s = "9876543210"
|
//! piCout << s; // s = "9876543210"
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//! \~\sa \a reversed()
|
//! \~\sa \a reversed()
|
||||||
PIString & reverse() {PIDeque<PIChar>::reverse(); return *this;}
|
PIString & reverse() {d.reverse(); return *this;}
|
||||||
|
|
||||||
//! \~english Reverse copy of this string
|
//! \~english Reverse copy of this string
|
||||||
//! \~russian Разворачивает копию этой строки
|
//! \~russian Разворачивает копию этой строки
|
||||||
@@ -804,7 +846,7 @@ public:
|
|||||||
|
|
||||||
//! \~english Returns if string contains symbol "c"
|
//! \~english Returns if string contains symbol "c"
|
||||||
//! \~russian Возвращает содержит ли строка символ "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"
|
//! \~english Returns if string contains substring "str"
|
||||||
//! \~russian Возвращает содержит ли строка подстроку "str"
|
//! \~russian Возвращает содержит ли строка подстроку "str"
|
||||||
@@ -819,6 +861,10 @@ public:
|
|||||||
//! \~russian Ищет символ "c" от символа "start" и возвращает первое вхождение
|
//! \~russian Ищет символ "c" от символа "start" и возвращает первое вхождение
|
||||||
int find(const char c, const int start = 0) const;
|
int find(const char c, const int start = 0) const;
|
||||||
|
|
||||||
|
//! \~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);}
|
||||||
|
|
||||||
//! \~english Search substring "str" from symbol at index "start" and return first occur position
|
//! \~english Search substring "str" from symbol at index "start" and return first occur position
|
||||||
//! \~russian Ищет подстроку "str" от символа "start" и возвращает первое вхождение
|
//! \~russian Ищет подстроку "str" от символа "start" и возвращает первое вхождение
|
||||||
int find(const PIString & str, const int start = 0) const;
|
int find(const PIString & str, const int start = 0) const;
|
||||||
@@ -855,6 +901,10 @@ public:
|
|||||||
//! \~russian Ищет символ "c" от символа "start" и возвращает последнее вхождение
|
//! \~russian Ищет символ "c" от символа "start" и возвращает последнее вхождение
|
||||||
int findLast(const char c, const int start = 0) const;
|
int findLast(const char c, const int start = 0) const;
|
||||||
|
|
||||||
|
//! \~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;
|
||||||
|
|
||||||
//! \~english Search substring "str" from symbol at index "start" and return last occur position
|
//! \~english Search substring "str" from symbol at index "start" and return last occur position
|
||||||
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение
|
//! \~russian Ищет подстроку "str" от символа "start" и возвращает последнее вхождение
|
||||||
int findLast(const PIString & str, const int start = 0) const;
|
int findLast(const PIString & str, const int start = 0) const;
|
||||||
@@ -927,16 +977,25 @@ public:
|
|||||||
|
|
||||||
//! \~english Returns symbols length of string
|
//! \~english Returns symbols length of string
|
||||||
//! \~russian Возвращает длину строки в символах
|
//! \~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
|
//! \~english Returns \c true if string is empty, i.e. length = 0
|
||||||
//! \~russian Возвращает \c true если строка пустая, т.е. длина = 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
|
//! \~english Returns \c true if string is not empty, i.e. length > 0
|
||||||
//! \~russian Возвращает \c true если строка непустая, т.е. длина > 0
|
//! \~russian Возвращает \c true если строка непустая, т.е. длина > 0
|
||||||
bool isNotEmpty() const {return !isEmpty();}
|
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
|
//! \~english Returns \c true if string equal "true", "yes", "on" or positive not null numeric value
|
||||||
//! \~russian Возвращает \c true если строка равна "true", "yes", "on" или числу > 0
|
//! \~russian Возвращает \c true если строка равна "true", "yes", "on" или числу > 0
|
||||||
@@ -1090,7 +1149,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
@@ -1102,7 +1161,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
@@ -1114,7 +1173,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
@@ -1126,7 +1185,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
@@ -1138,7 +1197,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
@@ -1150,7 +1209,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
@@ -1162,7 +1221,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" in base "base" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" по основанию "base" и возвращает эту строку
|
||||||
@@ -1174,7 +1233,7 @@ public:
|
|||||||
//! s.setNumber(123, 16);
|
//! s.setNumber(123, 16);
|
||||||
//! piCout << s; // 7B
|
//! piCout << s; // 7B
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||||
@@ -1192,7 +1251,7 @@ public:
|
|||||||
//! s.setNumber(123456789., 'f', 0);
|
//! s.setNumber(123456789., 'f', 0);
|
||||||
//! piCout << s; // 123456789
|
//! piCout << s; // 123456789
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||||
@@ -1210,7 +1269,7 @@ public:
|
|||||||
//! s.setNumber(123456789., 'f', 0);
|
//! s.setNumber(123456789., 'f', 0);
|
||||||
//! piCout << s; // 123456789
|
//! piCout << s; // 123456789
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to text representation of "value" with format "format" and precision "precision" and return this string
|
||||||
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
//! \~russian Устанавливает содержимое строки в текстовое представление "value" в формате "format" и точностью "precision" и возвращает эту строку
|
||||||
@@ -1228,7 +1287,7 @@ public:
|
|||||||
//! s.setNumber(123456789., 'f', 0);
|
//! s.setNumber(123456789., 'f', 0);
|
||||||
//! piCout << s; // 123456789
|
//! piCout << s; // 123456789
|
||||||
//! \endcode
|
//! \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
|
//! \~english Set string content to human readable size in B/kB/MB/GB/TB/PB
|
||||||
//! \~russian Устанавливает содержимое в строку с читаемым размером B/kB/MB/GB/TB/PB
|
//! \~russian Устанавливает содержимое в строку с читаемым размером B/kB/MB/GB/TB/PB
|
||||||
@@ -1345,7 +1404,7 @@ public:
|
|||||||
|
|
||||||
//! \~english Returns "true" or "false"
|
//! \~english Returns "true" or "false"
|
||||||
//! \~russian Возвращает "true" или "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
|
//! \~english Returns string constructed from terminal codepage
|
||||||
//! \~russian Возвращает строку созданную из кодировки консоли
|
//! \~russian Возвращает строку созданную из кодировки консоли
|
||||||
@@ -1380,6 +1439,11 @@ public:
|
|||||||
//! \~\sa PIString::setReadableSize()
|
//! \~\sa PIString::setReadableSize()
|
||||||
static PIString readableSize(llong bytes);
|
static PIString readableSize(llong bytes);
|
||||||
|
|
||||||
|
void swap(PIString & str) {
|
||||||
|
d.swap(str.d);
|
||||||
|
piSwap(data_, str.data_);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char toBaseN[];
|
static const char toBaseN[];
|
||||||
static const int fromBaseN[];
|
static const int fromBaseN[];
|
||||||
@@ -1400,6 +1464,7 @@ private:
|
|||||||
void deleteData() 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;
|
mutable char * data_ = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1412,12 +1477,12 @@ PIP_EXPORT PICout operator <<(PICout s, const PIString & v);
|
|||||||
//! \relatesalso PIByteArray
|
//! \relatesalso PIByteArray
|
||||||
//! \~english Store operator
|
//! \~english Store operator
|
||||||
//! \~russian Оператор сохранения
|
//! \~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
|
//! \relatesalso PIByteArray
|
||||||
//! \~english Restore operator
|
//! \~english Restore operator
|
||||||
//! \~russian Оператор извлечения
|
//! \~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
|
//! \~english Returns concatenated string
|
||||||
@@ -1457,6 +1522,8 @@ PIString PIP_EXPORT versionNormalize(const PIString & v);
|
|||||||
//! \~russian Возвращает хэш строки
|
//! \~russian Возвращает хэш строки
|
||||||
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) {f.swap(s);}
|
template<> inline void piSwap(PIString & f, PIString & s) {
|
||||||
|
f.swap(s);
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PISTRING_H
|
#endif // PISTRING_H
|
||||||
|
|||||||
6
main.cpp
6
main.cpp
@@ -130,7 +130,13 @@ int main(int argc, char * argv[]) {
|
|||||||
}
|
}
|
||||||
piCout << l << "PIString::fromNumber" << tm.elapsed_m();
|
piCout << l << "PIString::fromNumber" << tm.elapsed_m();
|
||||||
tm.reset();
|
tm.reset();
|
||||||
|
for(int i=0; i<cc; ++i) {
|
||||||
|
PIString s = is;
|
||||||
|
l = s.size();
|
||||||
|
}
|
||||||
|
piCout << l << "PIString::assign empty" << tm.elapsed_m();
|
||||||
PIString is2 = PIString::fromUTF8(ba);
|
PIString is2 = PIString::fromUTF8(ba);
|
||||||
|
tm.reset();
|
||||||
for(int i=0; i<cc; ++i) {
|
for(int i=0; i<cc; ++i) {
|
||||||
PIString s = is;
|
PIString s = is;
|
||||||
l = s.size();
|
l = s.size();
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ PIString frameworkName(const PIString & l) {
|
|||||||
|
|
||||||
|
|
||||||
PIString frameworkInternalPath(const PIString & l) {
|
PIString frameworkInternalPath(const PIString & l) {
|
||||||
return l.right(l.size_s() - l.lastIndexOf(".framework") - 11);
|
return l.right(l.size_s() - l.findLast('.') - 11);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -632,7 +632,7 @@ int main(int argc, char * argv[]) {
|
|||||||
if (styles.isEmpty()) styles << "";
|
if (styles.isEmpty()) styles << "";
|
||||||
PIStringList qpd = cli.argumentValue("qt-plugins").toLowerCase().split(DELIM);
|
PIStringList qpd = cli.argumentValue("qt-plugins").toLowerCase().split(DELIM);
|
||||||
piForeachC (PIString & qp, qpd) {
|
piForeachC (PIString & qp, qpd) {
|
||||||
int _i = qp.indexOf("=");
|
int _i = qp.find('=');
|
||||||
if (_i < 0) continue;
|
if (_i < 0) continue;
|
||||||
PIString pname = qp.left(_i).trim();
|
PIString pname = qp.left(_i).trim();
|
||||||
PIStringList pfilt = qp.mid(_i + 1).trim().split(",");
|
PIStringList pfilt = qp.mid(_i + 1).trim().split(",");
|
||||||
|
|||||||
Reference in New Issue
Block a user