Gnash  0.8.10
URL.h
Go to the documentation of this file.
00001 // 
00002 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00003 //   Free Software Foundation, Inc
00004 // 
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation; either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018 
00019 #ifndef GNASH_URL_H
00020 #define GNASH_URL_H
00021 
00022 #include "dsodefs.h"
00023 
00024 #include <iosfwd>
00025 #include <string>
00026 #include <map>
00027 
00028 namespace gnash {
00029 
00031 //
00034 class DSOEXPORT URL
00035 {
00036 
00037 public:
00038 
00039         friend std::ostream& operator<< (std::ostream&o, const URL& u);
00040 
00042         //
00048         URL(const std::string& absolute_url);
00049 
00052         //
00055         URL(const std::string& relative_url, const URL& baseurl);
00056 
00058         const std::string& protocol() const { return _proto; }
00059 
00061         //
00064         const std::string& hostname() const { return _host; }
00065 
00067         //
00071         const std::string& port() const { return _port; }
00072 
00074     //
00076         const std::string& path() const { return _path; }
00077 
00079         //
00082         const std::string& anchor() const { return _anchor; }
00083 
00085         //
00088         const std::string& querystring() const { return _querystring; }
00089         
00091         //
00092         void set_querystring(const std::string& value) { _querystring = value; } 
00093 
00095         //
00097         std::string str() const;
00098 
00100         //
00113         static void parse_querystring(const std::string& query_string,
00114                  std::map<std::string, std::string>& target_map);
00115 
00119         //
00133         static void encode(std::string& str);
00134 
00144         static std::string encode(const std::string& str);
00145 
00149         //
00158         static void decode(std::string& str);
00159 
00160 private:
00161         void init_absolute(const std::string& absurl);
00162 
00163         void init_relative(const std::string& relurl, const URL& baseurl);
00164 
00166         void split_anchor_from_path();
00167 
00169         void split_port_from_host();
00170 
00172         void split_querystring_from_path();
00173 
00175         //
00180         void normalize_path(std::string& path);
00181 
00182         std::string _proto;
00183         std::string _host;
00184         std::string _port;
00185         std::string _path;
00186         std::string _anchor;
00187         std::string _querystring;
00188 };
00189 
00190 DSOEXPORT std::ostream& operator<< (std::ostream&o, const URL& u);
00191 
00192 } // end of gnash namespace
00193 
00194 // __GNASH_URL_H__
00195 #endif
00196