URL.h++

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002    commonc++ - A C++ Common Class Library
00003    Copyright (C) 2005-2012  Mark A Lindner
00004 
00005    This file is part of commonc++.
00006 
00007    This library is free software; you can redistribute it and/or
00008    modify it under the terms of the GNU Library General Public
00009    License as published by the Free Software Foundation; either
00010    version 2 of the License, or (at your option) any later version.
00011 
00012    This library is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015    Library General Public License for more details.
00016 
00017    You should have received a copy of the GNU Library General Public
00018    License along with this library; if not, write to the Free
00019    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020    ---------------------------------------------------------------------------
00021 */
00022 
00023 #ifndef __ccxx_URL_hxx
00024 #define __ccxx_URL_hxx
00025 
00026 #include <memory>
00027 
00028 #include <commonc++/Common.h++>
00029 #include <commonc++/String.h++>
00030 #include <commonc++/ParseException.h++>
00031 #include <commonc++/RegExp.h++>
00032 
00033 namespace ccxx {
00034 
00041 class COMMONCPP_API URL
00042 {
00043   public:
00044 
00046   URL();
00047 
00049   URL(const String& url);
00050 
00052   URL(const URL& other);
00053 
00055   ~URL() throw();
00056 
00058   inline void setScheme(const String& scheme)
00059   { _scheme = scheme; _url = String::null; }
00060 
00062   inline String getScheme() const
00063   { return(_scheme); }
00064 
00066   inline void setHost(const String& host)
00067   { _host = host; _url = String::null; }
00068 
00070   inline String getHost() const
00071   { return(_host); }
00072 
00075   inline void setPort(uint16_t port) throw()
00076   { _port = port; _url = String::null; }
00077 
00081   inline uint16_t getPort() const throw()
00082   { return(_port); }
00083 
00085   void setPath(const String& path);
00086 
00088   inline String getPath() const
00089   { return(_path); }
00090 
00092   inline String getCanonicalPath() const
00093   { return(_canonicalPath); }
00094 
00099   inline void setQuery(const String& query)
00100   { _query = query; _url = String::null; }
00101 
00106   inline String getQuery() const
00107   { return(_query); }
00108 
00110   bool isValid() const throw();
00111 
00113   String toString() const;
00114 
00116   bool operator==(const URL& other) const throw();
00117 
00119   inline bool operator!=(const URL& other) const throw()
00120   { return(! operator==(other)); }
00121 
00123   URL& operator=(const String& other);
00124 
00126   URL& operator=(const URL& other);
00127 
00133   static String encode(const String& str);
00134 
00140   static String decode(const String& str);
00141 
00142   private:
00143 
00144   void _init();
00145   void _parseURL(const String& url);
00146   String _canonicalizePath(const String &path);
00147 
00148   String _scheme;
00149   String _host;
00150   uint16_t _port;
00151   String _path;
00152   String _canonicalPath;
00153   String _query;
00154   mutable String _url;
00155   RegExp _re;
00156 };
00157 
00158 }; // namespace ccxx
00159 
00160 #endif // __ccxx_URL_hxx
00161 
00162 /* end of header file */
Generated on Sat Nov 26 16:49:07 2011 for libcommonc++ by  doxygen 1.6.3