Botan 3.7.1
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 <cstdint>
13#include <string>
14#include <string_view>
15
16namespace Botan {
17
19 public:
20 enum class Type : uint8_t {
21 IPv4,
22 IPv6,
23 Domain,
24 };
25
26 static URI from_any(std::string_view uri);
27 static URI from_ipv4(std::string_view uri);
28 static URI from_ipv6(std::string_view uri);
29 static URI from_domain(std::string_view uri);
30
31 URI(Type type, std::string_view host, uint16_t port) : m_type(type), m_host(host), m_port(port) {}
32
33 bool operator==(const URI& a) const { return m_type == a.m_type && m_host == a.m_host && m_port == a.m_port; }
34
35 std::string to_string() const;
36
37 const std::string& host() const { return m_host; }
38
39 uint16_t port() const { return m_port; }
40
41 Type type() const { return m_type; }
42
43 private:
44 const Type m_type;
45 const std::string m_host;
46 const uint16_t m_port;
47};
48
49} // namespace Botan
50
51#endif
#define BOTAN_TEST_API
Definition api.h:39
uint16_t port() const
Definition uri.h:39
URI(Type type, std::string_view host, uint16_t port)
Definition uri.h:31
Type type() const
Definition uri.h:41
std::string to_string() const
bool operator==(const URI &a) const
Definition uri.h:33
const std::string & host() const
Definition uri.h:37