From bb3fad646f94739a876869464a484c99795bce61 Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 3 Jun 2008 08:13:20 +0000 Subject: Added support for lua validator programs. --- server/src/templateparser.cc | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'server/src/templateparser.cc') 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) { -- cgit v1.2.3