/*
- * Copyright 2001-2006 Internet2
+ * Copyright 2001-2007 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
const string& buf,
const char*& lastpos,
ostream& os,
- const map<string,string>& parameters,
+ const TemplateParameters& parameters,
const XMLToolingException* e
) const
{
string key = buf.substr(lastpos-line, thispos-lastpos);
trimspace(key);
- map<string,string>::const_iterator i=parameters.find(key);
- if (i != parameters.end()) {
- html_encode(os,i->second.c_str());
- }
- else if (e) {
- const char* ep = e->getProperty(key.c_str());
- if (ep)
- html_encode(os,ep);
- }
+ const char* p = parameters.getParameter(key.c_str());
+ if (!p && e)
+ p = e->getProperty(key.c_str());
+ if (p)
+ html_encode(os,p);
lastpos = thispos + 2; // strlen("/>")
}
}
if ((thispos = strchr(lastpos, '>')) != NULL) {
string key = buf.substr(lastpos-line, thispos-lastpos);
trimspace(key);
- map<string,string>::const_iterator i=parameters.find(key);
bool cond=false;
- if (visible) {
- if (i != parameters.end())
- cond=true;
- else if (e && e->getProperty(key.c_str()))
- cond=true;
- }
+ if (visible)
+ cond = parameters.getParameter(key.c_str()) || (e && e->getProperty(key.c_str()));
lastpos = thispos + 1; // strlen(">")
process(cond, buf, lastpos, os, parameters, e);
}
if ((thispos = strchr(lastpos, '>')) != NULL) {
string key = buf.substr(lastpos-line, thispos-lastpos);
trimspace(key);
- map<string,string>::const_iterator i=parameters.find(key);
bool cond=visible;
- if (visible) {
- if (i != parameters.end())
- cond=false;
- else if (e && e->getProperty(key.c_str()))
- cond=false;
- }
+ if (visible)
+ cond = !(parameters.getParameter(key.c_str()) || (e && e->getProperty(key.c_str())));
lastpos = thispos + 1; // strlen(">")
process(cond, buf, lastpos, os, parameters, e);
}
os << buf.substr(lastpos-line);
}
-void TemplateEngine::run(istream& is, ostream& os, const map<string,string>& parameters, const XMLToolingException* e) const
+void TemplateEngine::run(istream& is, ostream& os, const TemplateParameters& parameters, const XMLToolingException* e) const
{
string buf,line;
while (getline(is, line))