aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-10-15 12:19:34 +0000
committerMax Horn2010-10-15 12:19:34 +0000
commit2fed5ff83244d6d66199239c3753e5934ed18b7b (patch)
tree5893f4e1eb068f151421f86a0f44c10eb868c11c
parent36cd5caf956c087995a62983ad09c15250f29475 (diff)
downloadscummvm-rg350-2fed5ff83244d6d66199239c3753e5934ed18b7b.tar.gz
scummvm-rg350-2fed5ff83244d6d66199239c3753e5934ed18b7b.tar.bz2
scummvm-rg350-2fed5ff83244d6d66199239c3753e5934ed18b7b.zip
COMMON: Move XMLParser method impls to .cpp file; make skipComments non-virtual
svn-id: r53480
-rw-r--r--common/xmlparser.cpp56
-rw-r--r--common/xmlparser.h71
2 files changed, 65 insertions, 62 deletions
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index 48f4f7bdf4..ab56ba3751 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -451,5 +451,61 @@ bool XMLParser::parse() {
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
diff --git a/common/xmlparser.h b/common/xmlparser.h
index 537fb01941..c8cc349a6c 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -293,65 +293,22 @@ protected:
/**
* 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;
-
- while (_char && isspace(_char))
- _char = _stream->readByte();
-
- return true;
- }
+ bool skipSpaces();
/**
* 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();
-
- 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 skipComments();
/**
* Check if a given character can be part of a KEY or VALUE name.
@@ -364,18 +321,8 @@ protected:
/**
* Parses a the first textual token found.
- * There's no reason to overload this.
*/
- bool parseToken() {
- _token.clear();
-
- while (isValidNameChar(_char)) {
- _token += _char;
- _char = _stream->readByte();
- }
-
- return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/';
- }
+ bool parseToken();
/**
* Parses the values inside an integer key.
@@ -423,6 +370,6 @@ private:
Common::Stack<ParserNode*> _activeKey; /** Node stack of the parsed keys */
};
-}
+} // End of namespace Common
#endif