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

spl/web/Uri.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 _uri_h
00018 #define _uri_h
00019 
00020 #include <string.h>
00021 #include <spl/types.h>
00022 #include <spl/Debug.h>
00023 #include <spl/collection/Association.h>
00024 #include <spl/collection/Hashtable.h>
00025 #include <spl/Memory.h>
00026 #include <spl/String.h>
00027 #include <spl/collection/Vector.h>
00028 
00034 class Uri : public IMemoryValidate, public IHashable
00035 {
00036 protected:
00037         String m_protocol;
00038         String m_server;
00039         int m_port;
00040         String m_path;
00041         String m_filename;
00042         String m_fileext;
00043 
00044         Vector<Association<String, String> > m_args;
00045         Hashtable<String, String> m_argIdx;
00046 
00047 public:
00048         Uri(  );
00049         Uri( const Uri& uri );
00050         Uri( const String& cpuri );
00051         virtual ~Uri();
00052 
00053         Uri& operator =(const Uri& uri);
00054 
00055         inline String& Protocol() { return m_protocol; }
00056         inline String& Host() { return m_server; }
00057         inline int& Port() { return m_port; }
00058         inline String& Path() { return m_path; }
00059         inline String& Filename() { return m_filename; }
00060         inline String& FileExt() { return m_fileext; }
00061 
00062         inline const Vector<Association<String, String> >& Args() { return m_args; }
00063 
00064         inline bool HasArg(const String& argname) const { return m_argIdx.ContainsKey(argname); }
00065 
00066         inline String& GetArg(const String& argname) { return m_argIdx.GetRef(argname); }
00067 
00068         void Parse( const String& uri );
00069 
00070         virtual int32 HashCode() const;
00071 
00072         StringPtr AbsolutePath() const;
00073         StringPtr ToString() const;
00074 
00075 #ifdef DEBUG
00076         void ValidateMem() const;
00077         void CheckMem() const;
00078 #endif
00079 };
00080 
00083 #endif