From 23f39df8b8edeacfa5821050abbdc855acb2edd6 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 1 Jul 2011 11:54:26 +0000 Subject: removed macrotool. add lua wrapper for praxisd. new type attributes_t for sax parser and children. make macros/templates use real vars instead of var map. add data ttl on macro level. add 'important' attribute to macrotags in templates. --- server/src/templateparser.cc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'server/src/templateparser.cc') diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index 20270c6..b9c65f5 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -83,7 +83,7 @@ void TemplateParser::characterData(std::string &data) { } -void TemplateParser::startTag(std::string name, std::map< std::string, std::string> attributes) +void TemplateParser::startTag(std::string name, attributes_t &attr) { // Enable macro parsing if(name == "template") { @@ -92,7 +92,9 @@ void TemplateParser::startTag(std::string name, std::map< std::string, std::stri assert(t); // A Template has not yet been allocated, cannot create template! - t->attributes = attributes; + if(attr.find("name") != attr.end()) t->name = attr["name"]; + if(attr.find("title") != attr.end()) t->title = attr["title"]; + if(attr.find("version") != attr.end()) t->version = attr["version"]; return; } @@ -105,7 +107,19 @@ void TemplateParser::startTag(std::string name, std::map< std::string, std::stri assert(t); // A Template has not yet been allocated, cannot create macro! Macro m; - m.attributes = attributes; + + if(attr.find("name") != attr.end()) m.name = attr["name"]; + if(attr.find("version") != attr.end()) m.version = attr["version"]; + if(attr.find("caption") != attr.end()) m.caption = attr["caption"]; + if(attr.find("requires") != attr.end()) m.requires = attr["requires"]; + if(attr.find("ttl") != attr.end()) m.ttl = attr["ttl"]; + + m.isImportant = attr.find("important") != attr.end() && + attr["important"] == "true"; + m.isStatic = attr.find("static") != attr.end() && attr["static"] == "true"; + m.isCompact = attr.find("compact") != attr.end() && + attr["compact"] == "true"; + m.isHeader = name == "header"; t->macros.push_back(m); current_macro = &(t->macros.back()); @@ -139,7 +153,8 @@ int TemplateParser::readData(char *data, size_t size) return r; } -void TemplateParser::parseError(const char *buf, size_t len, std::string error, int lineno) +void TemplateParser::parseError(const char *buf, size_t len, std::string error, + int lineno) { fprintf(stderr, "TemplateParser[%s] error at line %d: %s\n", file.c_str(), lineno, error.c_str()); -- cgit v1.2.3