AC_PATH_TOOL([$1], [$2])
if test "$DX_FLAG_[]DX_CURRENT_FEATURE$$1" = 1; then
AC_MSG_WARN([$2 not found - will not DX_CURRENT_DESCRIPTION])
- AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+ AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
fi
])
# ----------------------------------------------------------
# Turn off the DX_CURRENT_FEATURE if the required feature is off.
AC_DEFUN([DX_CLEAR_DEPEND], [
-test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_[]DX_CURRENT_FEATURE], 0)
+test "$DX_FLAG_$1" = "$2" || AC_SUBST([DX_FLAG_]DX_CURRENT_FEATURE, 0)
])
# DX_FEATURE_ARG(FEATURE, DESCRIPTION,
ifnottag = string("<") + tagPrefix + "ifnot ";
ifendtag = string("</") + tagPrefix + "if>";
ifnotendtag = string("</") + tagPrefix + "ifnot>";
+ fortag = string("<") + tagPrefix + "for ";
+ forendtag = string("</") + tagPrefix + "for>";
}
string TemplateEngine::unsafe_chars = "#%&():[]\\`{}";
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<xmltooling::TemplateEngine::TemplateParameters> 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; i<forend; i++ ) {
+ const TemplateParameters nullp;
+ const TemplateParameters* tp = forParams.size()>0? static_cast<const TemplateParameters*>(&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)
#include <map>
#include <string>
#include <iostream>
+#include <vector>
#if defined (_MSC_VER)
#pragma warning( push )
* <li> <mlp key/> </li>
* <li> <mlpif key> stuff </mlpif></li>
* <li> <mlpifnot key> stuff </mlpifnot></li>
+ * <li> <mlpfor key> stuff </mlpfor></li>
* </ul>
*
* The default tag prefix is "mlp". This can be overridden for
* Allows callers to supply a more dynamic lookup mechanism to supplement a basic map.
*/
class XMLTOOL_API TemplateParameters {
- MAKE_NONCOPYABLE(TemplateParameters);
+ // MAKE_NONCOPYABLE(TemplateParameters);
public:
TemplateParameters() : m_request(NULL) {}
virtual ~TemplateParameters() {}
/** Map of known parameters to supply to template. */
std::map<std::string,std::string> m_map;
+ std::map<std::string,std::vector<TemplateParameters> > m_collectionMap;
/** Request from client that resulted in template being processed. */
const GenericRequest* m_request;
std::map<std::string,std::string>::const_iterator i=m_map.find(name);
return (i!=m_map.end() ? i->second.c_str() : (m_request ? m_request->getParameter(name) : NULL));
}
+
+ /**
+ * Returns the collection of parameters to plug into the template.
+ *
+ * @param name name of parameter collection
+ * @return vector of parameters
+ */
+ virtual const std::vector<TemplateParameters> getParameterCollection(const char* name) const {
+ std::map<std::string,std::vector<TemplateParameters> >::const_iterator i=m_collectionMap.find(name);
+ return (i->second);
+ }
};
/**
const XMLToolingException* e
) const;
- std::string keytag,iftag,ifendtag,ifnottag,ifnotendtag;
+ std::string keytag,iftag,ifendtag,ifnottag,ifnotendtag,fortag,forendtag;
};
};