/*
- * Copyright 2001-2009 Internet2
+ * Copyright 2001-2010 Internet2
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*/
#include "internal.h"
+#include "io/GenericRequest.h"
#include "util/TemplateEngine.h"
using namespace xmltooling;
using namespace std;
namespace {
- static const pair<string,string> emptyPair;
+ static const pair<const string,string> emptyPair;
+}
+
+TemplateEngine::TemplateEngine()
+{
+ setTagPrefix("mlp");
+}
+
+TemplateEngine::~TemplateEngine()
+{
+}
+
+TemplateEngine::TemplateParameters::TemplateParameters() : m_request(nullptr)
+{
+}
+
+TemplateEngine::TemplateParameters::~TemplateParameters()
+{
+}
+
+const char* TemplateEngine::TemplateParameters::getParameter(const char* name) const
+{
+ map<string,string>::const_iterator i=m_map.find(name);
+ return (i!=m_map.end() ? i->second.c_str() : (m_request ? m_request->getParameter(name) : nullptr));
+}
+
+const multimap<string,string>* TemplateEngine::TemplateParameters::getLoopCollection(const char* name) const
+{
+ map< string,multimap<string,string> >::const_iterator i=m_collectionMap.find(name);
+ return (i!=m_collectionMap.end() ? &(i->second) : nullptr);
}
void TemplateEngine::setTagPrefix(const char* tagPrefix)
const char*& lastpos,
ostream& os,
const TemplateParameters& parameters,
- const std::pair<std::string,std::string>& loopentry,
+ const std::pair<const std::string,std::string>& loopentry,
const XMLToolingException* e
) const
{
const char* line = buf.c_str();
const char* thispos;
- while ((thispos = strchr(lastpos, '<')) != NULL) {
+ while ((thispos = strchr(lastpos, '<')) != nullptr) {
// Output the string up to this token.
if (visible)
os << buf.substr(lastpos-line, thispos-lastpos);
lastpos = thispos + keytag.length();
// search for the end-tag
- if ((thispos = strstr(lastpos, "/>")) != NULL) {
+ if ((thispos = strstr(lastpos, "/>")) != nullptr) {
string key = buf.substr(lastpos-line, thispos-lastpos);
trimspace(key);
lastpos = thispos + iftag.length();
// search for the end of this tag
- if ((thispos = strchr(lastpos, '>')) != NULL) {
+ if ((thispos = strchr(lastpos, '>')) != nullptr) {
string key = buf.substr(lastpos-line, thispos-lastpos);
trimspace(key);
bool cond=false;
lastpos = thispos + ifnottag.length();
// search for the end of this tag
- if ((thispos = strchr(lastpos, '>')) != NULL) {
+ if ((thispos = strchr(lastpos, '>')) != nullptr) {
string key = buf.substr(lastpos-line, thispos-lastpos);
trimspace(key);
bool cond=visible;
bool cond = visible;
// search for the end of this tag
- if ((thispos = strchr(lastpos, '>')) != NULL) {
+ if ((thispos = strchr(lastpos, '>')) != nullptr) {
key = buf.substr(lastpos-line, thispos-lastpos);
trimspace(key);
lastpos = thispos + 1; // strlen(">")