summaryrefslogtreecommitdiff
path: root/utils/themeeditor/parser/skin_parser.h
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-17 05:37:01 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-17 05:37:01 +0000
commitca564287ee3f48945d45c7d92be7a83452f53745 (patch)
treed6e502bb604f925240a742b3bac2c813a98c447b /utils/themeeditor/parser/skin_parser.h
parentba07b2055c7eb8f2add96f55cb52b40b9ccb3d63 (diff)
downloadrockbox-ca564287ee3f48945d45c7d92be7a83452f53745.zip
rockbox-ca564287ee3f48945d45c7d92be7a83452f53745.tar.gz
rockbox-ca564287ee3f48945d45c7d92be7a83452f53745.tar.bz2
rockbox-ca564287ee3f48945d45c7d92be7a83452f53745.tar.xz
Theme Editor: Moved source files into subdirectories
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26876 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/parser/skin_parser.h')
-rw-r--r--utils/themeeditor/parser/skin_parser.h138
1 files changed, 138 insertions, 0 deletions
diff --git a/utils/themeeditor/parser/skin_parser.h b/utils/themeeditor/parser/skin_parser.h
new file mode 100644
index 0000000..1fc4a7a
--- /dev/null
+++ b/utils/themeeditor/parser/skin_parser.h
@@ -0,0 +1,138 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2010 Robert Bieber
+ *
+ * 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 software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#ifndef GENERIC_PARSER_H
+#define GENERIC_PARSER_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#include <stdlib.h>
+
+/********************************************************************
+ ****** Data Structures *********************************************
+ *******************************************************************/
+
+/* Possible types of element in a WPS file */
+enum skin_element_type
+{
+ UNKNOWN = -1,
+ VIEWPORT,
+ LINE,
+ SUBLINES,
+ CONDITIONAL,
+ TAG,
+ TEXT,
+ COMMENT,
+};
+
+enum skin_errorcode
+{
+ MEMORY_LIMIT_EXCEEDED,
+ NEWLINE_EXPECTED,
+ ILLEGAL_TAG,
+ ARGLIST_EXPECTED,
+ TOO_MANY_ARGS,
+ DEFAULT_NOT_ALLOWED,
+ UNEXPECTED_NEWLINE,
+ INSUFFICIENT_ARGS,
+ INT_EXPECTED,
+ SEPERATOR_EXPECTED,
+ CLOSE_EXPECTED,
+ MULTILINE_EXPECTED
+};
+
+/* Holds a tag parameter, either numeric or text */
+struct skin_tag_parameter
+{
+ enum
+ {
+ NUMERIC,
+ STRING,
+ CODE,
+ DEFAULT
+ } type;
+
+ union
+ {
+ int numeric;
+ char* text;
+ struct skin_element* code;
+ } data;
+
+ char type_code;
+
+};
+
+/* Defines an element of a SKIN file */
+struct skin_element
+{
+ /* Defines what type of element it is */
+ enum skin_element_type type;
+
+ /* The line on which it's defined in the source file */
+ int line;
+
+ /* Placeholder for element data
+ * TEXT and COMMENT uses it for the text string
+ * TAG, VIEWPORT, LINE, etc may use it for post parse extra storage
+ */
+ void* data;
+
+ /* The tag or conditional name */
+ struct tag_info *tag;
+
+ /* Pointer to and size of an array of parameters */
+ int params_count;
+ struct skin_tag_parameter* params;
+
+ /* Pointer to and size of an array of children */
+ int children_count;
+ struct skin_element** children;
+
+ /* Link to the next element */
+ struct skin_element* next;
+};
+
+/***********************************************************************
+ ***** Functions *******************************************************
+ **********************************************************************/
+
+/* Parses a WPS document and returns a list of skin_element
+ structures. */
+struct skin_element* skin_parse(const char* document);
+
+/* Memory management functions */
+char *skin_alloc(size_t size);
+struct skin_element* skin_alloc_element();
+struct skin_element** skin_alloc_children(int count);
+struct skin_tag_parameter* skin_alloc_params(int count);
+char* skin_alloc_string(int length);
+
+void skin_free_tree(struct skin_element* root);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* GENERIC_PARSER_H */