Cuberite
A lightweight, fast and extensible game server for Minecraft
UrlParser.h
Go to the documentation of this file.
1 
2 // UrlParser.h
3 
4 // Declares the cUrlParser class that parses string URL into individual parts
5 
6 
7 
8 
9 
10 #pragma once
11 
12 
13 
14 
15 
17 {
18 public:
21  static bool IsKnownScheme(const AString & a_Scheme) { return (GetDefaultPort(a_Scheme) > 0); }
22 
25  static UInt16 GetDefaultPort(const AString & a_Scheme);
26 
30  static std::pair<bool, AString> ParseAuthorityPart(
31  const AString & a_AuthorityPart,
32  AString & a_Username,
33  AString & a_Password,
34  AString & a_Host,
35  UInt16 & a_Port
36  );
37 
43  static std::pair<bool, AString> Parse(
44  const AString & a_Url,
45  AString & a_Scheme,
46  AString & a_Username,
47  AString & a_Password,
48  AString & a_Host,
49  UInt16 & a_Port,
50  AString & a_Path,
51  AString & a_Query,
52  AString & a_Fragment
53  );
54 
56  static std::pair<bool, AString> Validate(const AString & a_Url);
57 };
58 
59 
60 
61 
unsigned short UInt16
Definition: Globals.h:158
std::string AString
Definition: StringUtils.h:11
static std::pair< bool, AString > Parse(const AString &a_Url, AString &a_Scheme, AString &a_Username, AString &a_Password, AString &a_Host, UInt16 &a_Port, AString &a_Path, AString &a_Query, AString &a_Fragment)
Parses the given URL into individual components.
Definition: UrlParser.cpp:117
static std::pair< bool, AString > ParseAuthorityPart(const AString &a_AuthorityPart, AString &a_Username, AString &a_Password, AString &a_Host, UInt16 &a_Port)
Parses the given Authority part of an URL into individual components.
Definition: UrlParser.cpp:39
static bool IsKnownScheme(const AString &a_Scheme)
Returns true if the specified scheme (http, ftp, mailto, ...) is recognized by the URL parser.
Definition: UrlParser.h:21
static std::pair< bool, AString > Validate(const AString &a_Url)
Checks if the supplied URL is valid.
Definition: UrlParser.cpp:202
static UInt16 GetDefaultPort(const AString &a_Scheme)
Returns the default port used by the specified scheme / protocol.
Definition: UrlParser.cpp:14