Merge branch '1.x' of ssh://authdev.it.ohio-state.edu/~scantor/git/cpp-xmltooling...
[shibboleth/cpp-xmltooling.git] / xmltooling / util / TemplateEngine.cpp
index 4062fca..90173c1 100644 (file)
@@ -1,17 +1,21 @@
-/*
- *  Copyright 2001-2009 Internet2
+/**
+ * Licensed to the University Corporation for Advanced Internet
+ * Development, Inc. (UCAID) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for
+ * additional information regarding copyright ownership.
  *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * UCAID licenses this file to you under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the
+ * License at
  *
- *     http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
  */
 
 /**
@@ -31,16 +35,33 @@ namespace {
     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) : NULL));
+    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) : NULL);
+    return (i!=m_collectionMap.end() ? &(i->second) : nullptr);
 }
 
 void TemplateEngine::setTagPrefix(const char* tagPrefix)
@@ -118,7 +139,7 @@ void TemplateEngine::process(
     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);
@@ -134,7 +155,7 @@ void TemplateEngine::process(
             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);
 
@@ -162,7 +183,7 @@ void TemplateEngine::process(
             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;
@@ -192,7 +213,7 @@ void TemplateEngine::process(
             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;
@@ -225,7 +246,7 @@ void TemplateEngine::process(
             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(">")