aboutsummaryrefslogtreecommitdiff
path: root/gui/ThemeParser.cpp
diff options
context:
space:
mode:
authorVicent Marti2008-06-12 19:06:37 +0000
committerVicent Marti2008-06-12 19:06:37 +0000
commit7a9a74691fef580467d93c713c03be613a6d289b (patch)
tree9badb25845ee23bcff69dc4d781b068cfa7ef877 /gui/ThemeParser.cpp
parent5dd77ea8203c7d63848b0423fbc3c9bfbb8987b5 (diff)
downloadscummvm-rg350-7a9a74691fef580467d93c713c03be613a6d289b.tar.gz
scummvm-rg350-7a9a74691fef580467d93c713c03be613a6d289b.tar.bz2
scummvm-rg350-7a9a74691fef580467d93c713c03be613a6d289b.zip
Parser skeleton
Expanded drawing interface svn-id: r32678
Diffstat (limited to 'gui/ThemeParser.cpp')
-rw-r--r--gui/ThemeParser.cpp111
1 files changed, 111 insertions, 0 deletions
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
new file mode 100644
index 0000000000..26745ac5a6
--- /dev/null
+++ b/gui/ThemeParser.cpp
@@ -0,0 +1,111 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/util.h"
+#include "common/system.h"
+#include "common/events.h"
+
+#include "gui/ThemeParser.h"
+
+/**
+
+<drawdata = "background_default" cache = true>
+ <draw func = "roundedsq" fill = "gradient" gradient_start = "255, 255, 128" gradient_end = "128, 128, 128" size = "auto">
+ <draw func = "roundedsq" fill = "none" color = "0, 0, 0" size = "auto">
+</drawdata>
+
+*/
+
+namespace GUI {
+
+inline bool isValidNameChar(char c) {
+ return !isspace(c) && c != '/' && c != '*' && c != '\\' &&
+ c != '|' && c != '"' && c != '\'' && c != ',' &&
+ c != '<' && c != '>' && c != '=';
+}
+
+void ThemeParser::parserError(const char *error_string) {
+ _state = kParserError;
+}
+
+bool ThemeParser::parseDrawData() {
+
+ _state = kParserNeedKey;
+
+ while (_text[_pos++]) {
+
+ while (isspace(_text[_pos]))
+ _pos++;
+
+ // comment handling: skip everything between /* and */
+ if (_text[_pos] == '/') {
+ if (_text[++_pos] != '*') {
+ parserError("Malformed comment string.");
+ return false;
+ }
+
+ _pos++;
+
+ while (_text[_pos] != '*' && _text[_pos + 1] != '/')
+ _pos++;
+ }
+
+ switch (_state) {
+ case kParserNeedKey:
+ if (_text[_pos] != '<') {
+ parserError("Expecting key start.");
+ return false;
+ }
+
+ _state = kParserKeyNeedName;
+ break;
+
+ case kParserKeyNeedName:
+ _token.clear();
+ while (isValidNameChar(_text[_pos]))
+ _token += _text[_pos++];
+
+ if (!isspace(_text[_pos])) {
+ parserError("Invalid character in token name.");
+ return false;
+ }
+
+ _state = kParserKeyNeedToken;
+ break;
+
+ case kParserKeyNeedToken:
+ _token.clear();
+ break;
+
+ default:
+ return false;
+ }
+ }
+
+ return true;
+}
+
+}
+