PIString hard optimization

This commit is contained in:
2020-07-31 14:12:47 +03:00
parent 1d5c979607
commit e728b30e5e
7 changed files with 318 additions and 258 deletions

View File

@@ -173,7 +173,7 @@ PIString PIString::dtos(const double num, char format, int precision) {
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 (ok != 0) *ok = false; return PIString();}
if (ok != 0) *ok = true;
if (base == 10) return lltos(value);
@@ -192,7 +192,7 @@ PIString PIString::fromNumberBaseS(const llong 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 (ok != 0) *ok = false; return PIString();}
if (ok != 0) *ok = true;
if (base == 10) return ulltos(value);
@@ -211,9 +211,10 @@ PIString PIString::fromNumberBaseU(const ullong value, int base, bool * ok) {
llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
static const PIString s_0x = PIStringAscii("0x");
PIString v = value.trimmed();
if (base < 0) {
int ind = v.find("0x");
int ind = v.find(s_0x);
if (ind == 0 || ind == 1) {v.remove(ind, 2); base = 16;}
else base = 10;
} else
@@ -254,6 +255,7 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) {
int sz = ucnv_toUChars(cc, ucs, s, c, s, &e);
//printf("appendFromChars %d -> %d\n", s, sz);
//printf("PIString %d -> %d\n", c[0], ucs[0]);
reserve(size_s() + sz);
for (int i = 0; i < sz; ++i)
push_back(PIChar(ucs[i]));
delete[] ucs;
@@ -264,11 +266,9 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) {
# ifdef WINDOWS
sz = MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, 0, 0);
if (sz <= 0) return;
wchar_t * buffer = new wchar_t[sz];
MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, buffer, sz);
for (int i = 0; i < sz; ++i)
push_back(PIChar((ushort)buffer[i]));
delete[] buffer;
int old_sz = size_s();
enlarge(sz);
MultiByteToWideChar((uint)(uintptr_t)codepage, MB_ERR_INVALID_CHARS, c, s, (LPWSTR)PIDeque<PIChar>::data(old_sz), sz);
return;
//printf("request %d\n", sz);
# else
@@ -330,9 +330,14 @@ PIString PIString::fromAscii(const char * s) {
PIString ret;
int l = 0;
while (s[l] != '\0') {
ret.push_back(PIChar(short(s[l])));
ret.push_back(PIChar(s[l]));
++l;
}
/*while (s[l] != '\0') ++l;
PIString ret;
ret.resize(l);
for (int i = 0; i < l; ++i)
ret[i] = s[i];*/
return ret;
}
@@ -369,6 +374,7 @@ void PIString::buildData(const char * cp) const {
UConverter * cc = ucnv_open(cp, &e);
if (cc) {
char uc[8];
data_.reserve(size_s());
for (int i = 0; i < size_s(); ++i) {
if (at(i).isAscii())
data_.push_back(uchar(at(i).unicode16Code()));
@@ -605,16 +611,18 @@ PIString PIString::trimmed() const {
PIString & PIString::replace(int from, int count, const PIString & with) {
if (count < length() - from) remove(from, count);
else remove(from, length() - from);
uint c = with.length();
for (uint i = 0; i < c; ++i) insert(from + i, with[i]);
count = piMini(count, length() - from);
if (count == with.size_s())
memcpy(&(at(from)), &(with.at(0)), count * sizeof(PIChar));
else {
remove(from, count);
PIDeque<PIChar>::insert(from, with);
}
return *this;
}
PIString & PIString::replace(const PIString & what, const PIString & with, bool * ok) {
//piCout << "replace" << what << with;
if (what.isEmpty()) {
if (ok != 0) *ok = false;
return *this;
@@ -628,8 +636,53 @@ PIString & PIString::replace(const PIString & what, const PIString & with, bool
PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
if (what.isEmpty() || what == with) return *this;
bool ok = true;
while (ok) replace(what, with, &ok);
if (with.isEmpty()) removeAll(what);
else {
int l = what.length(), dl = with.length() - what.length();
for (int i = 0; i < length() - l + 1; ++i) {
bool match = true;
for (int j = 0; j < l; ++j) {
if (at(j + i) != what[j]) {
match = false;
break;
}
}
if (!match) continue;
if (dl > 0) PIDeque<PIChar>::insert(i, PIDeque<PIChar>((size_t)dl));
if (dl < 0) PIDeque<PIChar>::remove(i, -dl);
memcpy(PIDeque<PIChar>::data(i), &(with.at(0)), with.length() * sizeof(PIChar));
//i -= l;
}
}
return *this;
}
PIString & PIString::replaceAll(const char what, const char with) {
int l = length();
for (int i = 0; i < l; ++i) {
if (at(i) == what)
at(i) = with;
}
return *this;
}
PIString & PIString::removeAll(const PIString & str) {
if (str.isEmpty()) return *this;
int l = str.length();
for (int i = 0; i < length() - l + 1; ++i) {
bool match = true;
for (int j = 0; j < l; ++j) {
if (at(j + i) != str[j]) {
match = false;
break;
}
}
if (!match) continue;
PIDeque<PIChar>::remove(i, l);
i -= l;
}
return *this;
}
@@ -641,16 +694,17 @@ PIString & PIString::insert(int index, const PIString & str) {
PIString & PIString::elide(int size, float pos) {
static const PIString s_dotdot = PIStringAscii("..");
if (length() <= size) return *this;
if (length() <= 2) {
fill(".");
fill('.');
return *this;
}
pos = piClampf(pos, 0.f, 1.f);
int ns = size - 2;
int ls = piRoundf(ns * pos);
remove(ls, length() - ns);
insert(ls, "..");
insert(ls, s_dotdot);
return *this;
}
@@ -670,9 +724,9 @@ PIStringList PIString::split(const PIString & delim) const {
}
int PIString::find(const char str, const int start) const {
int PIString::find(const char c, const int start) const {
for (int i = start; i < length(); ++i)
if (at(i) == str)
if (at(i) == c)
return i;
return -1;
}
@@ -687,9 +741,9 @@ int PIString::find(const PIString & str, const int start) const {
}
int PIString::findLast(const char str, const int start) const {
int PIString::findLast(const char c, const int start) const {
for (int i = length() - 1; i >= start; --i)
if (at(i) == str)
if (at(i) == c)
return i;
return -1;
}
@@ -730,7 +784,7 @@ int PIString::findCWord(const PIString & word, const int start) const {
}
int PIString::findRange(const PIChar & start, const PIChar & end, const PIChar & shield, const int start_index, int * len) const {
int PIString::findRange(const PIChar start, const PIChar end, const PIChar shield, const int start_index, int * len) const {
if (len) *len = 0;
bool trim_ = (start != ' ' && start != '\t' && start != '\n' && start != '\r'), eq = (start == end);
int sz = size_s(), ls = -1, le = -1, cnt = 0;
@@ -783,7 +837,7 @@ int PIString::findAnyLast(const PIString & str, const int start) const {
}
int PIString::entries(const PIChar & c) const {
int PIString::entries(const PIChar c) const {
int sz = size_s(), ret = 0;
for (int i = 0; i < sz; ++i)
if (at(i) == c) ++ret;
@@ -804,9 +858,14 @@ bool PIString::endsWith(const PIString & str) const {
bool PIString::toBool() const {
static const PIString s_true = PIStringAscii("true");
static const PIString s_yes = PIStringAscii("yes" );
static const PIString s_on = PIStringAscii("on" );
static const PIString s_ok = PIStringAscii("ok" );
PIString s(*this);
s = s.trimmed().toLowerCase();
if ( atof(s.toNativeDecimalPoints().data()) > 0. || s == "true" || s == "yes" || s == "on" || s == "ok") return true;
if (s == s_true || s == s_yes || s == s_on || s == s_ok) return true;
if (atof(s.toNativeDecimalPoints().data()) > 0.) return true;
return false;
}
@@ -953,7 +1012,7 @@ PIString PIString::takeNumber() {
}
PIString PIString::takeRange(const PIChar & start, const PIChar & end, const PIChar & shield) {
PIString PIString::takeRange(const PIChar start, const PIChar end, const PIChar shield) {
PIString ret;
bool trim_ = (start != ' ' && start != '\t' && start != '\n' && start != '\r'), eq = (start == end);
int sz = size_s(), ls = -1, le = -1, cnt = 0;
@@ -991,7 +1050,7 @@ PIString PIString::takeRange(const PIChar & start, const PIChar & end, const PIC
}
PIString PIString::inBrackets(const PIChar &start, const PIChar &end) const {
PIString PIString::inBrackets(const PIChar start, const PIChar end) const {
int slen = length();
int st = -1, bcnt = 0;
PIChar cc;
@@ -1030,9 +1089,9 @@ PIString PIString::toNativeDecimalPoints() const {
#ifdef HAS_LOCALE
PIString s(*this);
if (currentLocale == 0) return s;
return s.replaceAll(".", currentLocale->decimal_point).replaceAll(",", currentLocale->decimal_point);
return s.replaceAll('.', currentLocale->decimal_point).replaceAll(',', currentLocale->decimal_point);
#else
return PIString(*this).replaceAll(",", ".");
return PIString(*this).replaceAll(',', '.');
#endif
}
@@ -1062,27 +1121,27 @@ ldouble PIString::toLDouble() const {
PIString & PIString::setReadableSize(llong bytes) {
clear();
if (bytes < 1024) {*this += (PIString::fromNumber(bytes) + " B"); return *this;}
if (bytes < 1024) {*this += (PIString::fromNumber(bytes) + PIStringAscii(" B")); return *this;}
double fres = bytes / 1024.;
llong res = bytes / 1024;
fres -= res;
if (res < 1024) {*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(llong(fres * 10)).left(1) + " kB"); return *this;}
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" kB")); return *this;}
fres = res / 1024.;
res /= 1024;
fres -= res;
if (res < 1024) {*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(llong(fres * 10)).left(1) + " MB"); return *this;}
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" MB")); return *this;}
fres = res / 1024.;
res /= 1024;
fres -= res;
if (res < 1024) {*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(llong(fres * 10)).left(1) + " GB"); return *this;}
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" GB")); return *this;}
fres = res / 1024.;
res /= 1024;
fres -= res;
if (res < 1024) {*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(llong(fres * 10)).left(1) + " TB"); return *this;}
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" TB")); return *this;}
fres = res / 1024.;
res /= 1024;
fres -= res;
*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(llong(fres * 10)).left(1) + " PB");
*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" PB"));
return *this;
}
@@ -1110,14 +1169,14 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
}
int mccnt = 2 - s.entries('.');
if (mccnt > 0) {
int ind = s.findLast(".") + 1;
int ind = s.findLast('.') + 1;
while (!_versionDelims_.contains(s[ind])) {
++ind;
if (ind > s.size_s() - 1)
break;
}
for (int i = 0; i < mccnt; ++i)
s.insert(ind, ".0");
s.insert(ind, PIStringAscii(".0"));
}
PIStringList comps;
while (!s.isEmpty()) {
@@ -1132,7 +1191,7 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
}
for (int i = 0; i < comps.size_s(); ++i) {
if (comps[i].isEmpty())
comps[i] = "0";
comps[i] = '0';
bool ok = false;
int val = comps[i].toInt(-1, &ok);
if (ok) {
@@ -1148,20 +1207,20 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
int versionLabelValue(PIString s) {
int ret = -10000;
if (s.isEmpty()) return 0;
if (s.startsWith("pre")) {
if (s.startsWith(PIStringAscii("pre"))) {
s.cutLeft(3);
ret -= 1;
}
if (s.startsWith("rc")) {
if (s.startsWith(PIStringAscii("rc"))) {
s.cutLeft(2);
ret += s.toInt();
}
if (s.startsWith("r")) {
if (s.startsWith(PIStringAscii("r"))) {
s.cutLeft(1);
ret += 10000 + s.toInt();
}
if (s == "alpha") ret -= 4;
if (s == "beta" ) ret -= 2;
if (s == PIStringAscii("alpha")) ret -= 4;
if (s == PIStringAscii("beta" )) ret -= 2;
return ret;
}
@@ -1200,13 +1259,13 @@ PIString versionNormalize(const PIString & v) {
PIString ret;
for (int i = 0; i < codes.size_s(); ++i) {
if (i > 0) {
if (i < 3) ret += ".";
else ret += "-";
if (i < 3) ret += '.';
else ret += '-';
}
ret += PIString::fromNumber(codes[i]);
}
for (int i = 0; i < strs.size_s(); ++i) {
ret += "_";
ret += '_';
ret += strs[i];
}
return ret;

View File

@@ -43,7 +43,8 @@ public:
static const float ElideCenter;
static const float ElideRight ;
PIString & operator +=(const PIChar & c) {push_back(c); return *this;}
PIString & operator +=(const PIChar c) {push_back(c); return *this;}
PIString & operator +=(const char c) {push_back(PIChar(c)); return *this;}
PIString & operator +=(const char * str);
PIString & operator +=(const wchar_t * str);
PIString & operator +=(const PIByteArray & ba) {appendFromChars((const char * )ba.data(), ba.size_s(), __utf8name__); return *this;}
@@ -55,7 +56,7 @@ public:
//! Contructs string with single symbol "c"
PIString(const PIChar & c): PIDeque<PIChar>() {*this += c;}
PIString(const PIChar c): PIDeque<PIChar>() {*this += c;}
PIString(const char c): PIDeque<PIChar>() {*this += PIChar(c);}
/*! \brief Contructs string from c-string "str"
@@ -84,7 +85,7 @@ public:
/*! \brief Contructs string as sequence of symbols "c" of buffer with length "len"
* \details Example: \snippet pistring.cpp PIString(int, PIChar) */
PIString(const int len, const PIChar & c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
PIString(const int len, const PIChar c): PIDeque<PIChar>() {for (int i = 0; i < len; ++i) push_back(c);}
~PIString() {}
@@ -110,7 +111,7 @@ public:
bool operator ==(const PIString & str) const;
//! Compare operator
bool operator ==(const PIChar c) const {return *this == PIString(c);}
bool operator ==(const PIChar c) const {if (size_s() != 1) return false; return at(0) == c;}
//! Compare operator
bool operator ==(const char * str) const {return *this == PIString(str);}
@@ -119,7 +120,7 @@ public:
bool operator !=(const PIString & str) const;
//! Compare operator
bool operator !=(const PIChar c) const {return *this != PIString(c);}
bool operator !=(const PIChar c) const {if (size_s() != 1) return true; return at(0) != c;}
//! Compare operator
bool operator !=(const char * str) const {return *this != PIString(str);}
@@ -128,7 +129,7 @@ public:
bool operator <(const PIString & str) const;
//! Compare operator
bool operator <(const PIChar c) const {return *this < PIString(c);}
bool operator <(const PIChar c) const {if (size_s() != 1) return size_s() < 1; return at(0) < c;}
//! Compare operator
bool operator <(const char * str) const {return *this < PIString(str);}
@@ -137,7 +138,7 @@ public:
bool operator >(const PIString & str) const;
//! Compare operator
bool operator >(const PIChar c) const {return *this > PIString(c);}
bool operator >(const PIChar c) const {if (size_s() != 1) return size_s() > 1; return at(0) > c;}
//! Compare operator
bool operator >(const char * str) const {return *this > PIString(str);}
@@ -146,7 +147,7 @@ public:
bool operator <=(const PIString & str) const {return !(*this > str);}
//! Compare operator
bool operator <=(const PIChar c) const {return *this <= PIString(c);}
bool operator <=(const PIChar c) const {return !(*this > c);}
//! Compare operator
bool operator <=(const char * str) const {return *this <= PIString(str);}
@@ -155,7 +156,7 @@ public:
bool operator >=(const PIString & str) const {return !(*this < str);}
//! Compare operator
bool operator >=(const PIChar c) const {return *this >= PIString(c);}
bool operator >=(const PIChar c) const {return !(*this < c);}
//! Compare operator
bool operator >=(const char * str) const {return *this >= PIString(str);}
@@ -166,7 +167,11 @@ public:
/*! \brief Append symbol "c" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(PIChar) */
PIString & operator <<(const PIChar & c) {*this += c; return *this;}
PIString & operator <<(const PIChar c) {*this += c; return *this;}
/*! \brief Append symbol "c" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(PIChar) */
PIString & operator <<(const char c) {*this += PIChar(c); return *this;}
/*! \brief Append c-string "str" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(char * ) */
@@ -181,11 +186,6 @@ public:
PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;}
PIString & operator <<(const uint & num) {*this += PIString::fromNumber(num); return *this;}
/*! \brief Append string representation of "num" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(int) */
PIString & operator <<(const short & num) {*this += PIString::fromNumber(num); return *this;}
PIString & operator <<(const ushort & num) {*this += PIString::fromNumber(num); return *this;}
/*! \brief Append string representation of "num" at the end of string
* \details Example: \snippet pistring.cpp PIString::<<(int) */
PIString & operator <<(const long & num) {*this += PIString::fromNumber(num); return *this;}
@@ -282,8 +282,20 @@ public:
* \details Example: \snippet pistring.cpp PIString::replaceAll
* \sa \a replace(), \a replaced() */
PIString & replaceAll(const PIString & what, const PIString & with);
PIString replaceAll(const PIString & what, const PIString & with) const {PIString str(*this); str.replaceAll(what, with); return str;}
/*! \brief Replace all founded symbols "what" with symbol "with" and return this string
* \details Example: \snippet pistring.cpp PIString::replaceAll
* \sa \a replace(), \a replaced() */
PIString & replaceAll(const char what, const char with);
PIString replacedAll(const PIString & what, const PIString & 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;}
PIString & removeAll(const PIString & str);
PIString & removeAll(char c) {PIDeque<PIChar>::removeAll(PIChar(c)); return *this;}
/*! \brief Repeat content of string "times" times and return this string
* \details Example: \snippet pistring.cpp PIString::repeat */
PIString & repeat(int times) {PIString ss(*this); times--; piForTimes (times) *this += ss; return *this;}
@@ -294,11 +306,11 @@ public:
/*! \brief Insert symbol "c" after index "index" and return this string
* \details Example: \snippet pistring.cpp PIString::insert_0 */
PIString & insert(const int index, const PIChar & c) {PIDeque<PIChar>::insert(index, c); return *this;}
PIString & insert(const int index, const PIChar c) {PIDeque<PIChar>::insert(index, c); return *this;}
/*! \brief Insert symbol "c" after index "index" and return this string
* \details Example: \snippet pistring.cpp PIString::insert_1 */
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));}
/*! \brief Insert string "str" after index "index" and return this string
* \details Example: \snippet pistring.cpp PIString::insert_2 */
@@ -312,13 +324,13 @@ public:
* "c" at the end of string, and return this string
* \details Example: \snippet pistring.cpp PIString::expandRightTo
* \sa \a expandLeftTo() */
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 > length()) resize(len, c); return *this;}
/*! \brief Enlarge string to length "len" by addition sequence of symbols
* "c" at the beginning of string, and return this string
* \details Example: \snippet pistring.cpp PIString::expandLeftTo
* \sa \a expandRightTo() */
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 > length()) insert(0, PIString(len - length(), c)); return *this;}
/*! \brief Add "c" symbols at the beginning and end of the string, and return this string
* \sa \a quoted() */
@@ -331,7 +343,7 @@ public:
/*! \brief Reverse string and return this string
* \details Example: \snippet pistring.cpp PIString::reverse
* \sa \a reversed() */
PIString & reverse() {PIString str(*this); clear(); piForeachR (const PIChar & c, str) push_back(c); return *this;}
PIString & reverse() {PIString str(*this); clear(); piForeachCR (PIChar c, str) push_back(c); return *this;}
/*! \brief Reverse copy of this string and return it
* \details Example: \snippet pistring.cpp PIString::reversed
@@ -394,13 +406,13 @@ public:
* \details "Shield" symbol prevent analysis of the next symbol.
* Example: \snippet pistring.cpp PIString::takeRange
* \sa \a takeSymbol(), \a takeWord(), \a takeLine(), \a takeNumber() */
PIString takeRange(const PIChar & start, const PIChar & end, const PIChar & shield = '\\');
PIString takeRange(const PIChar start, const PIChar end, const PIChar shield = '\\');
/*! \brief Return a string in brackets "start" and "end" symbols from the begin of this
* string and return it.
* \details Example: string = "a(b(c)d)e"; inBrackets('(', ')') = "b(c)d"; */
PIString inBrackets(const PIChar & start, const PIChar & end) const;
PIString inBrackets(const PIChar start, const PIChar end) const;
/*! \brief Return real bytes count of this string
* \details It`s equivalent length of char sequence
@@ -467,11 +479,8 @@ public:
PIString toNativeDecimalPoints() const;
//! \brief Returns if string contains "str"
bool contains(const char str) const {return contains(PIString(str));}
//! \brief Returns if string contains "str"
bool contains(const PIChar str) const {return contains(PIString(str));}
//! \brief Returns if string contains "c"
bool contains(const char c) const {return PIDeque<PIChar>::contains(PIChar(c));}
//! \brief Returns if string contains "str"
bool contains(const char * str) const {return contains(PIString(str));}
@@ -480,9 +489,9 @@ public:
bool contains(const PIString & str) const {return find(str) >= 0;}
//! \brief Search substring "str" from symbol at index "start" and return first occur position
//! \brief Search symbol "c" from symbol at index "start" and return first occur position
//! \details Example: \snippet pistring.cpp PIString::find
int find(const char str, const int start = 0) const;
int find(const char c, const int start = 0) const;
//! \brief Search substring "str" from symbol at index "start" and return first occur position
//! \details Example: \snippet pistring.cpp PIString::find
@@ -492,9 +501,9 @@ public:
//! \details Example: \snippet pistring.cpp PIString::find
int find(const char * str, const int start = 0) const {return find(PIString(str), start);}
//! \brief Search substring "str" from symbol at index "start" and return last occur position
//! \brief Search symbol "c" from symbol at index "start" and return last occur position
//! \details Example: \snippet pistring.cpp PIString::findLast
int findLast(const char str, const int start = 0) const;
int findLast(const char c, const int start = 0) const;
//! \brief Search substring "str" from symbol at index "start" and return last occur position
//! \details Example: \snippet pistring.cpp PIString::findLast
@@ -514,7 +523,7 @@ public:
//! \brief Search range between "start" and "end" symbols at index "start_index" and return first occur position.
//! \details Example: \snippet pistring.cpp PIString::findRange
int findRange(const PIChar & start, const PIChar & end, const PIChar & shield = '\\', const int start_index = 0, int * len = 0) const;
int findRange(const PIChar start, const PIChar end, const PIChar shield = '\\', const int start_index = 0, int * len = 0) const;
//! \brief Search any symbol of "str" from symbol at index "start" and return first occur position
//! \details Example: \snippet pistring.cpp PIString::findAny
@@ -533,7 +542,7 @@ public:
int findAnyLast(const char * str, const int start = 0) const {return findAnyLast(PIString(str), start);}
//! \brief Returns number of occurrences of symbol "c"
int entries(const PIChar & c) const;
int entries(const PIChar c) const;
//! \brief Returns number of occurrences of symbol "c"
int entries(char c) const {return entries(PIChar(c));}
@@ -718,9 +727,6 @@ public:
//! \details Example: \snippet pistring.cpp PIString::readableSize
static PIString readableSize(llong bytes);
PIString & removeAll(char v) {replaceAll(v, ""); return *this;}
PIString & removeAll(const PIString & v) {replaceAll(v, ""); return *this;}
private:
static const char toBaseN[];
static const int fromBaseN[];
@@ -763,6 +769,12 @@ inline PIString operator +(const PIString & f, const char * str) {PIString s(f);
//! \relatesalso PIString \brief Return concatenated string
inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;}
//! \relatesalso PIString \brief Return concatenated string
inline PIString operator +(const char c, const PIString & f) {return PIChar(c) + f;}
//! \relatesalso PIString \brief Return concatenated string
inline PIString operator +(const PIString & f, const char c) {return f + PIChar(c);}
inline char chrUpr(char c);
inline char chrLwr(char c);