git-svn-id: svn://db.shs.com.ru/pip@223 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
This commit is contained in:
@@ -430,21 +430,19 @@ bool PIString::operator >(const PIString & str) const {
|
||||
PIString PIString::mid(const int start, const int len) const {
|
||||
//PIString str;
|
||||
int s = start, l = len;
|
||||
if (l == 0 || start >= length()) return PIString();
|
||||
if (l == 0 || s >= length()) return PIString();
|
||||
if (s < 0) {
|
||||
l += s;
|
||||
s = 0;
|
||||
}
|
||||
if (l < 0) {
|
||||
//for (uint i = s; i < size(); ++i)
|
||||
// str += at(i);
|
||||
return PIString(&(at(s)), size_s() - s);
|
||||
} else {
|
||||
if (l > length() - s)
|
||||
l = length() - s;
|
||||
//for (int i = s; i < s + l; ++i)
|
||||
// str += at(i);
|
||||
//std::cout << "mid " << s << " " << l << " " << size_s() << " " << start << " " << len << "\n";
|
||||
// std::cout << "mid " << s << " " << l << " " << size_s() << " " << start << " " << len << "\n";
|
||||
return PIString(&(at(s)), l);
|
||||
}
|
||||
return PIString();
|
||||
@@ -795,6 +793,25 @@ PIString PIString::takeRange(const PIChar & start, const PIChar & end, const PIC
|
||||
}
|
||||
|
||||
|
||||
PIString PIString::inBrackets(const PIChar &start, const PIChar &end) const {
|
||||
int slen = length();
|
||||
int st = -1, bcnt = 0;
|
||||
PIChar cc;
|
||||
for (int i = 0; i < slen; i++) {
|
||||
cc = at(i);
|
||||
if (cc == start) {
|
||||
if (bcnt == 0) st = i;
|
||||
bcnt++;
|
||||
}
|
||||
if (cc == end && st >= 0) {
|
||||
bcnt--;
|
||||
if (bcnt == 0) return mid(st+1, i-st-1);
|
||||
}
|
||||
}
|
||||
return PIString();
|
||||
}
|
||||
|
||||
|
||||
PIString PIString::toUpperCase() const {
|
||||
PIString str(*this);
|
||||
int l = str.size();
|
||||
|
||||
@@ -450,8 +450,11 @@ public:
|
||||
* \sa \a takeSymbol(), \a takeWord(), \a takeLine(), \a takeNumber() */
|
||||
PIString takeRange(const PIChar & start, const PIChar & end, const PIChar & shield = '\\');
|
||||
|
||||
//const char * data() {return convertToStd().c_str();}
|
||||
|
||||
|
||||
/*! \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;
|
||||
|
||||
/*! \brief Return real bytes count of this string
|
||||
* \details It`s equivalent length of char sequence
|
||||
|
||||
Reference in New Issue
Block a user