diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-08-23 13:31:57 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-08-23 13:31:57 +0200 |
commit | 07694570b09524881d01df7c857cc8f471f1ad04 (patch) | |
tree | 8cae77df7bb081c1b7d37a587d11c765769d3643 /server/src/templateparser.cc | |
parent | 05732251c115b3538879ca523c461572115c6526 (diff) | |
parent | 909c48a297d7f68b107fce7ad444c2165f749f42 (diff) |
Merge branch 'master' of http://git.aasimon.org/public/pracro
Diffstat (limited to 'server/src/templateparser.cc')
-rw-r--r-- | server/src/templateparser.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/server/src/templateparser.cc b/server/src/templateparser.cc index b9c65f5..8fc3eff 100644 --- a/server/src/templateparser.cc +++ b/server/src/templateparser.cc @@ -81,6 +81,10 @@ TemplateParser::~TemplateParser() void TemplateParser::characterData(std::string &data) { + if(state == SCRIPT) { + assert(current_script); // No script present! + current_script->code.append(data); + } } void TemplateParser::startTag(std::string name, attributes_t &attr) @@ -127,6 +131,39 @@ void TemplateParser::startTag(std::string name, attributes_t &attr) return; } + // Enable script parsing + if(name == "scripts") { + if(state != TEMPLATE) error("scripts found outside template."); + state = SCRIPTS; + + assert(t); // No template is currently available, cannot create maps! + + return; + } + + // Create script + if(name == "script") { + + assert(t); // No template is currently available, cannot create script! + + switch(state) { + case SCRIPTS: + { + state = SCRIPT; + + Script s; + s.attributes = attr; + t->scripts.push_back(s); + current_script = &(t->scripts.back()); + } + break; + default: + error("<script> tag found outside <scripts> tag."); + break; + } + return; + } + error("Unknown/illegal tag: %s", name.c_str()); } @@ -137,6 +174,18 @@ void TemplateParser::endTag(std::string name) current_macro = NULL; state = TEMPLATE; } + if(name == "scripts") state = TEMPLATE; + if(name == "script") { + switch(state) { + case SCRIPT: + current_script = NULL; + state = SCRIPTS; + break; + default: + // tag mismatch? + break; + } + } } int TemplateParser::readData(char *data, size_t size) |