[Scummvm-cvs-logs] SF.net SVN: scummvm:[47744] scummvm/trunk/common

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Sun Jan 31 11:22:10 CET 2010


Revision: 47744
          http://scummvm.svn.sourceforge.net/scummvm/?rev=47744&view=rev
Author:   lordhoto
Date:     2010-01-31 10:22:09 +0000 (Sun, 31 Jan 2010)

Log Message:
-----------
Slight formatting fixes to comply to our coding guidelines.

Modified Paths:
--------------
    scummvm/trunk/common/str.cpp
    scummvm/trunk/common/str.h

Modified: scummvm/trunk/common/str.cpp
===================================================================
--- scummvm/trunk/common/str.cpp	2010-01-31 10:02:38 UTC (rev 47743)
+++ scummvm/trunk/common/str.cpp	2010-01-31 10:22:09 UTC (rev 47744)
@@ -37,7 +37,7 @@
 
 namespace Common {
 
-MemoryPool *g_refCountPool = 0;	// FIXME: This is never freed right now
+MemoryPool *g_refCountPool = 0; // FIXME: This is never freed right now
 
 static uint32 computeCapacity(uint32 len) {
 	// By default, for the capacity we use the next multiple of 32
@@ -84,7 +84,7 @@
 }
 
 String::String(const String &str)
- : _size(str._size) {
+    : _size(str._size) {
 	if (str.isStorageIntern()) {
 		// String in internal storage: just copy it
 		memcpy(_storage, str._storage, _builtinCapacity);
@@ -100,7 +100,7 @@
 }
 
 String::String(char c)
-: _size(0), _str(_storage) {
+    : _size(0), _str(_storage) {
 
 	_storage[0] = c;
 	_storage[1] = 0;
@@ -219,7 +219,7 @@
 	}
 }
 
-String& String::operator  =(const char *str) {
+String &String::operator=(const char *str) {
 	uint32 len = strlen(str);
 	ensureCapacity(len, false);
 	_size = len;
@@ -227,7 +227,7 @@
 	return *this;
 }
 
-String &String::operator  =(const String &str) {
+String &String::operator=(const String &str) {
 	if (&str == this)
 		return *this;
 
@@ -249,7 +249,7 @@
 	return *this;
 }
 
-String& String::operator  =(char c) {
+String &String::operator=(char c) {
 	decRefCount(_extern._refCount);
 	_str = _storage;
 	_size = 1;
@@ -258,7 +258,7 @@
 	return *this;
 }
 
-String &String::operator +=(const char *str) {
+String &String::operator+=(const char *str) {
 	if (_str <= str && str <= _str + _size)
 		return operator+=(Common::String(str));
 
@@ -272,7 +272,7 @@
 	return *this;
 }
 
-String &String::operator +=(const String &str) {
+String &String::operator+=(const String &str) {
 	if (&str == this)
 		return operator+=(Common::String(str));
 
@@ -286,7 +286,7 @@
 	return *this;
 }
 
-String &String::operator +=(char c) {
+String &String::operator+=(char c) {
 	ensureCapacity(_size + 1, true);
 
 	_str[_size++] = c;
@@ -363,7 +363,7 @@
 
 	makeUnique();
 	while (p++ < _size)
-		_str[p-1] = _str[p];
+		_str[p - 1] = _str[p];
 	_size--;
 }
 
@@ -388,7 +388,7 @@
 	ensureCapacity(_size + 1, true);
 	_size++;
 	for (uint32 i = _size; i > p; --i)
-		_str[i] = _str[i-1];
+		_str[i] = _str[i - 1];
 	_str[p] = c;
 }
 
@@ -411,8 +411,8 @@
 	makeUnique();
 
 	// Trim trailing whitespace
-	while (_size >= 1 && isspace(_str[_size-1]))
-		_size--;
+	while (_size >= 1 && isspace(_str[_size - 1]))
+		--_size;
 	_str[_size] = 0;
 
 	// Trim leading whitespace
@@ -449,7 +449,7 @@
 		int size = _builtinCapacity;
 		do {
 			size *= 2;
-			output.ensureCapacity(size-1, false);
+			output.ensureCapacity(size - 1, false);
 			assert(!output.isStorageIntern());
 			size = output._extern._capacity;
 
@@ -477,16 +477,16 @@
 
 #pragma mark -
 
-bool String::operator ==(const String &x) const {
+bool String::operator==(const String &x) const {
 	return equals(x);
 }
 
-bool String::operator ==(const char *x) const {
+bool String::operator==(const char *x) const {
 	assert(x != 0);
 	return equals(x);
 }
 
-bool String::operator !=(const String &x) const {
+bool String::operator!=(const String &x) const {
 	return !equals(x);
 }
 
@@ -495,29 +495,29 @@
 	return !equals(x);
 }
 
-bool String::operator < (const String &x) const {
+bool String::operator<(const String &x) const {
 	return compareTo(x) < 0;
 }
 
-bool String::operator <= (const String &x) const {
+bool String::operator<=(const String &x) const {
 	return compareTo(x) <= 0;
 }
 
-bool String::operator > (const String &x) const {
+bool String::operator>(const String &x) const {
 	return compareTo(x) > 0;
 }
 
-bool String::operator >= (const String &x) const {
+bool String::operator>=(const String &x) const {
 	return compareTo(x) >= 0;
 }
 
 #pragma mark -
 
-bool operator == (const char* y, const String &x) {
+bool operator==(const char* y, const String &x) {
 	return (x == y);
 }
 
-bool operator != (const char* y, const String &x) {
+bool operator!=(const char* y, const String &x) {
 	return x != y;
 }
 
@@ -561,31 +561,31 @@
 
 #pragma mark -
 
-String operator +(const String &x, const String &y) {
+String operator+(const String &x, const String &y) {
 	String temp(x);
 	temp += y;
 	return temp;
 }
 
-String operator +(const char *x, const String &y) {
+String operator+(const char *x, const String &y) {
 	String temp(x);
 	temp += y;
 	return temp;
 }
 
-String operator +(const String &x, const char *y) {
+String operator+(const String &x, const char *y) {
 	String temp(x);
 	temp += y;
 	return temp;
 }
 
-String operator +(char x, const String &y) {
+String operator+(char x, const String &y) {
 	String temp(x);
 	temp += y;
 	return temp;
 }
 
-String operator +(const String &x, char y) {
+String operator+(const String &x, char y) {
 	String temp(x);
 	temp += y;
 	return temp;

Modified: scummvm/trunk/common/str.h
===================================================================
--- scummvm/trunk/common/str.h	2010-01-31 10:02:38 UTC (rev 47743)
+++ scummvm/trunk/common/str.h	2010-01-31 10:22:09 UTC (rev 47744)
@@ -54,20 +54,20 @@
 	 * than 8 makes no sense, since that's the size of member _extern
 	 * (on 32 bit machines; 12 bytes on systems with 64bit pointers).
 	 */
-	static const uint32 _builtinCapacity = 32 - sizeof(uint32) - sizeof(char*);
+	static const uint32 _builtinCapacity = 32 - sizeof(uint32) - sizeof(char *);
 
 	/**
 	 * Length of the string. Stored to avoid having to call strlen
 	 * a lot. Yes, we limit ourselves to strings shorter than 4GB --
 	 * on purpose :-).
 	 */
-	uint32		_size;
+	uint32 _size;
 
 	/**
 	 * Pointer to the actual string storage. Either points to _storage,
 	 * or to a block allocated on the heap via malloc.
 	 */
-	char		*_str;
+	char  *_str;
 
 
 	union {
@@ -81,7 +81,7 @@
 		 */
 		struct {
 			mutable int *_refCount;
-			uint32		_capacity;
+			uint32       _capacity;
 		} _extern;
 	};
 
@@ -110,32 +110,32 @@
 
 	~String();
 
-	String &operator  =(const char *str);
-	String &operator  =(const String &str);
-	String &operator  =(char c);
-	String &operator +=(const char *str);
-	String &operator +=(const String &str);
-	String &operator +=(char c);
+	String &operator=(const char *str);
+	String &operator=(const String &str);
+	String &operator=(char c);
+	String &operator+=(const char *str);
+	String &operator+=(const String &str);
+	String &operator+=(char c);
 
-	bool operator ==(const String &x) const;
-	bool operator ==(const char *x) const;
-	bool operator !=(const String &x) const;
-	bool operator !=(const char *x) const;
+	bool operator==(const String &x) const;
+	bool operator==(const char *x) const;
+	bool operator!=(const String &x) const;
+	bool operator!=(const char *x) const;
 
-	bool operator <(const String &x) const;
-	bool operator <=(const String &x) const;
-	bool operator >(const String &x) const;
-	bool operator >=(const String &x) const;
+	bool operator<(const String &x) const;
+	bool operator<=(const String &x) const;
+	bool operator>(const String &x) const;
+	bool operator>=(const String &x) const;
 
 	bool equals(const String &x) const;
 	bool equalsIgnoreCase(const String &x) const;
-	int compareTo(const String &x) const;	// strcmp clone
-	int compareToIgnoreCase(const String &x) const;	// stricmp clone
+	int compareTo(const String &x) const;           // strcmp clone
+	int compareToIgnoreCase(const String &x) const; // stricmp clone
 
 	bool equals(const char *x) const;
 	bool equalsIgnoreCase(const char *x) const;
-	int compareTo(const char *x) const;	// strcmp clone
-	int compareToIgnoreCase(const char *x) const;	// stricmp clone
+	int compareTo(const char *x) const;             // strcmp clone
+	int compareToIgnoreCase(const char *x) const;   // stricmp clone
 
 	bool hasSuffix(const String &x) const;
 	bool hasSuffix(const char *x) const;
@@ -152,15 +152,15 @@
 	 * Taken from exult/files/listfiles.cc
 	 *
 	 * Token meaning:
-	 *		"*": any character, any amount of times.
-	 *		"?": any character, only once.
+	 *      "*": any character, any amount of times.
+	 *      "?": any character, only once.
 	 *
 	 * Example strings/patterns:
-	 *		String: monkey.s01	 Pattern: monkey.s??	=> true
-	 *		String: monkey.s101	 Pattern: monkey.s??	=> false
-	 *		String: monkey.s99	 Pattern: monkey.s?1	=> false
-	 *		String: monkey.s101	 Pattern: monkey.s*		=> true
-	 *		String: monkey.s99	 Pattern: monkey.s*1	=> false
+	 *      String: monkey.s01   Pattern: monkey.s??    => true
+	 *      String: monkey.s101  Pattern: monkey.s??    => false
+	 *      String: monkey.s99   Pattern: monkey.s?1    => false
+	 *      String: monkey.s101  Pattern: monkey.s*     => true
+	 *      String: monkey.s99   Pattern: monkey.s*1    => false
 	 *
 	 * @param str Text to be matched against the given pattern.
 	 * @param pat Glob pattern.
@@ -173,11 +173,11 @@
 	bool matchString(const String &pat, bool ignoreCase = false, bool pathMode = false) const;
 
 
-	inline const char *c_str() const		{ return _str; }
-	inline uint size() const				{ return _size; }
+	inline const char *c_str() const { return _str; }
+	inline uint size() const         { return _size; }
 
-	inline bool empty() const	{ return (_size == 0); }
-	char lastChar() const	{ return (_size > 0) ? _str[_size-1] : 0; }
+	inline bool empty() const { return (_size == 0); }
+	char lastChar() const     { return (_size > 0) ? _str[_size - 1] : 0; }
 
 	char operator[](int idx) const {
 		assert(_str && idx >= 0 && idx < (int)_size);
@@ -222,19 +222,19 @@
 	typedef char *        iterator;
 	typedef const char *  const_iterator;
 
-	iterator		begin() {
+	iterator begin() {
 		return _str;
 	}
 
-	iterator		end() {
+	iterator end() {
 		return begin() + size();
 	}
 
-	const_iterator	begin() const {
+	const_iterator begin() const {
 		return _str;
 	}
 
-	const_iterator	end() const {
+	const_iterator end() const {
 		return begin() + size();
 	}
 
@@ -247,17 +247,17 @@
 };
 
 // Append two strings to form a new (temp) string
-String operator +(const String &x, const String &y);
+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 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);
+String operator+(const String &x, char y);
+String operator+(char x, const String &y);
 
 // Some useful additional comparison operators for Strings
-bool operator == (const char *x, const String &y);
-bool operator != (const char *x, const String &y);
+bool operator==(const char *x, const String &y);
+bool operator!=(const char *x, const String &y);
 
 // Utility functions to remove leading and trailing whitespaces
 extern char *ltrim(char *t);
@@ -269,9 +269,9 @@
  * Returns the last component of a given path.
  *
  * Examples:
- *			/foo/bar.txt would return 'bar.txt'
- *			/foo/bar/    would return 'bar'
- *			/foo/./bar//    would return 'bar'
+ *          /foo/bar.txt    would return 'bar.txt'
+ *          /foo/bar/       would return 'bar'
+ *          /foo/./bar//    would return 'bar'
  *
  * @param path the path of which we want to know the last component
  * @param sep character used to separate path components
@@ -287,9 +287,9 @@
  *
  * @todo remove double dot components:  /foo/baz/../bar -> /foo/bar
  *
- * @param path	the path to normalize
- * @param sep	the separator token (usually '/' on Unix-style systems, or '\\' on Windows based stuff)
- * @return	the normalized path
+ * @param path  the path to normalize
+ * @param sep   the separator token (usually '/' on Unix-style systems, or '\\' on Windows based stuff)
+ * @return      the normalized path
  */
 Common::String normalizePath(const Common::String &path, const char sep);
 
@@ -299,15 +299,15 @@
  * Taken from exult/files/listfiles.cc
  *
  * Token meaning:
- *		"*": any character, any amount of times.
- *		"?": any character, only once.
+ *      "*": any character, any amount of times.
+ *      "?": any character, only once.
  *
  * Example strings/patterns:
- *		String: monkey.s01	 Pattern: monkey.s??	=> true
- *		String: monkey.s101	 Pattern: monkey.s??	=> false
- *		String: monkey.s99	 Pattern: monkey.s?1	=> false
- *		String: monkey.s101	 Pattern: monkey.s*		=> true
- *		String: monkey.s99	 Pattern: monkey.s*1	=> false
+ *      String: monkey.s01   Pattern: monkey.s??    => true
+ *      String: monkey.s101  Pattern: monkey.s??    => false
+ *      String: monkey.s99   Pattern: monkey.s?1    => false
+ *      String: monkey.s101  Pattern: monkey.s*     => true
+ *      String: monkey.s99   Pattern: monkey.s*1    => false
  *
  * @param str Text to be matched against the given pattern.
  * @param pat Glob pattern.
@@ -321,6 +321,6 @@
 
 typedef Array<String> StringList;
 
-}	// End of namespace Common
+} // End of namespace Common
 
 #endif


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