diff options
Diffstat (limited to 'server/src/templateparser.cc')
-rw-r--r-- | server/src/templateparser.cc | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index 8ddf6d2..62be9c7 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -63,7 +63,7 @@ TemplateParser::TemplateParser(std::string templatefile) t = new Template(); current_macro = NULL; - file = templatefile;//Conf::xml_basedir + "/templates/" + course + ".xml"; + file = templatefile; PRACRO_DEBUG(macro, "Using template file: %s\n", file.c_str()); @@ -84,20 +84,20 @@ void TemplateParser::characterData(std::string &data) void TemplateParser::startTag(std::string name, std::map< std::string, std::string> attributes) { // Enable macro parsing - if(name == "course") { - if(state != UNDEFINED) error("course found not a root node."); - state = COURSE; + if(name == "template") { + if(state != UNDEFINED) error("Template found not a root node."); + state = TEMPLATE; - assert(t); // A Template has not yet been allocated, cannot create course! + assert(t); // A Template has not yet been allocated, cannot create template! - t->course.attributes = attributes; + t->attributes = attributes; return; } // Create macro and enable parsing of queries, maps and window if(name == "macro" || name == "header") { - if(state != COURSE) error("macro found outside course."); + if(state != TEMPLATE) error("macro found outside template."); state = MACRO; assert(t); // A Template has not yet been allocated, cannot create macro! @@ -105,8 +105,8 @@ void TemplateParser::startTag(std::string name, std::map< std::string, std::stri Macro m; m.attributes = attributes; m.isHeader = name == "header"; - t->course.macros.push_back(m); - current_macro = &(t->course.macros.back()); + t->macros.push_back(m); + current_macro = &(t->macros.back()); return; } @@ -116,10 +116,10 @@ void TemplateParser::startTag(std::string name, std::map< std::string, std::stri void TemplateParser::endTag(std::string name) { - if(name == "course") state = UNDEFINED; + if(name == "template") state = UNDEFINED; if(name == "macro" || name == "header") { current_macro = NULL; - state = COURSE; + state = TEMPLATE; } } @@ -173,16 +173,13 @@ int main() Template *t = parser.getTemplate(); - printf("[Template]:\n"); - print_attributes("\t-", t->attributes); - - printf("\t[Course]:\n"); - print_attributes("\t\t-", t->course.attributes); + printf("\t[Template]:\n"); + print_attributes("\t\t-", t->attributes); printf("\t\t[Macros]:\n"); - std::vector< Macro >::iterator i = t->course.macros.begin(); + std::vector< Macro >::iterator i = t->macros.begin(); - while(i != t->course.macros.end()) { + while(i != t->macros.end()) { printf("\t\t\t[Macro]:\n"); print_attributes("\t\t\t\t-", (*i).attributes); |