+/*\r
+ * Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * @file saml/binding/URLEncoder.h\r
+ * \r
+ * Interface to a URL-encoding mechanism along with a\r
+ * default implementation.\r
+ */\r
+\r
+#ifndef __saml_urlenc_h__\r
+#define __saml_urlenc_h__\r
+\r
+#include <saml/base.h>\r
+\r
+namespace opensaml {\r
+ /**\r
+ * Interface to a URL-encoding mechanism along with a default implementation.\r
+ * \r
+ * Since URL-encoding is not canonical, it's important that the same\r
+ * encoder is used during some library operations and the calling code.\r
+ * Applications can supply an alternative implementation to the library\r
+ * if required.\r
+ */\r
+ class SAML_API URLEncoder {\r
+ MAKE_NONCOPYABLE(URLEncoder);\r
+ public:\r
+ URLEncoder() {}\r
+ virtual ~URLEncoder() {}\r
+ \r
+ /**\r
+ * Produce a URL-safe but equivalent version of the input string.\r
+ * \r
+ * @param s input string to encode\r
+ * @return a string object containing the result of encoding the input\r
+ */\r
+ virtual std::string encode(const char* s) const;\r
+ \r
+ /**\r
+ * Perform an in-place decoding operation on the input string.\r
+ * The resulting string will be NULL-terminated.\r
+ * \r
+ * @param s input string to decode in a writable buffer\r
+ */\r
+ virtual void decode(char* s) const;\r
+ \r
+ protected:\r
+ /**\r
+ * Returns true iff the input character requires encoding.\r
+ * \r
+ * @param ch the character to check\r
+ * @return true iff the character should be encoded \r
+ */\r
+ virtual bool isBad(char ch) const {\r
+ static char badchars[]="=&/?:\"\\+<>#%{}|^~[]`;@";\r
+ return (strchr(badchars,ch) || ch<=0x20 || ch>=0x7F);\r
+ }\r
+ };\r
+};\r
+\r
+#endif /* __saml_urlenc_h__ */\r