mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-21 19:51:49 +00:00
Small tweaks for the String class
svn-id: r14293
This commit is contained in:
parent
9dfee6c315
commit
0605918ab4
@ -108,6 +108,14 @@ String &String::operator =(const String &str) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& String::operator =(char c) {
|
||||
ensureCapacity(1, false);
|
||||
_len = 1;
|
||||
_str[0] = c;
|
||||
_str[1] = 0;
|
||||
return *this;
|
||||
}
|
||||
|
||||
String &String::operator +=(const char *str) {
|
||||
int len = strlen(str);
|
||||
if (len > 0) {
|
||||
@ -139,10 +147,6 @@ String &String::operator += (char c) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
char String::lastChar() const {
|
||||
return (_len > 0) ? _str[_len-1] : 0;
|
||||
}
|
||||
|
||||
void String::deleteLastChar() {
|
||||
if (_len > 0) {
|
||||
ensureCapacity(_len - 1, true);
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
uint size() const { return _len; }
|
||||
|
||||
bool isEmpty() const { return (_len == 0); }
|
||||
char lastChar() const { return (_len > 0) ? _str[_len-1] : 0; }
|
||||
};
|
||||
|
||||
class String : public ConstString {
|
||||
@ -94,6 +95,7 @@ public:
|
||||
// An alternative would be to add private clone() and cloneMutable methods that
|
||||
// would do the right thing.
|
||||
String &operator =(const String &str);
|
||||
String &operator =(char c);
|
||||
String &operator +=(const char *str);
|
||||
String &operator +=(const String &str);
|
||||
String &operator +=(char c);
|
||||
@ -108,7 +110,6 @@ public:
|
||||
return _str[idx];
|
||||
}
|
||||
|
||||
char lastChar() const;
|
||||
void deleteLastChar();
|
||||
void deleteChar(int p);
|
||||
void clear();
|
||||
|
Loading…
x
Reference in New Issue
Block a user