Botan  2.18.1
Crypto and TLS for C++11
uri.h
Go to the documentation of this file.
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 
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;
31  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
MechanismType type
#define BOTAN_TEST_API
Definition: compiler.h:51
std::string to_string(ErrorType type)
Convert an ErrorType to string.
Definition: exceptn.cpp:11
const std::string host
Definition: uri.h:43
Definition: alg_id.cpp:13
bool operator==(const URI &a) const
Definition: uri.h:36
URI(Type xtype, const std::string &xhost, unsigned short xport)
Definition: uri.h:31
const uint16_t port
Definition: uri.h:44
Definition: uri.h:17
const Type type
Definition: uri.h:42
Type
Definition: uri.h:19