[Scummvm-cvs-logs] CVS: scummvm/common str.cpp,1.31,1.32 str.h,1.22,1.23
Max Horn
fingolfin at users.sourceforge.net
Wed Jul 21 07:21:04 CEST 2004
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31919
Modified Files:
str.cpp str.h
Log Message:
Small tweaks for the String class
Index: str.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/str.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- str.cpp 27 Jun 2004 23:58:41 -0000 1.31
+++ str.cpp 21 Jul 2004 14:20:37 -0000 1.32
@@ -108,6 +108,14 @@
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 @@
return *this;
}
-char String::lastChar() const {
- return (_len > 0) ? _str[_len-1] : 0;
-}
-
void String::deleteLastChar() {
if (_len > 0) {
ensureCapacity(_len - 1, true);
Index: str.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/str.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- str.h 27 Jun 2004 23:58:41 -0000 1.22
+++ str.h 21 Jul 2004 14:20:37 -0000 1.23
@@ -70,6 +70,7 @@
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 @@
// 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 @@
return _str[idx];
}
- char lastChar() const;
void deleteLastChar();
void deleteChar(int p);
void clear();
More information about the Scummvm-git-logs
mailing list