From 77272458e7a8906d871b241b5385bbd0f783d861 Mon Sep 17 00:00:00 2001 From: deva Date: Thu, 30 Jul 2009 08:36:12 +0000 Subject: Removed the term 'course' everywhere, and replaced it by 'template'. This reduced/simplified the Template class structure a bit. --- server/src/templateparser.cc | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'server/src/templateparser.cc') 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); -- cgit v1.2.3