Gnash  0.8.11dev
URL.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 // Free Software Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 
19 #ifndef GNASH_URL_H
20 #define GNASH_URL_H
21 
22 #include "dsodefs.h"
23 
24 #include <iosfwd>
25 #include <string>
26 #include <map>
27 
28 namespace gnash {
29 
31 //
35 {
36 
37 public:
38 
39  friend std::ostream& operator<< (std::ostream&o, const URL& u);
40 
42  //
48  URL(const std::string& absolute_url);
49 
52  //
55  URL(const std::string& relative_url, const URL& baseurl);
56 
58  const std::string& protocol() const { return _proto; }
59 
61  //
64  const std::string& hostname() const { return _host; }
65 
67  //
71  const std::string& port() const { return _port; }
72 
74  //
76  const std::string& path() const { return _path; }
77 
79  //
82  const std::string& anchor() const { return _anchor; }
83 
85  //
88  const std::string& querystring() const { return _querystring; }
89 
91  //
92  void set_querystring(const std::string& value) { _querystring = value; }
93 
95  //
97  std::string str() const;
98 
100  //
113  static void parse_querystring(const std::string& query_string,
114  std::map<std::string, std::string>& target_map);
115 
119  //
133  static void encode(std::string& str);
134 
144  static std::string encode(const std::string& str);
145 
149  //
158  static void decode(std::string& str);
159 
160 private:
161  void init_absolute(const std::string& absurl);
162 
163  void init_relative(const std::string& relurl, const URL& baseurl);
164 
166  void split_anchor_from_path();
167 
169  void split_port_from_host();
170 
172  void split_querystring_from_path();
173 
175  //
180  void normalize_path(std::string& path);
181 
182  std::string _proto;
183  std::string _host;
184  std::string _port;
185  std::string _path;
186  std::string _anchor;
187  std::string _querystring;
188 };
189 
190 DSOEXPORT std::ostream& operator<< (std::ostream&o, const URL& u);
191 
192 } // end of gnash namespace
193 
194 // __GNASH_URL_H__
195 #endif
196 
const std::string & path() const
Return the &#39;path&#39; member of this URL, as a string.
Definition: URL.h:76
const std::string & protocol() const
Return the &#39;protocol&#39; member of this URL, as a string.
Definition: URL.h:58
const std::string & anchor() const
Return the &#39;anchor&#39; member of this URL, as a string.
Definition: URL.h:82
Definition: GnashKey.h:167
VGPath path
Definition: testr_gtk.cpp:84
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
Definition: GnashKey.h:161
const std::string & hostname() const
Return the &#39;hostname&#39; member of this URL, as a string.
Definition: URL.h:64
std::ostream & operator<<(std::ostream &o, const URL &u)
Definition: URL.cpp:447
const std::string & port() const
Return the &#39;port&#39; member of this URL, as a string.
Definition: URL.h:71
const std::string & querystring() const
Return the &#39;querystring&#39; member of this URL, as a string.
Definition: URL.h:88
#define DSOEXPORT
Definition: dsodefs.h:55
void set_querystring(const std::string &value)
Set the &#39;querystring&#39; member of this URL to a new value.
Definition: URL.h:92
Uniform Resource Locator.
Definition: URL.h:34