git-svn-id: svn://db.shs.com.ru/pip@220 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -255,6 +255,18 @@ void PIString::buildData(const char * cp) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PIString::trimsubstr(int &st, int &fn) const {
|
||||||
|
for (int i = 0; i < length(); ++i)
|
||||||
|
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12))
|
||||||
|
{st = i; break;}
|
||||||
|
if (st < 0) return;
|
||||||
|
for (int i = length() - 1; i >= 0; --i)
|
||||||
|
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12))
|
||||||
|
{fn = i; break;}
|
||||||
|
piCout << "trim" << st << fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * PIString::dataConsole() const {
|
const char * PIString::dataConsole() const {
|
||||||
buildData(
|
buildData(
|
||||||
#ifdef PIP_ICU
|
#ifdef PIP_ICU
|
||||||
@@ -459,14 +471,12 @@ PIString & PIString::cutMid(const int start, const int len) {
|
|||||||
|
|
||||||
|
|
||||||
PIString & PIString::trim() {
|
PIString & PIString::trim() {
|
||||||
int st = 0, fn = 0;
|
int st = -1, fn = 0;
|
||||||
for (int i = 0; i < length(); ++i)
|
trimsubstr(st, fn);
|
||||||
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12))
|
if (st < 0) {
|
||||||
{st = i; break;}
|
clear();
|
||||||
for (int i = length() - 1; i >= 0; --i)
|
return *this;
|
||||||
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12))
|
}
|
||||||
{fn = i; break;}
|
|
||||||
//*this = mid(st, fn - st + 1);
|
|
||||||
if (fn < size_s() - 1) cutRight(size_s() - fn - 1);
|
if (fn < size_s() - 1) cutRight(size_s() - fn - 1);
|
||||||
if (st > 0) cutLeft(st);
|
if (st > 0) cutLeft(st);
|
||||||
return *this;
|
return *this;
|
||||||
@@ -474,13 +484,9 @@ PIString & PIString::trim() {
|
|||||||
|
|
||||||
|
|
||||||
PIString PIString::trimmed() const {
|
PIString PIString::trimmed() const {
|
||||||
int st = 0, fn = 0;
|
int st = -1, fn = 0;
|
||||||
for (int i = 0; i < length(); ++i)
|
trimsubstr(st, fn);
|
||||||
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12))
|
if (st < 0) return PIString();
|
||||||
{st = i; break;}
|
|
||||||
for (int i = length() - 1; i >= 0; --i)
|
|
||||||
if (at(i) != ' ' && at(i) != '\t' && at(i) != '\n' && at(i) != '\r' && at(i) != char(12))
|
|
||||||
{fn = i; break;}
|
|
||||||
return mid(st, fn - st + 1);
|
return mid(st, fn - st + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -799,7 +799,7 @@ private:
|
|||||||
} else
|
} else
|
||||||
if (base < 2 || base > 40) {if (ok != 0) *ok = false; return 0;}
|
if (base < 2 || base > 40) {if (ok != 0) *ok = false; return 0;}
|
||||||
//v.reverse();
|
//v.reverse();
|
||||||
if (ok != 0) *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;
|
||||||
@@ -807,7 +807,10 @@ private:
|
|||||||
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) break;
|
if (cs < 0 || cs >= base) {
|
||||||
|
if (ok) *ok = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
digits << cs;
|
digits << cs;
|
||||||
}
|
}
|
||||||
for (int i = digits.size_s() - 1; i >= 0; --i) {
|
for (int i = digits.size_s() - 1; i >= 0; --i) {
|
||||||
@@ -827,6 +830,7 @@ private:
|
|||||||
}
|
}
|
||||||
void appendFromChars(const char * c, int s, const char * cp = 0);
|
void appendFromChars(const char * c, int s, const char * cp = 0);
|
||||||
void buildData(const char * cp = 0) const;
|
void buildData(const char * cp = 0) const;
|
||||||
|
void trimsubstr(int &st, int &fn) const;
|
||||||
std::string convertToStd() const;
|
std::string convertToStd() const;
|
||||||
#ifdef HAS_LOCALE
|
#ifdef HAS_LOCALE
|
||||||
wstring convertToWString() const {wstring s; for (int i = 0; i < length(); ++i) s.push_back(at(i).toWChar()); return s;}
|
wstring convertToWString() const {wstring s; for (int i = 0; i < length(); ++i) s.push_back(at(i).toWChar()); return s;}
|
||||||
|
|||||||
Reference in New Issue
Block a user