diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-01 13:54:44 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-01 13:54:44 +0400 |
commit | 1597ad9377460453845b48af69ea888e32297cc1 (patch) | |
tree | 3cda36a62e12b9e19bb124dacfd97a6ac0c9b108 /intern/string/STR_String.h | |
parent | 93cb7fb97b30641300185101526206253ef316b2 (diff) |
style cleanup
Diffstat (limited to 'intern/string/STR_String.h')
-rw-r--r-- | intern/string/STR_String.h | 104 |
1 files changed, 52 insertions, 52 deletions
diff --git a/intern/string/STR_String.h b/intern/string/STR_String.h index ac8b855bbe9..1705d7855e0 100644 --- a/intern/string/STR_String.h +++ b/intern/string/STR_String.h @@ -115,23 +115,23 @@ public: void Replace(int pos, int num, rcSTR_String str); // Substrings - inline STR_String Left(int num) const { num = (num < Len ? num:Len ); return STR_String(pData, num); } - inline STR_String Right(int num) const { num = (num < Len ? num:Len ); return STR_String(pData+Len-num, num); } - inline STR_String Mid(int pos, int num = INT_MAX) const { pos = (pos < Len ? pos:Len ); num = (num < (Len - pos) ? num : (Len - pos)); return STR_String(pData+pos, num); } + inline STR_String Left(int num) const { num = (num < Len ? num:Len ); return STR_String(pData, num); } + inline STR_String Right(int num) const { num = (num < Len ? num:Len ); return STR_String(pData+Len-num, num); } + inline STR_String Mid(int pos, int num = INT_MAX) const { pos = (pos < Len ? pos:Len ); num = (num < (Len - pos) ? num : (Len - pos)); return STR_String(pData+pos, num); } // Comparison - int Compare(rcSTR_String rhs) const; - int CompareNoCase(rcSTR_String rhs) const; - inline bool IsEqual(rcSTR_String rhs) const { return (Compare(rhs)==0); } - inline bool IsEqualNoCase(rcSTR_String rhs) const { return (CompareNoCase(rhs)==0); } + int Compare(rcSTR_String rhs) const; + int CompareNoCase(rcSTR_String rhs) const; + inline bool IsEqual(rcSTR_String rhs) const { return (Compare(rhs)==0); } + inline bool IsEqualNoCase(rcSTR_String rhs) const { return (CompareNoCase(rhs)==0); } // Search/replace - int Find(char c, int pos = 0) const; - int Find(const char *str, int pos = 0) const; - int Find(rcSTR_String str, int pos = 0) const; - int RFind(char c) const; - int FindOneOf(const char *set, int pos = 0) const; - int RFindOneOf(const char *set, int pos = 0) const; + int Find(char c, int pos = 0) const; + int Find(const char *str, int pos = 0) const; + int Find(rcSTR_String str, int pos = 0) const; + int RFind(char c) const; + int FindOneOf(const char *set, int pos = 0) const; + int RFindOneOf(const char *set, int pos = 0) const; std::vector<STR_String> Explode(char c) const; @@ -148,42 +148,42 @@ public: STR_String& TrimQuotes(); // Conversions -// inline operator char*() { return pData; } - inline operator const char *() const { return pData; } - inline char *Ptr() { return pData; } - inline const char *ReadPtr() const { return pData; } - inline float ToFloat() const { float x=(float)(atof(pData)); return x; } - inline int ToInt() const { return atoi(pData); } +// inline operator char*() { return pData; } + inline operator const char *() const { return pData; } + inline char *Ptr() { return pData; } + inline const char *ReadPtr() const { return pData; } + inline float ToFloat() const { float x=(float)(atof(pData)); return x; } + inline int ToInt() const { return atoi(pData); } // Operators - inline rcSTR_String operator=(const byte *rhs) { return Copy((const char *)rhs, strlen((const char *)rhs)); } - inline rcSTR_String operator=(rcSTR_String rhs) { return Copy(rhs.ReadPtr(), rhs.Length()); } - inline rcSTR_String operator=(char rhs) { return Copy(&rhs, 1); } - inline rcSTR_String operator=(const char *rhs) { return Copy(rhs, strlen(rhs)); } - - inline rcSTR_String operator+=(const char *rhs) { return Concat(rhs, strlen(rhs)); } - inline rcSTR_String operator+=(rcSTR_String rhs) { return Concat(rhs.ReadPtr(), rhs.Length()); } - inline rcSTR_String operator+=(char rhs) { return Concat(&rhs, 1); } - - - inline friend bool operator<(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } - inline friend bool operator<(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<0); }; - inline friend bool operator<(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } - inline friend bool operator>(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } - inline friend bool operator>(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>0); } - inline friend bool operator>(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } - inline friend bool operator<=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } - inline friend bool operator<=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<=0); } - inline friend bool operator<=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } - inline friend bool operator>=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } - inline friend bool operator>=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>=0); } - inline friend bool operator>=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } - inline friend bool operator==(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() == rhs.Length()) && (memcmp(lhs, rhs, lhs.Length())==0)); } - inline friend bool operator==(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)==0); } - inline friend bool operator==(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)==0); } - inline friend bool operator!=(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() != rhs.Length()) || (memcmp(lhs, rhs, lhs.Length())!=0)); } - inline friend bool operator!=(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)!=0); } - inline friend bool operator!=(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)!=0); } + inline rcSTR_String operator=(const byte *rhs) { return Copy((const char *)rhs, strlen((const char *)rhs)); } + inline rcSTR_String operator=(rcSTR_String rhs) { return Copy(rhs.ReadPtr(), rhs.Length()); } + inline rcSTR_String operator=(char rhs) { return Copy(&rhs, 1); } + inline rcSTR_String operator=(const char *rhs) { return Copy(rhs, strlen(rhs)); } + + inline rcSTR_String operator+=(const char *rhs) { return Concat(rhs, strlen(rhs)); } + inline rcSTR_String operator+=(rcSTR_String rhs) { return Concat(rhs.ReadPtr(), rhs.Length()); } + inline rcSTR_String operator+=(char rhs) { return Concat(&rhs, 1); } + + + inline friend bool operator<(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } + inline friend bool operator<(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<0); } + inline friend bool operator<(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); } + inline friend bool operator>(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } + inline friend bool operator>(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>0); } + inline friend bool operator>(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); } + inline friend bool operator<=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } + inline friend bool operator<=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<=0); } + inline friend bool operator<=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); } + inline friend bool operator>=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } + inline friend bool operator>=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>=0); } + inline friend bool operator>=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); } + inline friend bool operator==(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() == rhs.Length()) && (memcmp(lhs, rhs, lhs.Length())==0)); } + inline friend bool operator==(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)==0); } + inline friend bool operator==(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)==0); } + inline friend bool operator!=(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() != rhs.Length()) || (memcmp(lhs, rhs, lhs.Length())!=0)); } + inline friend bool operator!=(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)!=0); } + inline friend bool operator!=(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)!=0); } // serializing //int Serialize(pCStream stream); @@ -198,7 +198,7 @@ protected: static bool isUpper(char c) { return (c>='A') && (c <= 'Z'); } static bool isSpace(char c) { return (c==' ') || (c=='\t'); } - char *pData; // -> STR_String data + char *pData; // -> STR_String data int Len; // Data length int Max; // Space in data buffer @@ -209,10 +209,10 @@ protected: }; inline STR_String operator+(rcSTR_String lhs, rcSTR_String rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs.ReadPtr(), rhs.Length()); } -inline STR_String operator+(rcSTR_String lhs, char rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), &rhs, 1); } -inline STR_String operator+(char lhs, rcSTR_String rhs) { return STR_String(&lhs, 1, rhs.ReadPtr(), rhs.Length()); } -inline STR_String operator+(rcSTR_String lhs, const char *rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs, strlen(rhs)); } -inline STR_String operator+(const char *lhs, rcSTR_String rhs) { return STR_String(lhs, strlen(lhs), rhs.ReadPtr(), rhs.Length()); } +inline STR_String operator+(rcSTR_String lhs, char rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), &rhs, 1); } +inline STR_String operator+(char lhs, rcSTR_String rhs) { return STR_String(&lhs, 1, rhs.ReadPtr(), rhs.Length()); } +inline STR_String operator+(rcSTR_String lhs, const char *rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs, strlen(rhs)); } +inline STR_String operator+(const char *lhs, rcSTR_String rhs) { return STR_String(lhs, strlen(lhs), rhs.ReadPtr(), rhs.Length()); } #endif //__STR_STRING_H__ |