8.12.2010 - bug fixes
This commit is contained in:
30
pistring.h
30
pistring.h
@@ -12,27 +12,27 @@ public:
|
||||
PIString(const string & str) {*this += str;}
|
||||
PIString(const PIString & str) {*this += str;}
|
||||
PIString(const int len, const char c = ' ') {for (uint i = 0; i < len; ++i) push_back(c);}
|
||||
|
||||
operator const char*() {return (size() == 0) ? "" : string(&at(0), size()).c_str();}
|
||||
|
||||
operator const char*() {return data();}
|
||||
operator const string() {return (size() == 0) ? string() : string(&at(0), size());}
|
||||
inline char & operator [](const int pos) {return at(pos);}
|
||||
inline const char operator [](const int pos) const {return at(pos);}
|
||||
|
||||
|
||||
PIString & operator +=(const PIString & str);
|
||||
inline PIString & operator +=(const char & c) {push_back(c); return *this;}
|
||||
PIString & operator +=(const char * str);
|
||||
PIString & operator +=(const string & str);
|
||||
|
||||
|
||||
bool operator ==(const PIString & str) const;
|
||||
inline bool operator ==(const char & c) const {return *this == PIString(c);}
|
||||
inline bool operator ==(const char * str) const {return *this == PIString(str);}
|
||||
inline bool operator ==(const string & str) const {return *this == PIString(str);}
|
||||
|
||||
|
||||
bool operator !=(const PIString & str) const;
|
||||
inline bool operator !=(const char & c) const {return *this != PIString(c);}
|
||||
inline bool operator !=(const char * str) const {return *this != PIString(str);}
|
||||
inline bool operator !=(const string & str) const {return *this != PIString(str);}
|
||||
|
||||
|
||||
PIString & operator <<(const PIString & str) {*this += str; return *this;}
|
||||
inline PIString & operator <<(const char & c) {*this += c; return *this;}
|
||||
inline PIString & operator <<(const char * str) {*this += str; return *this;}
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
inline PIString & operator <<(const long & num) {*this += PIString::fromNumber(num); return *this;}
|
||||
inline PIString & operator <<(const float & num) {*this += PIString::fromNumber(num); return *this;}
|
||||
inline PIString & operator <<(const double & num) {*this += PIString::fromNumber(num); return *this;}
|
||||
|
||||
|
||||
PIString mid(const int start, const int len = -1) const;
|
||||
inline PIString left(const int len) const {return len <= 0 ? PIString() : mid(0, len);}
|
||||
inline PIString right(const int len) const {return len <= 0 ? PIString() : mid(size() - len, len);}
|
||||
@@ -51,12 +51,12 @@ public:
|
||||
inline PIString & cutRight(const int len) {return len <= 0 ? *this : cutMid(size() - len, len);}
|
||||
PIString trimmed() const;
|
||||
PIString & trim();
|
||||
const char * data() const {return ((size() == 0) ? string() : string(&at(0), size())).c_str();}
|
||||
const char * data() const {return stdString().c_str();}
|
||||
string stdString() const {return (size() == 0) ? string() : string(&at(0), size());}
|
||||
|
||||
|
||||
PIString toUpperCase() const;
|
||||
PIString toLowerCase() const;
|
||||
|
||||
|
||||
int find(const char str, const int start = 0);
|
||||
int find(const PIString str, const int start = 0);
|
||||
inline int find(const char * str, const int start = 0) {return find(PIString(str), start);}
|
||||
@@ -65,28 +65,28 @@ public:
|
||||
int findLast(const PIString str, const int start = 0);
|
||||
inline int findLast(const char * str, const int start = 0) {return findLast(PIString(str), start);}
|
||||
inline int findLast(const string str, const int start = 0) {return findLast(PIString(str), start);}
|
||||
|
||||
|
||||
inline int length() const {return size();}
|
||||
inline bool isEmpty() const {return size() == 0;}
|
||||
|
||||
|
||||
int toInt() const {return atoi(data());}
|
||||
short toShort() const {return (short)atoi(data());}
|
||||
long toLong() const {return atol(data());}
|
||||
float toFloat() const {return (float)atof(data());}
|
||||
double toDouble() const {return atof(data());}
|
||||
|
||||
|
||||
inline PIString & setNumber(const int value) {clear(); *this += itos(value); return *this;}
|
||||
inline PIString & setNumber(const short value) {clear(); *this += itos(value); return *this;}
|
||||
inline PIString & setNumber(const long value) {clear(); *this += ltos(value); return *this;}
|
||||
inline PIString & setNumber(const float value) {clear(); *this += ftos(value); return *this;}
|
||||
inline PIString & setNumber(const double value) {clear(); *this += dtos(value); return *this;}
|
||||
|
||||
|
||||
inline static PIString fromNumber(const int value) {return PIString(itos(value));}
|
||||
inline static PIString fromNumber(const short value) {return PIString(itos(value));}
|
||||
inline static PIString fromNumber(const long value) {return PIString(ltos(value));}
|
||||
inline static PIString fromNumber(const float value) {return PIString(ftos(value));}
|
||||
inline static PIString fromNumber(const double value) {return PIString(dtos(value));}
|
||||
|
||||
|
||||
};
|
||||
|
||||
inline PIString operator +(const PIString & str, const PIString & f) {PIString s(str); s += f; return s;}
|
||||
|
||||
Reference in New Issue
Block a user