|
@@ -64,15 +64,17 @@ public: |
|
|
|
|
|
|
|
|
inline char &operator [](int n) |
|
|
inline char &operator [](int n) |
|
|
{ |
|
|
{ |
|
|
|
|
|
/* Allow n == Count() because we might have reasonable reasons |
|
|
|
|
|
* to access that hidden null character. */ |
|
|
ASSERT(n >= 0); |
|
|
ASSERT(n >= 0); |
|
|
ASSERT(n < Count() || (!n && !Count())); |
|
|
|
|
|
|
|
|
ASSERT(n <= Count()); |
|
|
return ((Super &)*this)[n]; |
|
|
return ((Super &)*this)[n]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
inline char const &operator [](int n) const |
|
|
inline char const &operator [](int n) const |
|
|
{ |
|
|
{ |
|
|
ASSERT(n >= 0); |
|
|
ASSERT(n >= 0); |
|
|
ASSERT(n < Count() || (!n && !Count())); |
|
|
|
|
|
|
|
|
ASSERT(n <= Count()); |
|
|
return ((Super const &)*this)[n]; |
|
|
return ((Super const &)*this)[n]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -95,11 +97,19 @@ public: |
|
|
|
|
|
|
|
|
void Resize(int count) |
|
|
void Resize(int count) |
|
|
{ |
|
|
{ |
|
|
ASSERT(count >= 0, "count = %d", count); |
|
|
|
|
|
|
|
|
ASSERT(count >= 0); |
|
|
((Super &)*this).Resize(count + 1); |
|
|
((Super &)*this).Resize(count + 1); |
|
|
((Super &)*this).Last() = '\0'; |
|
|
((Super &)*this).Last() = '\0'; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String Sub(int start, int count) const |
|
|
|
|
|
{ |
|
|
|
|
|
ASSERT(start >= 0); |
|
|
|
|
|
ASSERT(count >= 0); |
|
|
|
|
|
ASSERT(start + count <= Count()); |
|
|
|
|
|
return String(&(*this)[start], count); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
inline String operator +(String const &s) const |
|
|
inline String operator +(String const &s) const |
|
|
{ |
|
|
{ |
|
|
String ret(*this); |
|
|
String ret(*this); |
|
|