X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=xmltooling%2Futil%2FTemplateEngine.cpp;h=22881e3d72a1dcd92458cd7e5a42e13074b7b47f;hb=2e9d480a1f469205355b41ba3100279ed4434796;hp=7d3e7d88b04fb940db898f9273738665834fc14c;hpb=f5347b8db8b591a5dd03d2d93d76208ca5e2491e;p=shibboleth%2Fxmltooling.git diff --git a/xmltooling/util/TemplateEngine.cpp b/xmltooling/util/TemplateEngine.cpp index 7d3e7d8..22881e3 100644 --- a/xmltooling/util/TemplateEngine.cpp +++ b/xmltooling/util/TemplateEngine.cpp @@ -33,6 +33,8 @@ void TemplateEngine::setTagPrefix(const char* tagPrefix) ifnottag = string("<") + tagPrefix + "ifnot "; ifendtag = string(""; ifnotendtag = string(""; + fortag = string("<") + tagPrefix + "for "; + forendtag = string(""; } string TemplateEngine::unsafe_chars = "#%&():[]\\`{}"; @@ -186,6 +188,53 @@ void TemplateEngine::process( lastpos = thispos + ifnotendtag.length(); return; } + +#ifdef HAVE_STRCASECMP + else if (!strncasecmp(thispos, fortag.c_str(), fortag.length())) +#else + else if (!_strnicmp(thispos, fortag.c_str(), fortag.length())) +#endif + { + // Save this position off. + lastpos = thispos + iftag.length(); + string key; + bool cond = visible; + + // search for the end of this tag + if ((thispos = strchr(lastpos, '>')) != NULL) { + key = buf.substr(lastpos-line, thispos-lastpos); + trimspace(key); + lastpos = thispos + 1; // strlen(">") + } + const vector forParams = parameters.getParameterCollection(key.c_str()); + + unsigned int forend = forParams.size(); + if (forend==0) { // have to go through at least once to match end tags + cond = false; + forend = 1; + } + + const char *savlastpos = lastpos; + for (unsigned int i=0; i0? static_cast(&forParams[i]): &nullp; + lastpos = savlastpos; + process(cond, buf, lastpos, os, *tp, e); + } + + } + +#ifdef HAVE_STRCASECMP + else if (!strncasecmp(thispos, forendtag.c_str(), forendtag.length())) +#else + else if (!_strnicmp(thispos, forendtag.c_str(), forendtag.length())) +#endif + { + // Save this position off and pop the stack. + lastpos = thispos + forendtag.length(); + return; + } + else { // Skip it. if (visible)