[Scummvm-cvs-logs] SF.net SVN: scummvm: [27051] scummvm/trunk/common
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sat Jun 2 14:42:41 CEST 2007
Revision: 27051
http://scummvm.svn.sourceforge.net/scummvm/?rev=27051&view=rev
Author: fingolfin
Date: 2007-06-02 05:42:40 -0700 (Sat, 02 Jun 2007)
Log Message:
-----------
Enhanced Common::String by adding char constructor and operator+ for chars
Modified Paths:
--------------
scummvm/trunk/common/str.cpp
scummvm/trunk/common/str.h
Modified: scummvm/trunk/common/str.cpp
===================================================================
--- scummvm/trunk/common/str.cpp 2007-06-02 12:01:09 UTC (rev 27050)
+++ scummvm/trunk/common/str.cpp 2007-06-02 12:42:40 UTC (rev 27051)
@@ -86,7 +86,16 @@
}
assert(_str != 0);
}
+
+String::String(char c)
+: _len(0), _str(_storage) {
+ _storage[0] = c;
+ _storage[1] = 0;
+
+ _len = (c == 0) ? 0 : 1;
+}
+
String::~String() {
decRefCount(_extern._refCount);
}
@@ -437,6 +446,18 @@
return temp;
}
+String operator +(char x, const String &y) {
+ String temp(x);
+ temp += y;
+ return temp;
+}
+
+String operator +(const String &x, char y) {
+ String temp(x);
+ temp += y;
+ return temp;
+}
+
char *ltrim(char *t) {
while (isspace(*t))
t++;
Modified: scummvm/trunk/common/str.h
===================================================================
--- scummvm/trunk/common/str.h 2007-06-02 12:01:09 UTC (rev 27050)
+++ scummvm/trunk/common/str.h 2007-06-02 12:42:40 UTC (rev 27051)
@@ -99,6 +99,7 @@
String() : _len(0), _str(_storage) { _storage[0] = 0; }
String(const char *str, uint32 len = 0);
String(const String &str);
+ String(char c);
virtual ~String();
String &operator =(const char *str);
@@ -187,9 +188,13 @@
// Append two strings to form a new (temp) string
String operator +(const String &x, const String &y);
+
String operator +(const char *x, const String &y);
String operator +(const String &x, const char *y);
+String operator +(const String &x, char y);
+String operator +(char x, const String &y);
+
// Some useful additional comparision operators for Strings
bool operator == (const char *x, const String &y);
bool operator != (const char *x, const String &y);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list