• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

spl/web/HttpUtility.h

00001 /*
00002  *   This file is part of the Standard Portable Library (SPL).
00003  *
00004  *   SPL is free software: you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation, either version 3 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   SPL is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with SPL.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 #ifndef _httputility_h
00018 #define _httputility_h
00019 
00020 #include <spl/String.h>
00021 
00027 class HttpUtility
00028 {
00029 private:
00030         HttpUtility() {}
00031 
00032         inline static bool NotEncoded (char c)
00033         {
00034                 return (c == '!' || c == '\'' || c == '(' || c == ')' || c == '*' || c == '-' || c == '.' || c == '_');
00035         }
00036 
00037 public:
00038 
00039         static StringPtr HtmlAttributeEncode (const char *cp, int len);
00040         inline static StringPtr HtmlAttributeEncode (const String& s) { return HtmlAttributeEncode(s.GetChars(), s.Length()); }
00041 
00042         static bool HtmlAttributeEncodeRequired (const char *cp, int len);
00043         inline static bool HtmlAttributeEncodeRequired (const String& s) { return HtmlAttributeEncodeRequired(s.GetChars(), s.Length()); }
00044 
00045         static StringPtr UrlDecode (const char *cp, int len);
00046         inline static StringPtr UrlDecode (const String& s) { return UrlDecode(s.GetChars(), s.Length()); }
00047 
00048         static StringPtr UrlEncode (const char *cp, int len);
00049         inline static StringPtr UrlEncode (const String& s) { return UrlEncode(s.GetChars(), s.Length()); }
00050 
00051         static bool UrlEncodeRequired (const char *cp, int len);
00052         inline static bool UrlEncodeRequired (const String& s) { return UrlEncodeRequired(s.GetChars(), s.Length()); }
00053 
00054         static StringPtr HtmlDecode (const char *cp, int len);
00055         inline static StringPtr HtmlDecode (const String& s) { return HtmlDecode(s.GetChars(), s.Length()); }
00056 
00057         static StringPtr HtmlEncode (const char *cp, int len);
00058         inline static StringPtr HtmlEncode (const String& s) { return HtmlEncode(s.GetChars(), s.Length()); }
00059 
00060         static bool HtmlEncodeRequired (const char *cp, int len);
00061         inline static bool HtmlEncodeRequired (const String& s) { return HtmlEncodeRequired(s.GetChars(), s.Length()); }
00062 };
00063 
00066 #endif