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 
path
VGPath path
Definition: testr_gtk.cpp:84
gnash::URL::URL
URL(const std::string &absolute_url)
Construct an URL from the given absolute url string.
Definition: URL.cpp:141
name
std::string name
Definition: LocalConnection_as.cpp:149
gnash::GnashException
Top-level gnash exception.
Definition: GnashException.h:31
gnash::URL::hostname
const std::string & hostname() const
Return the 'hostname' member of this URL, as a string.
Definition: URL.h:64
dsodefs.h
gnash::log_debug
void log_debug(StringType msg, Args... args)
Definition: log.h:301
y
std::int32_t y
Definition: BitmapData_as.cpp:435
gnash::key::i
@ i
Definition: GnashKey.h:155
_
#define _(String)
Definition: log.h:44
gnash
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:41
gnash::UinputDevice::init
bool init()
Definition: UinputDevice.cpp:92
gnash::URL::parse_querystring
static void parse_querystring(const std::string &query_string, std::map< std::string, std::string > &target_map)
Parse a query string filling the provided map.
Definition: URL.cpp:354
gnash::URL::anchor
const std::string & anchor() const
Return the 'anchor' member of this URL, as a string.
Definition: URL.h:82
gnash::URL::set_querystring
void set_querystring(const std::string &value)
Set the 'querystring' member of this URL to a new value.
Definition: URL.h:92
gnash::URL::port
const std::string & port() const
Return the 'port' member of this URL, as a string.
Definition: URL.h:71
gnash::log_error
void log_error(StringType msg, Args... args)
Definition: log.h:283
gnash::URL::path
const std::string & path() const
Return the 'path' member of this URL, as a string.
Definition: URL.h:76
gnash::UinputDevice::scanForDevice
bool scanForDevice()
Definition: UinputDevice.cpp:51
GnashSleep.h
gnash::amf::write
void write(SimpleBuffer &buf, const std::string &str)
Write a string to an AMF buffer.
Definition: AMF.cpp:161
gnash::URL::encode
static void encode(std::string &str)
Encode a string to URL-encoded format converting all dodgy characters to AB hex sequences.
Definition: URL.cpp:391
gnash::URL::decode
static void decode(std::string &str)
Decode a string from URL-encoded format converting all hexadecimal sequences to ASCII characters.
Definition: URL.cpp:418
gnash::key::type
type
Definition: GnashKey.h:330
EV_SYN
#define EV_SYN
Definition: evtest.c:42
URL.h
gnash::UinputDevice::~UinputDevice
~UinputDevice()
Definition: UinputDevice.cpp:40
InputDevice.h
log.h
gnash::URL::querystring
const std::string & querystring() const
Return the 'querystring' member of this URL, as a string.
Definition: URL.h:88
gnashconfig.h
gnash::UinputDevice::UinputDevice
UinputDevice()
Definition: UinputDevice.cpp:34
gnash::key::c
@ c
Definition: GnashKey.h:149
DSOEXPORT
#define DSOEXPORT
Definition: dsodefs.h:55
gnash::InputDevice::devicetype_e
devicetype_e
Definition: InputDevice.h:94
gnash::URL::protocol
const std::string & protocol() const
Return the 'protocol' member of this URL, as a string.
Definition: URL.h:58
gnash::URL
Uniform Resource Locator.
Definition: URL.h:35
gnash::key::o
@ o
Definition: GnashKey.h:161
gnash::key::u
@ u
Definition: GnashKey.h:167
GnashException.h
x
std::int32_t x
Definition: BitmapData_as.cpp:434
gnash::URL::str
std::string str() const
Return the full absolute URL as a string.
Definition: URL.cpp:272
gnash::key::e
@ e
Definition: GnashKey.h:151
gnash::UinputDevice::moveTo
bool moveTo(int x, int y)
Definition: UinputDevice.cpp:189
gnash::operator<<
std::ostream & operator<<(std::ostream &o, const URL &u)
Definition: URL.cpp:447