Botan 3.9.0
Crypto and TLS for C&
oid_map.h
Go to the documentation of this file.
1/*
2* (C) 2023 Jack Lloyd
3*
4* Botan is released under the Simplified BSD License (see license.txt)
5*/
6
7#ifndef BOTAN_OID_MAP_H_
8#define BOTAN_OID_MAP_H_
9
10#include <botan/asn1_obj.h>
11#include <botan/mutex.h>
12#include <optional>
13#include <string>
14#include <string_view>
15#include <unordered_map>
16
17namespace Botan {
18
19class OID_Map final {
20 public:
21 void add_oid(const OID& oid, std::string_view str);
22
23 // TODO(Botan4) remove this function when oids.h is removed
24 void add_str2oid(const OID& oid, std::string_view str);
25
26 // TODO(Botan4) remove this function when oids.h is removed
27 void add_oid2str(const OID& oid, std::string_view str);
28
29 std::string oid2str(const OID& oid);
30
31 OID str2oid(std::string_view str);
32
33 static OID_Map& global_registry();
34
35 private:
36 static std::optional<std::string_view> lookup_static_oid(const OID& oid);
37 static std::optional<OID> lookup_static_oid_name(std::string_view name);
38
39 static std::unordered_map<OID, std::string> load_oid2str_map();
40 static std::unordered_map<std::string, OID> load_str2oid_map();
41
42 OID_Map();
43
44 mutex_type m_mutex;
45 std::unordered_map<std::string, OID> m_str2oid;
46 std::unordered_map<OID, std::string> m_oid2str;
47};
48
49} // namespace Botan
50
51#endif
std::string oid2str(const OID &oid)
Definition oid_map.cpp:69
void add_oid(const OID &oid, std::string_view str)
Definition oid_map.cpp:21
static OID_Map & global_registry()
Definition oid_map.cpp:16
void add_str2oid(const OID &oid, std::string_view str)
Definition oid_map.cpp:47
void add_oid2str(const OID &oid, std::string_view str)
Definition oid_map.cpp:58
OID str2oid(std::string_view str)
Definition oid_map.cpp:84
noop_mutex mutex_type
Definition mutex.h:37