diff options
Diffstat (limited to 'intern/string/STR_String.h')
-rw-r--r-- | intern/string/STR_String.h | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/intern/string/STR_String.h b/intern/string/STR_String.h index 98de5be9647..6e9f6007e0b 100644 --- a/intern/string/STR_String.h +++ b/intern/string/STR_String.h @@ -66,8 +66,8 @@ typedef const STR_String& rcSTR_String; typedef unsigned char byte; /** - * Smart String Value class. Is used by parser when an expression tree is build containing string. -*/ + * Smart String Value class. Is used by parser when an expression tree is build containing string. + */ class STR_String { @@ -85,16 +85,16 @@ public: explicit STR_String(dword val); explicit STR_String(float val); explicit STR_String(double val); - inline ~STR_String() { delete[] pData; } + inline ~STR_String() { delete[] this->m_data; } // Operations STR_String& Format(const char *fmt, ...); // Set formatted text to string STR_String& FormatAdd(const char *fmt, ...); // Add formatted text to string - inline void Clear() { Len = pData[0] = 0; } + inline void Clear() { this->m_len = this->m_data[0] = 0; } inline const STR_String & Reverse() { - for (int i1 = 0, i2 = Len - 1; i1 < i2; i1++, i2--) { - std::swap(pData[i1], pData[i2]); + for (int i1 = 0, i2 = this->m_len - 1; i1 < i2; i1++, i2--) { + std::swap(this->m_data[i1], this->m_data[i2]); } return *this; } @@ -102,28 +102,28 @@ public: // Properties bool IsUpper() const; bool IsLower() const; - inline bool IsEmpty() const { return Len == 0; } - inline int Length() const { return Len; } + inline bool IsEmpty() const { return this->m_len == 0; } + inline int Length() const { return this->m_len; } // Data access - inline STR_String& SetLength(int len) { AllocBuffer(len, true); Len=len; pData[len]=0; return *this; } - inline char GetAt(int pos) const { assertd(pos<Len); return pData[pos]; } - inline void SetAt(int pos, char c) { assertd(pos<Len); pData[pos]=c; } + inline STR_String& SetLength(int len) { AllocBuffer(len, true); this->m_len = len; this->m_data[len] = 0; return *this; } + inline char GetAt(int pos) const { assertd(pos<this->m_len); return this->m_data[pos]; } + inline void SetAt(int pos, char c) { assertd(pos<this->m_len); this->m_data[pos] = c; } inline void SetAt(int pos, rcSTR_String str); inline void SetAt(int pos, int num, rcSTR_String str); void Replace(int pos, rcSTR_String str); 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 < this->m_len ? num:this->m_len ); return STR_String(this->m_data, num); } + inline STR_String Right(int num) const { num = (num < this->m_len ? num:this->m_len ); return STR_String(this->m_data + this->m_len - num, num); } + inline STR_String Mid(int pos, int num = INT_MAX) const { pos = (pos < this->m_len ? pos:this->m_len ); num = (num < (this->m_len - pos) ? num : (this->m_len - pos)); return STR_String(this->m_data + 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); } + 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; @@ -148,12 +148,12 @@ 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 this->m_data; } + inline operator const char *() const { return this->m_data; } + inline char *Ptr() { return this->m_data; } + inline const char *ReadPtr() const { return this->m_data; } + inline float ToFloat() const { float x=(float)(atof(this->m_data)); return x; } + inline int ToInt() const { return atoi(this->m_data); } // Operators inline rcSTR_String operator=(const byte *rhs) { return Copy((const char *)rhs, strlen((const char *)rhs)); } @@ -198,9 +198,9 @@ 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 - int Len; // Data length - int Max; // Space in data buffer + char *m_data; // -> STR_String data + int m_len; //z Data length + int m_max; // Space in data buffer #ifdef WITH_CXX_GUARDEDALLOC |