#ifndef PISTRING_H #define PISTRING_H #include "piincludes.h" class PIString: public vector { public: PIString() {;} PIString(const char & c) {*this += c;} PIString(const char * str) {*this += str;} 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 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;} inline PIString & operator <<(const string & str) {*this += str; return *this;} inline PIString & operator <<(const int & num) {*this += PIString::fromNumber(num); return *this;} inline PIString & operator <<(const short & num) {*this += PIString::fromNumber(num); return *this;} 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);} PIString & cutMid(const int start, const int len); inline PIString & cutLeft(const int len) {return len <= 0 ? *this : cutMid(0, len);} 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();} 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);} inline int find(const string str, const int start = 0) {return find(PIString(str), start);} int findLast(const char str, const int start = 0); 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;} inline PIString operator +(const PIString & f, const char & c) {PIString s(f); s.push_back(c); return s;} inline PIString operator +(const PIString & f, const char * str) {PIString s(f); s += str; return s;} inline PIString operator +(const PIString & f, const string & str) {PIString s(f); s += str; return s;} inline PIString operator +(const char & c, const PIString & f) {return PIString(c) + f;} inline PIString operator +(const char * str, const PIString & f) {return PIString(str) + f;} inline PIString operator +(const string & str, const PIString & f) {return PIString(str) + f;} char chrUpr(char c); char chrLwr(char c); #endif // PISTRING_H