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

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Oct 15 14:19:34 CEST 2010


Revision: 53480
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53480&view=rev
Author:   fingolfin
Date:     2010-10-15 12:19:34 +0000 (Fri, 15 Oct 2010)

Log Message:
-----------
COMMON: Move XMLParser method impls to .cpp file; make skipComments non-virtual

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

Modified: scummvm/trunk/common/xmlparser.cpp
===================================================================
--- scummvm/trunk/common/xmlparser.cpp	2010-10-15 12:19:13 UTC (rev 53479)
+++ scummvm/trunk/common/xmlparser.cpp	2010-10-15 12:19:34 UTC (rev 53480)
@@ -451,5 +451,61 @@
 	return true;
 }
 
+bool XMLParser::skipSpaces() {
+	if (!isspace(_char))
+		return false;
+
+	while (_char && isspace(_char))
+		_char = _stream->readByte();
+
+	return true;
 }
 
+bool XMLParser::skipComments() {
+	if (_char == '<') {
+		_char = _stream->readByte();
+
+		if (_char != '!') {
+			_stream->seek(-1, SEEK_CUR);
+			_char = '<';
+			return false;
+		}
+
+		if (_stream->readByte() != '-' || _stream->readByte() != '-')
+			return parserError("Malformed comment syntax.");
+
+		_char = _stream->readByte();
+
+		while (_char) {
+			if (_char == '-') {
+				if (_stream->readByte() == '-') {
+
+					if (_stream->readByte() != '>')
+						return parserError("Malformed comment (double-hyphen inside comment body).");
+
+					_char = _stream->readByte();
+					return true;
+				}
+			}
+
+			_char = _stream->readByte();
+		}
+
+		return parserError("Comment has no closure.");
+	}
+
+	return false;
+}
+
+bool XMLParser::parseToken() {
+	_token.clear();
+
+	while (isValidNameChar(_char)) {
+		_token += _char;
+		_char = _stream->readByte();
+	}
+
+	return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/';
+}
+
+} // End of namespace Common

Modified: scummvm/trunk/common/xmlparser.h
===================================================================
--- scummvm/trunk/common/xmlparser.h	2010-10-15 12:19:13 UTC (rev 53479)
+++ scummvm/trunk/common/xmlparser.h	2010-10-15 12:19:34 UTC (rev 53480)
@@ -293,66 +293,23 @@
 
 	/**
 	 * Prints an error message when parsing fails and stops the parser.
-	 * Parser error always returns "false" so we can pass the return value directly
-	 * and break down the parsing.
+	 * Parser error always returns "false" so we can pass the return value
+	 * directly and break down the parsing.
 	 */
 	bool parserError(const char *errorString, ...) GCC_PRINTF(2, 3);
 
 	/**
-	 * Skips spaces/whitelines etc. Returns true if any spaces were skipped.
+	 * Skips spaces/whitelines etc.
+	 * @return true if any spaces were skipped.
 	 */
-	bool skipSpaces() {
-		if (!isspace(_char))
-			return false;
+	bool skipSpaces();
 
-		while (_char && isspace(_char))
-			_char = _stream->readByte();
-
-		return true;
-	}
-
 	/**
 	 * Skips comment blocks and comment lines.
-	 * Returns true if any comments were skipped.
-	 * Overload this if you want to disable comments on your XML syntax
-	 * or to change the commenting syntax.
+	 * @return true if any comments were skipped.
 	 */
-	virtual bool skipComments() {
-		if (_char == '<') {
-			_char = _stream->readByte();
+	bool skipComments();
 
-			if (_char != '!') {
-				_stream->seek(-1, SEEK_CUR);
-				_char = '<';
-				return false;
-			}
-
-			if (_stream->readByte() != '-' || _stream->readByte() != '-')
-				return parserError("Malformed comment syntax.");
-
-			_char = _stream->readByte();
-
-			while (_char) {
-				if (_char == '-') {
-					if (_stream->readByte() == '-') {
-
-						if (_stream->readByte() != '>')
-							return parserError("Malformed comment (double-hyphen inside comment body).");
-
-						_char = _stream->readByte();
-						return true;
-					}
-				}
-
-				_char = _stream->readByte();
-			}
-
-			return parserError("Comment has no closure.");
-		}
-
-		return false;
-	}
-
 	/**
 	 * Check if a given character can be part of a KEY or VALUE name.
 	 * Overload this if you want to support keys with strange characters
@@ -364,19 +321,9 @@
 
 	/**
 	 * Parses a the first textual token found.
-	 * There's no reason to overload this.
 	 */
-	bool parseToken() {
-		_token.clear();
+	bool parseToken();
 
-		while (isValidNameChar(_char)) {
-			_token += _char;
-			_char = _stream->readByte();
-		}
-
-		return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/';
-	}
-
 	/**
 	 * Parses the values inside an integer key.
 	 * The count parameter specifies the number of values inside
@@ -423,6 +370,6 @@
 	Common::Stack<ParserNode*> _activeKey; /** Node stack of the parsed keys */
 };
 
-}
+} // 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