PIString and PIChar fixes
This commit is contained in:
@@ -38,19 +38,19 @@ class PIP_EXPORT PIChar
|
|||||||
public:
|
public:
|
||||||
//! \~english Contructs Ascii symbol
|
//! \~english Contructs Ascii symbol
|
||||||
//! \~russian Создает символ Ascii
|
//! \~russian Создает символ Ascii
|
||||||
PIChar(const char c) {ch = c; ch &= 0xFF;}
|
PIChar(char c) {ch = c; ch &= 0xFF;}
|
||||||
|
|
||||||
//! \~english Contructs 2-bytes symbol
|
|
||||||
//! \~russian Создает 2-байтный символ
|
|
||||||
PIChar(const short c) {ch = c;}
|
|
||||||
|
|
||||||
//! \~english Contructs ascii symbol
|
//! \~english Contructs ascii symbol
|
||||||
//! \~russian Создает символ Ascii
|
//! \~russian Создает символ Ascii
|
||||||
PIChar(const uchar c) {ch = c;}
|
PIChar(uchar c) {ch = c;}
|
||||||
|
|
||||||
//! \~english Contructs 2-bytes symbol
|
//! \~english Contructs 2-bytes symbol
|
||||||
//! \~russian Создает 2-байтный символ
|
//! \~russian Создает 2-байтный символ
|
||||||
PIChar(const ushort c = 0) {ch = c;}
|
PIChar(ushort c = 0) {ch = c;}
|
||||||
|
|
||||||
|
//! \~english Contructs 2-bytes symbol from `wchar_t`
|
||||||
|
//! \~russian Создает 2-байтный символ из `wchar_t`
|
||||||
|
PIChar(wchar_t c) {ch = c;}
|
||||||
|
|
||||||
//! \~english Contructs symbol from system locale and no more than 4 bytes of string
|
//! \~english Contructs symbol from system locale and no more than 4 bytes of string
|
||||||
//! \~russian Создает символ из системной локали не более 4 байт длины
|
//! \~russian Создает символ из системной локали не более 4 байт длины
|
||||||
|
|||||||
@@ -139,26 +139,23 @@ const float PIString::ElideRight = 1.f;
|
|||||||
|
|
||||||
|
|
||||||
#ifndef CC_VC
|
#ifndef CC_VC
|
||||||
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf(ch, f, v);
|
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf(ch, f, v); return PIString(ch);
|
||||||
#else
|
#else
|
||||||
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf_s(ch, 256, f, v);
|
# define pisprintf(f, v) char ch[256]; memset(ch, 0, 256); sprintf_s(ch, 256, f, v); return PIString(ch);
|
||||||
#endif
|
#endif
|
||||||
#ifdef ANDROID
|
|
||||||
//int wctomb(char * c, wchar_t w) {*c = ((char * )&w)[0]; return 1;}
|
PIString PIString::itos(const int num) {pisprintf("%d", num);}
|
||||||
#endif
|
PIString PIString::ltos(const long num) {pisprintf("%ld", num);}
|
||||||
PIString PIString::itos(const int num) {pisprintf("%d", num); return PIString(ch);}
|
PIString PIString::lltos(const llong num) {pisprintf("%lld", num);}
|
||||||
PIString PIString::ltos(const long num) {pisprintf("%ld", num); return PIString(ch);}
|
PIString PIString::uitos(const uint num) {pisprintf("%u", num);}
|
||||||
PIString PIString::lltos(const llong num) {pisprintf("%lld", num); return PIString(ch);}
|
PIString PIString::ultos(const ulong num) {pisprintf("%lu", num);}
|
||||||
PIString PIString::uitos(const uint num) {pisprintf("%u", num); return PIString(ch);}
|
PIString PIString::ulltos(const ullong num) {pisprintf("%llu", num);}
|
||||||
PIString PIString::ultos(const ulong num) {pisprintf("%lu", num); return PIString(ch);}
|
|
||||||
PIString PIString::ulltos(const ullong num) {pisprintf("%llu", num); return PIString(ch);}
|
|
||||||
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 = sprintf(&(f[2]), "%d", precision);
|
||||||
f[2 + wr] = format;
|
f[2 + wr] = format;
|
||||||
f[3 + wr] = 0;
|
f[3 + wr] = 0;
|
||||||
pisprintf(f, num);
|
pisprintf(f, num);
|
||||||
return PIString(ch);
|
|
||||||
}
|
}
|
||||||
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] = "%.";
|
||||||
@@ -166,7 +163,6 @@ PIString PIString::dtos(const double num, char format, int precision) {
|
|||||||
f[2 + wr] = format;
|
f[2 + wr] = format;
|
||||||
f[3 + wr] = 0;
|
f[3 + wr] = 0;
|
||||||
pisprintf(f, num);
|
pisprintf(f, num);
|
||||||
return PIString(ch);
|
|
||||||
}
|
}
|
||||||
#undef pisprintf
|
#undef pisprintf
|
||||||
|
|
||||||
@@ -174,7 +170,10 @@ 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 (ok != 0) *ok = false; return PIString();}
|
if (base < 2 || base > 40) {
|
||||||
|
if (ok != 0) *ok = false;
|
||||||
|
return PIString();
|
||||||
|
}
|
||||||
if (ok != 0) *ok = true;
|
if (ok != 0) *ok = true;
|
||||||
if (base == 10) return lltos(value);
|
if (base == 10) return lltos(value);
|
||||||
PIString ret;
|
PIString ret;
|
||||||
@@ -193,7 +192,10 @@ 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 (ok != 0) *ok = false; return PIString();}
|
if (base < 2 || base > 40) {
|
||||||
|
if (ok != 0) *ok = false;
|
||||||
|
return PIString();
|
||||||
|
}
|
||||||
if (ok != 0) *ok = true;
|
if (ok != 0) *ok = true;
|
||||||
if (base == 10) return ulltos(value);
|
if (base == 10) return ulltos(value);
|
||||||
PIString ret;
|
PIString ret;
|
||||||
@@ -215,17 +217,26 @@ llong PIString::toNumberBase(const PIString & value, int base, bool * ok) {
|
|||||||
PIString v = value.trimmed();
|
PIString v = value.trimmed();
|
||||||
if (base < 0) {
|
if (base < 0) {
|
||||||
int ind = v.find(s_0x);
|
int ind = v.find(s_0x);
|
||||||
if (ind == 0 || ind == 1) {v.remove(ind, 2); base = 16;}
|
if (ind == 0 || ind == 1) {
|
||||||
else base = 10;
|
v.remove(ind, 2);
|
||||||
} else
|
base = 16;
|
||||||
if (base < 2 || base > 40) {if (ok != 0) *ok = false; return 0;}
|
} else {
|
||||||
|
base = 10;
|
||||||
|
}
|
||||||
|
} else if (base < 2 || base > 40) {
|
||||||
|
if (ok != 0) *ok = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (ok) *ok = true;
|
if (ok) *ok = true;
|
||||||
PIVector<int> digits;
|
PIVector<int> digits;
|
||||||
llong ret = 0, m = 1;
|
llong ret = 0, m = 1;
|
||||||
bool neg = false;
|
bool neg = false;
|
||||||
int cs;
|
int cs;
|
||||||
for (int i = 0; i < v.size_s(); ++i) {
|
for (int i = 0; i < v.size_s(); ++i) {
|
||||||
if (v[i] == PIChar('-')) {neg = !neg; continue;}
|
if (v[i] == PIChar('-')) {
|
||||||
|
neg = !neg;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
cs = fromBaseN[int(v[i].toAscii())];
|
cs = fromBaseN[int(v[i].toAscii())];
|
||||||
if (cs < 0 || cs >= base) {
|
if (cs < 0 || cs >= base) {
|
||||||
if (ok) *ok = false;
|
if (ok) *ok = false;
|
||||||
@@ -256,8 +267,9 @@ void PIString::appendFromChars(const char * c, int s, const char * codepage) {
|
|||||||
//printf("appendFromChars %d -> %d\n", s, sz);
|
//printf("appendFromChars %d -> %d\n", s, sz);
|
||||||
//printf("PIString %d -> %d\n", c[0], ucs[0]);
|
//printf("PIString %d -> %d\n", c[0], ucs[0]);
|
||||||
reserve(size_s() + sz);
|
reserve(size_s() + sz);
|
||||||
for (int i = 0; i < sz; ++i)
|
for (int i = 0; i < sz; ++i) {
|
||||||
push_back(PIChar(ucs[i]));
|
push_back(PIChar(ucs[i]));
|
||||||
|
}
|
||||||
delete[] ucs;
|
delete[] ucs;
|
||||||
ucnv_close(cc);
|
ucnv_close(cc);
|
||||||
return;
|
return;
|
||||||
@@ -339,8 +351,10 @@ PIString PIString::fromAscii(const char * s) {
|
|||||||
|
|
||||||
PIString PIString::fromAscii(const char * s, int len) {
|
PIString PIString::fromAscii(const char * s, int len) {
|
||||||
PIString ret;
|
PIString ret;
|
||||||
for (int l = 0; l < len; ++l)
|
ret.reserve(len);
|
||||||
|
for (int l = 0; l < len; ++l) {
|
||||||
ret.push_back(PIChar(s[l]));
|
ret.push_back(PIChar(s[l]));
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,15 +393,16 @@ void PIString::buildData(const char * cp) const {
|
|||||||
char uc[8];
|
char uc[8];
|
||||||
data_.reserve(size_s());
|
data_.reserve(size_s());
|
||||||
for (int i = 0; i < size_s(); ++i) {
|
for (int i = 0; i < size_s(); ++i) {
|
||||||
if (at(i).isAscii())
|
if (at(i).isAscii()) {
|
||||||
data_.push_back(uchar(at(i).unicode16Code()));
|
data_.push_back(uchar(at(i).unicode16Code()));
|
||||||
else {
|
} else {
|
||||||
e = (UErrorCode)0;
|
e = (UErrorCode)0;
|
||||||
sz = ucnv_fromUChars(cc, uc, 8, (const UChar*)(PIDeque<PIChar>::data(i)), 1, &e);
|
sz = ucnv_fromUChars(cc, uc, 8, (const UChar*)(PIDeque<PIChar>::data(i)), 1, &e);
|
||||||
for (int j = 0; j < sz; ++j)
|
for (int j = 0; j < sz; ++j) {
|
||||||
data_.push_back(uc[j]);
|
data_.push_back(uc[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
ucnv_close(cc);
|
ucnv_close(cc);
|
||||||
data_.push_back('\0');
|
data_.push_back('\0');
|
||||||
return;
|
return;
|
||||||
@@ -416,9 +431,10 @@ void PIString::buildData(const char * cp) const {
|
|||||||
}
|
}
|
||||||
wc = at(i).toWChar();
|
wc = at(i).toWChar();
|
||||||
sz = wctomb(tc, wc);
|
sz = wctomb(tc, wc);
|
||||||
for (int b = 0; b < sz; ++b)
|
for (int b = 0; b < sz; ++b) {
|
||||||
data_.push_back(uchar(tc[b]));
|
data_.push_back(uchar(tc[b]));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
data_.push_back(uchar('\0'));
|
data_.push_back(uchar('\0'));
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@@ -426,13 +442,19 @@ void PIString::buildData(const char * cp) 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 < length(); ++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; break;}
|
st = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (st < 0) return;
|
if (st < 0) return;
|
||||||
for (int i = length() - 1; i >= 0; --i)
|
for (int i = length() - 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; break;}
|
fn = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -450,8 +472,9 @@ const char * PIString::dataUTF8() const {
|
|||||||
|
|
||||||
const char * PIString::dataAscii() const {
|
const char * PIString::dataAscii() const {
|
||||||
data_.clear();
|
data_.clear();
|
||||||
for (int i = 0; i < size_s(); ++i)
|
for (int i = 0; i < size_s(); ++i) {
|
||||||
data_.push_back(uchar(at(i).ch));
|
data_.push_back(uchar(at(i).ch));
|
||||||
|
}
|
||||||
data_.push_back(uchar('\0'));
|
data_.push_back(uchar('\0'));
|
||||||
return (const char *)data_.data();
|
return (const char *)data_.data();
|
||||||
}
|
}
|
||||||
@@ -497,8 +520,9 @@ PIString & PIString::operator +=(const char * str) {
|
|||||||
PIString & PIString::operator +=(const wchar_t * str) {
|
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(ushort(str[i])));
|
push_back(PIChar(str[i]));
|
||||||
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -512,9 +536,9 @@ PIString & PIString::operator +=(const PIString & str) {
|
|||||||
bool PIString::operator ==(const PIString & str) const {
|
bool PIString::operator ==(const PIString & str) const {
|
||||||
uint l = str.size();
|
uint l = str.size();
|
||||||
if (size() != l) return false;
|
if (size() != l) return false;
|
||||||
for (uint i = 0; i < l; ++i)
|
for (uint i = 0; i < l; ++i) {
|
||||||
if (str[i] != at(i))
|
if (str[i] != at(i)) return false;
|
||||||
return false;
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,9 +546,9 @@ 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();
|
uint l = str.size();
|
||||||
if (size() != l) return true;
|
if (size() != l) return true;
|
||||||
for (uint i = 0; i < l; ++i)
|
for (uint i = 0; i < l; ++i) {
|
||||||
if (str[i] != at(i))
|
if (str[i] != at(i)) return true;
|
||||||
return true;
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,8 +590,7 @@ PIString PIString::mid(const int start, const int len) const {
|
|||||||
if (l < 0) {
|
if (l < 0) {
|
||||||
return PIString(&(at(s)), size_s() - s);
|
return PIString(&(at(s)), size_s() - s);
|
||||||
} else {
|
} else {
|
||||||
if (l > length() - s)
|
if (l > length() - s) l = length() - s;
|
||||||
l = length() - s;
|
|
||||||
return PIString(&(at(s)), l);
|
return PIString(&(at(s)), l);
|
||||||
}
|
}
|
||||||
return PIString();
|
return PIString();
|
||||||
@@ -581,11 +604,10 @@ PIString & PIString::cutMid(const int start, const int len) {
|
|||||||
l += s;
|
l += s;
|
||||||
s = 0;
|
s = 0;
|
||||||
}
|
}
|
||||||
if (l < 0)
|
if (l < 0) {
|
||||||
remove(s, size() - s);
|
remove(s, size() - s);
|
||||||
else {
|
} else {
|
||||||
if (l > length() - s)
|
if (l > length() - s) l = length() - s;
|
||||||
l = length() - s;
|
|
||||||
remove(s, l);
|
remove(s, l);
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@@ -615,9 +637,9 @@ 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(PIDeque<PIChar>::data(from), static_cast<PIDeque<PIChar>>(with).data(), count * sizeof(PIChar));
|
||||||
else {
|
} else {
|
||||||
remove(from, count);
|
remove(from, count);
|
||||||
PIDeque<PIChar>::insert(from, with);
|
PIDeque<PIChar>::insert(from, with);
|
||||||
}
|
}
|
||||||
@@ -639,8 +661,9 @@ PIString & PIString::replace(const PIString & what, const PIString & with, bool
|
|||||||
|
|
||||||
PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
||||||
if (what.isEmpty() || what == with) return *this;
|
if (what.isEmpty() || what == with) return *this;
|
||||||
if (with.isEmpty()) removeAll(what);
|
if (with.isEmpty()) {
|
||||||
else {
|
removeAll(what);
|
||||||
|
} else {
|
||||||
int l = what.length(), dl = with.length() - what.length();
|
int l = what.length(), dl = with.length() - what.length();
|
||||||
for (int i = 0; i < length() - l + 1; ++i) {
|
for (int i = 0; i < length() - l + 1; ++i) {
|
||||||
bool match = true;
|
bool match = true;
|
||||||
@@ -654,7 +677,6 @@ PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
|
|||||||
if (dl > 0) PIDeque<PIChar>::insert(i, PIDeque<PIChar>((size_t)dl));
|
if (dl > 0) PIDeque<PIChar>::insert(i, PIDeque<PIChar>((size_t)dl));
|
||||||
if (dl < 0) PIDeque<PIChar>::remove(i, -dl);
|
if (dl < 0) PIDeque<PIChar>::remove(i, -dl);
|
||||||
memcpy(PIDeque<PIChar>::data(i), &(with.at(0)), with.length() * sizeof(PIChar));
|
memcpy(PIDeque<PIChar>::data(i), &(with.at(0)), with.length() * sizeof(PIChar));
|
||||||
//i -= l;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
@@ -675,7 +697,6 @@ 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) PIDeque<PIChar>::remove(i, dl);
|
||||||
(*this)[i] = PIChar(with);
|
(*this)[i] = PIChar(with);
|
||||||
//i -= l;
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -684,8 +705,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)
|
if (at(i) == what) (*this)[i] = with;
|
||||||
(*this)[i] = with;
|
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -748,35 +768,35 @@ PIStringList PIString::split(const PIString & delim) const {
|
|||||||
|
|
||||||
|
|
||||||
int PIString::find(const char c, const int start) const {
|
int PIString::find(const char c, const int start) const {
|
||||||
for (int i = start; i < length(); ++i)
|
for (int i = start; i < length(); ++i) {
|
||||||
if (at(i) == c)
|
if (at(i) == c) return i;
|
||||||
return i;
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::find(const PIString & str, const int start) const {
|
int PIString::find(const PIString & str, const int start) const {
|
||||||
int l = str.length();
|
int l = str.length();
|
||||||
for (int i = start; i < length() - l + 1; ++i)
|
for (int i = start; i < length() - l + 1; ++i) {
|
||||||
if (mid(i, l) == str)
|
if (mid(i, l) == str) return i;
|
||||||
return i;
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::findLast(const char c, const int start) const {
|
int PIString::findLast(const char c, const int start) const {
|
||||||
for (int i = length() - 1; i >= start; --i)
|
for (int i = length() - 1; i >= start; --i) {
|
||||||
if (at(i) == c)
|
if (at(i) == c) return i;
|
||||||
return i;
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::findLast(const PIString & str, const int start) const {
|
int PIString::findLast(const PIString & str, const int start) const {
|
||||||
int l = str.length();
|
int l = str.length();
|
||||||
for (int i = length() - l; i >= start; --i)
|
for (int i = length() - l; i >= start; --i) {
|
||||||
if (mid(i, l) == str)
|
if (mid(i, l) == str) return i;
|
||||||
return i;
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -786,8 +806,20 @@ int PIString::findWord(const PIString & word, const int start) const {
|
|||||||
while ((f = find(word, f + 1)) >= 0) {
|
while ((f = find(word, f + 1)) >= 0) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
PIChar c;
|
PIChar c;
|
||||||
if (f > 0) {c = (*this)[f - 1]; if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {ok = false; continue;}}
|
if (f > 0) {
|
||||||
if (f + wl < tl) {c = (*this)[f + wl]; if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {ok = false; continue;}}
|
c = (*this)[f - 1];
|
||||||
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
|
||||||
|
ok = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (f + wl < tl) {
|
||||||
|
c = (*this)[f + wl];
|
||||||
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
|
||||||
|
ok = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ok) return f;
|
if (ok) return f;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -799,8 +831,20 @@ int PIString::findCWord(const PIString & word, const int start) const {
|
|||||||
while ((f = find(word, f + 1)) >= 0) {
|
while ((f = find(word, f + 1)) >= 0) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
PIChar c;
|
PIChar c;
|
||||||
if (f > 0) {c = (*this)[f - 1]; if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {ok = false; continue;}}
|
if (f > 0) {
|
||||||
if (f + wl < tl) {c = (*this)[f + wl]; if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {ok = false; continue;}}
|
c = (*this)[f - 1];
|
||||||
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {
|
||||||
|
ok = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (f + wl < tl) {
|
||||||
|
c = (*this)[f + wl];
|
||||||
|
if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r' || (c != '_' && !c.isAlpha() && !c.isDigit()))) {
|
||||||
|
ok = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (ok) return f;
|
if (ok) return f;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@@ -813,7 +857,10 @@ int PIString::findRange(const PIChar start, const PIChar end, const PIChar shiel
|
|||||||
int sz = size_s(), ls = -1, le = -1, cnt = 0;
|
int sz = size_s(), ls = -1, le = -1, cnt = 0;
|
||||||
for (int i = start_index; i < sz; ++i) {
|
for (int i = start_index; i < sz; ++i) {
|
||||||
PIChar c = at(i);
|
PIChar c = at(i);
|
||||||
if (c == shield) {++i; continue;}
|
if (c == shield) {
|
||||||
|
++i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (trim_) {
|
if (trim_) {
|
||||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
||||||
continue;
|
continue;
|
||||||
@@ -845,25 +892,26 @@ int PIString::findRange(const PIChar start, const PIChar end, const PIChar shiel
|
|||||||
|
|
||||||
|
|
||||||
int PIString::findAny(const PIString & str, const int start) const {
|
int PIString::findAny(const PIString & str, const int start) const {
|
||||||
for (int i = start; i < length(); ++i)
|
for (int i = start; i < length(); ++i) {
|
||||||
if (str.contains(at(i)))
|
if (str.contains(at(i))) return i;
|
||||||
return i;
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::findAnyLast(const PIString & str, const int start) const {
|
int PIString::findAnyLast(const PIString & str, const int start) const {
|
||||||
for (int i = length() - 1; i >= start; --i)
|
for (int i = length() - 1; i >= start; --i) {
|
||||||
if (str.contains(at(i)))
|
if (str.contains(at(i))) return i;
|
||||||
return i;
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int PIString::entries(const PIChar c) const {
|
int PIString::entries(const PIChar c) const {
|
||||||
int sz = size_s(), ret = 0;
|
int sz = size_s(), ret = 0;
|
||||||
for (int i = 0; i < sz; ++i)
|
for (int i = 0; i < sz; ++i) {
|
||||||
if (at(i) == c) ++ret;
|
if (at(i) == c) ++ret;
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -898,8 +946,7 @@ PIString PIString::takeSymbol() {
|
|||||||
int sz = size_s(), ss = -1;
|
int sz = size_s(), ss = -1;
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
PIChar c = at(i);
|
PIChar c = at(i);
|
||||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') continue;
|
||||||
continue;
|
|
||||||
ss = i;
|
ss = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -942,10 +989,11 @@ PIString PIString::takeCWord() {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ws < 0) {
|
if (ws < 0) {
|
||||||
if (c.isAlpha() || c == '_')
|
if (c.isAlpha() || c == '_') {
|
||||||
ws = i;
|
ws = i;
|
||||||
else
|
} else {
|
||||||
return ret;
|
return ret;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!c.isAlpha() && !c.isDigit() && c != '_') {
|
if (!c.isAlpha() && !c.isDigit() && c != '_') {
|
||||||
we = i;
|
we = i;
|
||||||
@@ -971,9 +1019,11 @@ PIString PIString::takeLine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
PIString ret = left(le);
|
PIString ret = left(le);
|
||||||
if (!ret.isEmpty())
|
if (!ret.isEmpty()) {
|
||||||
if (ret.back() == '\r')
|
if (ret.back() == '\r') {
|
||||||
ret.cutRight(1);
|
ret.cutRight(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
cutLeft(le < 0 ? sz : le + 1);
|
cutLeft(le < 0 ? sz : le + 1);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -988,37 +1038,75 @@ PIString PIString::takeNumber() {
|
|||||||
//piCout << "char " << c << "phase" << phase;
|
//piCout << "char " << c << "phase" << phase;
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case 0: // trim
|
case 0: // trim
|
||||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
phase = 7;
|
phase = 7;
|
||||||
case 7: // sign
|
case 7: // sign
|
||||||
if (c == '-' || c == '+') {ls = i; phase = 1; break;}
|
if (c == '-' || c == '+') {
|
||||||
|
ls = i;
|
||||||
|
phase = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case 1: // search start
|
case 1: // search start
|
||||||
if (c >= '0' && c <= '9') {le = i; if (ls < 0) ls = i; phase = 2; break;}
|
if ((c >= '0' && c <= '9') || c == '.') {
|
||||||
if (c == '.') {le = i; if (ls < 0) ls = i; phase = 3; break;}
|
le = i;
|
||||||
|
if (ls < 0) ls = i;
|
||||||
|
if (c == '.') phase = 3;
|
||||||
|
else phase = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
phase = 9;
|
phase = 9;
|
||||||
break;
|
break;
|
||||||
case 2: // integer
|
case 2: // integer
|
||||||
if (c == '.') {le = i; phase = 3; break;}
|
if (c == '.') {
|
||||||
if (c == 'e' || c == 'E') {le = i; phase = 4; break;}
|
le = i;
|
||||||
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || c == 'x') {le = i; break;}
|
phase = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (c == 'e' || c == 'E') {
|
||||||
|
le = i;
|
||||||
|
phase = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || c == 'x') {
|
||||||
|
le = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
phase = 6;
|
phase = 6;
|
||||||
break;
|
break;
|
||||||
case 3: // point
|
case 3: // point
|
||||||
if (c == 'e' || c == 'E') {le = i; phase = 4; break;}
|
if (c == 'e' || c == 'E') {
|
||||||
if (c >= '0' && c <= '9') {le = i; break;}
|
le = i;
|
||||||
|
phase = 4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (c >= '0' && c <= '9') {
|
||||||
|
le = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
phase = 6;
|
phase = 6;
|
||||||
break;
|
break;
|
||||||
case 4: // exp
|
case 4: // exp
|
||||||
if ((c >= '0' && c <= '9') || c == '-' || c == '+') {le = i; phase = 5; break;}
|
if ((c >= '0' && c <= '9') || c == '-' || c == '+') {
|
||||||
|
le = i;
|
||||||
|
phase = 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
phase = 6;
|
phase = 6;
|
||||||
break;
|
break;
|
||||||
case 5: // power
|
case 5: // power
|
||||||
if (c >= '0' && c <= '9') {le = i; break;}
|
if (c >= '0' && c <= '9') {
|
||||||
|
le = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
phase = 6;
|
phase = 6;
|
||||||
break;
|
break;
|
||||||
case 6: // suffix
|
case 6: // suffix
|
||||||
if (c == 'f' || c == 's' || c == 'u' || c == 'l' || c == 'L') {le = i; break;}
|
if (c == 'f' || c == 's' || c == 'u' || c == 'l' || c == 'L') {
|
||||||
|
le = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
phase = 9;
|
phase = 9;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1041,16 +1129,25 @@ PIString PIString::takeRange(const PIChar start, const PIChar end, const PIChar
|
|||||||
int sz = size_s(), ls = -1, le = -1, cnt = 0;
|
int sz = size_s(), ls = -1, le = -1, cnt = 0;
|
||||||
for (int i = 0; i < sz; ++i) {
|
for (int i = 0; i < sz; ++i) {
|
||||||
PIChar c = at(i);
|
PIChar c = at(i);
|
||||||
if (c == shield) {++i; continue;}
|
if (c == shield) {
|
||||||
if (trim_) {
|
++i;
|
||||||
if (c == ' ' || c == '\t' || c == '\n' || c == '\r')
|
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
if (trim_) {
|
||||||
|
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
trim_ = false;
|
trim_ = false;
|
||||||
}
|
}
|
||||||
if (eq) {
|
if (eq) {
|
||||||
if (c == start) {
|
if (c == start) {
|
||||||
if (cnt == 0) ls = i;
|
if (cnt == 0) {
|
||||||
else {le = i; cnt = 0; break;}
|
ls = i;
|
||||||
|
} else {
|
||||||
|
le = i;
|
||||||
|
cnt = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
cnt++;
|
cnt++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1095,7 +1192,9 @@ PIString PIString::inBrackets(const PIChar start, const PIChar end) const {
|
|||||||
PIString PIString::toUpperCase() const {
|
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) str[i] = str[i].toUpper();
|
for (int i = 0; i < l; ++i) {
|
||||||
|
str[i] = str[i].toUpper();
|
||||||
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1103,7 +1202,9 @@ PIString PIString::toUpperCase() const {
|
|||||||
PIString PIString::toLowerCase() const {
|
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) str[i] = str[i].toLower();
|
for (int i = 0; i < l; ++i) {
|
||||||
|
str[i] = str[i].toLower();
|
||||||
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1144,23 +1245,38 @@ ldouble PIString::toLDouble() const {
|
|||||||
|
|
||||||
PIString & PIString::setReadableSize(llong bytes) {
|
PIString & PIString::setReadableSize(llong bytes) {
|
||||||
clear();
|
clear();
|
||||||
if (bytes < 1024) {*this += (PIString::fromNumber(bytes) + PIStringAscii(" B")); return *this;}
|
if (bytes < 1024) {
|
||||||
|
*this += (PIString::fromNumber(bytes) + PIStringAscii(" B"));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
double fres = bytes / 1024.;
|
double fres = bytes / 1024.;
|
||||||
llong res = bytes / 1024;
|
llong res = bytes / 1024;
|
||||||
fres -= res;
|
fres -= res;
|
||||||
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" 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.;
|
fres = res / 1024.;
|
||||||
res /= 1024;
|
res /= 1024;
|
||||||
fres -= res;
|
fres -= res;
|
||||||
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" 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.;
|
fres = res / 1024.;
|
||||||
res /= 1024;
|
res /= 1024;
|
||||||
fres -= res;
|
fres -= res;
|
||||||
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" 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.;
|
fres = res / 1024.;
|
||||||
res /= 1024;
|
res /= 1024;
|
||||||
fres -= res;
|
fres -= res;
|
||||||
if (res < 1024) {*this += (PIString::fromNumber(res) + PIStringAscii(".") + PIString::fromNumber(llong(fres * 10)).left(1) + PIStringAscii(" 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.;
|
fres = res / 1024.;
|
||||||
res /= 1024;
|
res /= 1024;
|
||||||
fres -= res;
|
fres -= res;
|
||||||
@@ -1183,12 +1299,12 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
|
|||||||
int ind = s.findLast('.') + 1;
|
int ind = s.findLast('.') + 1;
|
||||||
while (!_versionDelims_.contains(s[ind])) {
|
while (!_versionDelims_.contains(s[ind])) {
|
||||||
++ind;
|
++ind;
|
||||||
if (ind > s.size_s() - 1)
|
if (ind > s.size_s() - 1) break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
for (int i = 0; i < mccnt; ++i)
|
for (int i = 0; i < mccnt; ++i) {
|
||||||
s.insert(ind, PIStringAscii(".0"));
|
s.insert(ind, PIStringAscii(".0"));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
PIStringList comps;
|
PIStringList comps;
|
||||||
while (!s.isEmpty()) {
|
while (!s.isEmpty()) {
|
||||||
int ind = s.findAny(_versionDelims_);
|
int ind = s.findAny(_versionDelims_);
|
||||||
@@ -1201,8 +1317,7 @@ void parseVersion(PIString s, PIVector<int> & codes, PIStringList & strs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int i = 0; i < comps.size_s(); ++i) {
|
for (int i = 0; i < comps.size_s(); ++i) {
|
||||||
if (comps[i].isEmpty())
|
if (comps[i].isEmpty()) comps[i] = '0';
|
||||||
comps[i] = '0';
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int val = comps[i].toInt(-1, &ok);
|
int val = comps[i].toInt(-1, &ok);
|
||||||
if (ok) {
|
if (ok) {
|
||||||
|
|||||||
@@ -34,13 +34,13 @@
|
|||||||
|
|
||||||
inline std::string PIString2StdString(const PIString & v) {
|
inline std::string PIString2StdString(const PIString & v) {
|
||||||
std::string s;
|
std::string s;
|
||||||
uint wc;
|
ushort wc;
|
||||||
uchar tc;
|
uchar tc;
|
||||||
if (v.size() > 0) {
|
if (v.size() > 0) {
|
||||||
for (int i = 0; i < v.length(); ++i) {
|
for (int i = 0; i < v.length(); ++i) {
|
||||||
wc = uint(v.at(i).unicode16Code());
|
wc = v[i].unicode16Code();
|
||||||
while (tc = wc & 0xFF, tc) {
|
while (tc = wc & 0xFF, tc) {
|
||||||
s.push_back(char(tc));
|
s.push_back(tc);
|
||||||
wc >>= 8;
|
wc >>= 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,22 +48,28 @@ inline std::string PIString2StdString(const PIString & v) {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline PIString StdString2PIString(const std::string & v) {
|
inline PIString StdString2PIString(const std::string & v) {
|
||||||
return PIString(v.c_str(), v.length());
|
return PIString(v.c_str(), v.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAS_LOCALE
|
#ifdef HAS_LOCALE
|
||||||
inline std::wstring PIString2StdWString(const PIString & v) {
|
inline std::wstring PIString2StdWString(const PIString & v) {
|
||||||
std::wstring s;
|
std::wstring s;
|
||||||
for (int i = 0; i < v.length(); ++i)
|
for (int i = 0; i < v.length(); ++i) {
|
||||||
s.push_back(v.at(i).toWChar());
|
s.push_back(v[i].toWChar());
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline PIString StdWString2PIString(const std::wstring & v) {
|
inline PIString StdWString2PIString(const std::wstring & v) {
|
||||||
PIString s;
|
PIString s;
|
||||||
uint l = v.size();
|
uint l = v.size();
|
||||||
for (uint i = 0; i < l; ++i) s.push_back(v[i]);
|
for (uint i = 0; i < l; ++i) {
|
||||||
|
s.push_back(v[i]);
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -71,20 +77,42 @@ inline PIString StdWString2PIString(const std::wstring & v) {
|
|||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIChar \brief Output operator to \c std::ostream
|
//! \relatesalso PIChar \brief Output operator to \c std::ostream
|
||||||
inline std::ostream & operator <<(std::ostream & s, const PIChar & v) {s << v.toCharPtr(); return s;}
|
inline std::ostream & operator <<(std::ostream & s, const PIChar & v) {
|
||||||
|
s << v.toCharPtr();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Return concatenated string
|
//! \relatesalso PIString \brief Return concatenated string
|
||||||
inline PIString operator +(const PIString & f, const std::string & str) {PIString s(f); s += StdString2PIString(str); return s;}
|
inline PIString operator +(const PIString & f, const std::string & str) {
|
||||||
|
PIString s(f);
|
||||||
|
s += StdString2PIString(str);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Return concatenated string
|
//! \relatesalso PIString \brief Return concatenated string
|
||||||
inline PIString operator +(const std::string & str, const PIString & f) {return StdString2PIString(str) + f;}
|
inline PIString operator +(const std::string & str, const PIString & f) {
|
||||||
|
return StdString2PIString(str) + f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Output operator to std::ostream (cout)
|
//! \relatesalso PIString \brief Output operator to std::ostream (cout)
|
||||||
inline std::ostream & operator <<(std::ostream & s, const PIString & v) {for (int i = 0; i < v.length(); ++i) s << v[i]; return s;}
|
inline std::ostream & operator <<(std::ostream & s, const PIString & v) {
|
||||||
|
for (int i = 0; i < v.length(); ++i) {
|
||||||
|
s << v[i];
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIString \brief Input operator from std::istream (cin)
|
//! \relatesalso PIString \brief Input operator from std::istream (cin)
|
||||||
inline std::istream & operator >>(std::istream & s, PIString & v) {std::string ss; s >> ss; v = StdString2PIString(ss); return s;}
|
inline std::istream & operator >>(std::istream & s, PIString & v) {
|
||||||
|
std::string ss;
|
||||||
|
s >> ss;
|
||||||
|
v = StdString2PIString(ss);
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//! \relatesalso PIStringList \brief Output operator to std::ostream (cout)
|
//! \relatesalso PIStringList \brief Output operator to std::ostream (cout)
|
||||||
|
|||||||
Reference in New Issue
Block a user