1 /*
2 * (C) 2019 Nuno Goncalves <nunojpg@gmail.com>
3 *
4 * Botan is released under the Simplified BSD License (see license.txt)
5 */
6 
7 #ifndef BOTAN_URI_H_
8 #define BOTAN_URI_H_
9 
10 #include <cstdint>
11 #include <string>
12 
13 #include <botan/build.h>
14 
15 namespace Botan {
16 
17 struct BOTAN_TEST_API URI
18    {
19    enum class Type : uint8_t
20       {
21       NotSet,
22       IPv4,
23       IPv6,
24       Domain,
25       };
26    static URI fromAny(const std::string& uri);
27    static URI fromIPv4(const std::string& uri);
28    static URI fromIPv6(const std::string& uri);
29    static URI fromDomain(const std::string& uri);
30    URI() = default;
URIURI31    URI(Type xtype, const std::string& xhost, unsigned short xport)
32       : type { xtype }
33       , host { xhost }
34       , port { xport }
35       {}
36    bool operator==(const URI& a) const
37       {
38       return type == a.type && host == a.host && port == a.port;
39       }
40    std::string to_string() const;
41 
42    const Type type{Type::NotSet};
43    const std::string host{};
44    const uint16_t port{};
45    };
46 
47 }
48 
49 #endif
50