diff options
author | deva <deva> | 2008-06-03 08:13:20 +0000 |
---|---|---|
committer | deva <deva> | 2008-06-03 08:13:20 +0000 |
commit | bb3fad646f94739a876869464a484c99795bce61 (patch) | |
tree | 1894d6b43055b654150bf9e56cc1baefce34dcad /server/src/templateparser.cc | |
parent | 13b9aa0c0ab5a7b66c08f7a7e02c193530640ed3 (diff) |
Added support for lua validator programs.
Diffstat (limited to 'server/src/templateparser.cc')
-rw-r--r-- | server/src/templateparser.cc | 38 |
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) { |