summaryrefslogtreecommitdiff
path: root/server/src/templateparser.cc
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/templateparser.cc')
-rw-r--r--server/src/templateparser.cc38
1 files changed, 36 insertions, 2 deletions
diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc
index d35811a..04650ca 100644
--- a/server/src/templateparser.cc
+++ b/server/src/templateparser.cc
@@ -65,6 +65,7 @@ TemplateParser::TemplateParser(std::string course)
t = NULL;
current_macro = NULL;
current_map = NULL;
+ current_luaprogram = NULL;
file = XML"/";
file.append(course);
@@ -85,11 +86,14 @@ TemplateParser::~TemplateParser()
void TemplateParser::characterData(std::string &data)
{
if(state == MAP) {
- // assert(current_macro->maps.size()); // No maps present!
- // current_macro->maps.back().attributes["lua"].append(data);
assert(current_map); // No map present!
current_map->attributes["lua"].append(data);
}
+
+ if(state == LUAPROGRAM) {
+ assert(current_luaprogram); // No lua program present!
+ current_luaprogram->attributes["lua"].append(data);
+ }
}
void TemplateParser::startTag(std::string name, std::map< std::string, std::string> attributes)
@@ -183,6 +187,31 @@ void TemplateParser::startTag(std::string name, std::map< std::string, std::stri
return;
}
+ // Enable LUA Program parsing
+ if(name == "luaprograms") {
+ if(state != MACRO) error("luaprograms found outside macro.");
+ state = LUAPROGRAMS;
+
+ assert(current_macro); // No macro is currently available, cannot create maps!
+
+ return;
+ }
+
+ // Create Query
+ if(name == "luaprogram") {
+ if(state != LUAPROGRAMS) error("lua program found outside maps.");
+ state = LUAPROGRAM;
+
+ assert(current_macro); // No macro is currently available, cannot create map!
+
+ LUAProgram l;
+ l.attributes = attributes;
+ current_macro->luaprograms.push_back(l);
+ current_luaprogram = &(current_macro->luaprograms.back());
+
+ return;
+ }
+
// Enable widget parsing
if(name == "window") {
@@ -243,6 +272,11 @@ void TemplateParser::endTag(std::string name)
current_map = NULL;
state = MAPS;
}
+ if(name == "luaprograms") state = MACRO;
+ if(name == "luaprogram") {
+ current_luaprogram = NULL;
+ state = LUAPROGRAMS;
+ }
if(name == "window") state = MACRO;
if(state == WINDOW) {