Missing assert header.
[shibboleth/xmltooling.git] / xmltooling / exceptions.cpp
index 56ce6d3..91f4ffa 100644 (file)
@@ -23,6 +23,7 @@
 #include "internal.h"
 #include "exceptions.h"
 #include "XMLToolingConfig.h"
+#include "util/URLEncoder.h"
 #include "util/XMLConstants.h"
 #include "util/XMLHelper.h"
 
@@ -222,20 +223,31 @@ string XMLToolingException::toString() const
     const char* msg=getMessage();
     if (msg)
         xml=xml + "<message>" + msg + "</message>";
-    for (map<string,string>::const_iterator i=m_params.begin(); i!=m_params.end(); i++) {
+    for (map<string,string>::const_iterator i=m_params.begin(); i!=m_params.end(); i++)
         xml=xml + "<param name=\"" + i->first + "\">" + i->second + "</param>";
-    }
     xml+="</exception>";
     return xml;
 }
 
+string XMLToolingException::toQueryString() const
+{
+    string q;
+    const URLEncoder* enc = XMLToolingConfig::getConfig().getURLEncoder();
+    for (map<string,string>::const_iterator i=m_params.begin(); i!=m_params.end(); i++) {
+        if (!q.empty())
+            q += '&';
+        q = q + i->first + '=' + enc->encode(i->second.c_str());
+    }
+    return q;
+}
+
 XMLToolingException* XMLToolingException::fromStream(std::istream& in)
 {
-    static const XMLCh exception[] = { chLatin_e, chLatin_x, chLatin_c, chLatin_e, chLatin_p, chLatin_t, chLatin_i, chLatin_o, chLatin_n, chNull };
-    static const XMLCh message[] = { chLatin_m, chLatin_e, chLatin_s, chLatin_s, chLatin_a, chLatin_g, chLatin_e, chNull };
-    static const XMLCh name[] = { chLatin_n, chLatin_a, chLatin_m, chLatin_e, chNull };
-    static const XMLCh param[] = { chLatin_p, chLatin_a, chLatin_r, chLatin_a, chLatin_m, chNull };
-    static const XMLCh type[] = { chLatin_t, chLatin_y, chLatin_p, chLatin_e, chNull };
+    static const XMLCh exception[] =    UNICODE_LITERAL_9(e,x,c,e,p,t,i,o,n);
+    static const XMLCh message[] =      UNICODE_LITERAL_7(m,e,s,s,a,g,e);
+    static const XMLCh name[] =         UNICODE_LITERAL_4(n,a,m,e);
+    static const XMLCh param[] =        UNICODE_LITERAL_5(p,a,r,a,m);
+    static const XMLCh type[] =         UNICODE_LITERAL_4(t,y,p,e);
 
     DOMDocument* doc=XMLToolingConfig::getConfig().getParser().parse(in);