 |
Gorgon Game Engine
|
Go to the documentation of this file.
9 namespace Gorgon {
namespace Encoding {
13 using std::runtime_error::runtime_error;
38 URI(
const std::string &str,
bool inpagelink =
false);
42 URI(
const char *str) :
URI(std::string(str)) { }
45 operator std::string()
const;
48 std::string
Convert()
const {
return *
this; }
55 operator bool()
const {
72 void Combine(
const std::string &link);
112 HTTPQuery(std::initializer_list<std::pair<const std::string, std::string>>
init);
118 operator std::string()
const;
124 std::string
Get(
const std::string &key)
const {
125 if(
data.count(key) == 0)
return "";
136 bool Exists(
const std::string &key)
const {
137 return data.count(key) != 0;
141 std::map<std::string, std::string>
data;
156 URIPath(
const std::string &path);
162 operator std::string()
const;
176 std::string
Get(
int ind)
const {
177 if(ind==0 &&
segments.size()==0)
return "";
229 std::string
URIDecode(
const std::string &str);
232 std::string
URIEncode(
const std::string &str);
236 std::string
PCTEncode(
const std::string &str,
const std::set<char> &allowed,
bool allowalpha=
true,
bool allownum=
true);
Represents and HTTP query that might be send to page using POST or embedded in URI.
Definition: URI.h:105
This error is thrown while URI decoding and building.
Definition: URI.h:11
bool IsValid() const
Returns if this URI is valid.
Definition: URI.cpp:385
URIPath(const char *path)
Parses the given path.
Definition: URI.h:159
URI operator+(const std::string &link)
Definition: URI.h:74
std::string URIEncode(const std::string &str)
Encodes a given URI string according to RFC 3986.
Definition: URI.cpp:125
std::string PCTEncode(const std::string &str, const std::set< char > &allowed, bool allowalpha=true, bool allownum=true)
Customized percentage encoding.
Definition: URI.cpp:108
URI(const char *str)
Builds a new URI from the given string.
Definition: URI.h:42
std::string Convert() const
Converts this query system to string.
Definition: URI.h:121
void init()
Definition: X11.cpp:143
int GetSize() const
Definition: URI.h:170
std::string Get(const std::string &key) const
Returns the value that is stored within key. If key does not exist, an empty string will be returned.
Definition: URI.h:124
bool operator!=(const URI &other) const
Compares two URIs in their simplest forms.
Definition: URI.h:67
std::string & operator[](int ind)
Returns the segment at the given index.
Definition: URI.h:173
std::string FixLineEndings(const std::string &in, LineEnding type=LineEnding::Standard)
Fixes/changes line endings.
Definition: String.cpp:8
std::string query
Query for the resource, must be properly escaped and encoded, you may use HTTPQuery to build http que...
Definition: URI.h:98
void Combine(const std::string &link)
Combines a relative URI into this URI.
Definition: URI.cpp:398
Root namespace for Gorgon Game Engine.
Definition: Any.h:19
std::string Convert() const
Converts this URI to a properly encoded string.
Definition: URI.h:48
std::string URIDecode(const std::string &str)
Decodes a given URI string according to RFC 3986. May throw URIError.
Definition: URI.cpp:74
void Normalize()
Normalizes any relative references in the path. May throw URIError.
Definition: URI.cpp:593
std::string Convert() const
Converts the path to string properly escaping for URI.
Definition: URI.h:197
bool operator!=(const URIPath &other) const
Compares two paths after normalization.
Definition: URI.h:168
std::string ToLower(std::string str)
Converts the given string to lowercase.
Definition: String.h:416
std::string host
Host address, either IP/domain name or empty, ex: darkgaze.org.
Definition: URI.h:85
std::string scheme
Scheme of the URI, ex: http.
Definition: URI.h:82
std::string fragment
Fragment of the resource (anchor in HTML)
Definition: URI.h:101
std::string StripFirst()
Returns the first segment and removes it from the list of segments.
Definition: URI.h:184
URIPath()=default
Empty constructor.
void Combine(const URIPath &another)
Combines another URIPath using this one as the root.
Definition: URI.cpp:622
bool Exists(const std::string &key) const
Returns if the given key exists.
Definition: URI.h:136
URIPath operator+(const URIPath &another) const
Combines this path with another, using this path as the root.
Definition: URI.h:203
URI()=default
Empty constructor. Does not set scheme thus would not be a valid URI.
Helps to manage URIPaths.
Definition: URI.h:146
std::string path
Path of the resource. Segments must be separated by /. You may use URIPath to construct a path.
Definition: URI.h:95
std::string & operator[](const std::string &key)
Returns the value that is stored within key. If key does not exist, an empty value with the given key...
Definition: URI.h:131
int port
The port number, 0 means it is not defined.
Definition: URI.h:92
std::ostream & operator<<(std::ostream &out, const URI &uri)
Definition: URI.cpp:642
URIPath & operator+=(const URIPath &another)
Combines another URIPath into this one, using this path as the root.
Definition: URI.h:210
std::string Concat(const P_ &... rest)
Streams the given parameters into a stringstream and returns the result, effectively concatinating al...
Definition: String.h:560
std::string Get(int ind) const
Returns the segment at the given index. Index 0 will never cause an error, if does not exists,...
Definition: URI.h:176
std::string userinfo
User information.
Definition: URI.h:89
Represents an unfolded URI.
Definition: URI.h:22
HTTPQuery()=default
Empty constructor.
std::map< std::string, std::string > data
Key-value pairs for this HTTP query.
Definition: URI.h:141
bool operator==(const URI &other) const
Compares two URIs in their simplest forms.
Definition: URI.cpp:454
bool operator==(const URIPath &other) const
Compares two paths after normalization.
Definition: URI.cpp:629
std::vector< std::string > segments
List of segments.
Definition: URI.h:219