Botan 3.11.0
Crypto and TLS for C&
uri.h
Go to the documentation of this file.
1/*
2* (C) 2019 Nuno Goncalves <nunojpg@gmail.com>
3* 2023,2024 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#ifndef BOTAN_URI_H_
9#define BOTAN_URI_H_
10
11#include <botan/types.h>
12#include <string>
13#include <string_view>
14
15namespace Botan {
16
18 public:
19 enum class Type : uint8_t {
20 IPv4,
21 IPv6,
22 Domain,
23 };
24
25 static URI from_any(std::string_view uri);
26 static URI from_ipv4(std::string_view uri);
27 static URI from_ipv6(std::string_view uri);
28 static URI from_domain(std::string_view uri);
29
30 URI(Type type, std::string_view host, uint16_t port) : m_type(type), m_host(host), m_port(port) {}
31
32 bool operator==(const URI& a) const { return m_type == a.m_type && m_host == a.m_host && m_port == a.m_port; }
33
34 std::string to_string() const;
35
36 const std::string& host() const { return m_host; }
37
38 uint16_t port() const { return m_port; }
39
40 Type type() const { return m_type; }
41
42 private:
43 const Type m_type;
44 const std::string m_host;
45 const uint16_t m_port;
46};
47
48} // namespace Botan
49
50#endif
#define BOTAN_TEST_API
Definition api.h:41
uint16_t port() const
Definition uri.h:38
URI(Type type, std::string_view host, uint16_t port)
Definition uri.h:30
Type type() const
Definition uri.h:40
std::string to_string() const
bool operator==(const URI &a) const
Definition uri.h:32
const std::string & host() const
Definition uri.h:36