Botan 3.9.0
Crypto and TLS for C&
Botan::OID_Map Class Referencefinal

#include <oid_map.h>

Public Member Functions

void add_oid (const OID &oid, std::string_view str)
void add_oid2str (const OID &oid, std::string_view str)
void add_str2oid (const OID &oid, std::string_view str)
std::string oid2str (const OID &oid)
OID str2oid (std::string_view str)

Static Public Member Functions

static OID_Mapglobal_registry ()

Detailed Description

Definition at line 19 of file oid_map.h.

Member Function Documentation

◆ add_oid()

void Botan::OID_Map::add_oid ( const OID & oid,
std::string_view str )

Definition at line 21 of file oid_map.cpp.

21 {
22 if(auto name = lookup_static_oid(oid)) {
23 if(*name != str) {
24 throw Invalid_State("Cannot register two different names to a single OID");
25 } else {
26 return;
27 }
28 }
29
31
32 auto o2s = m_oid2str.find(oid);
33
34 if(o2s == m_oid2str.end()) {
35 m_oid2str.insert(std::make_pair(oid, str));
36 } else if(o2s->second != str) {
37 throw Invalid_State("Cannot register two different names to a single OID");
38 }
39
40 auto s2o = m_str2oid.find(std::string(str));
41
42 if(s2o == m_str2oid.end()) {
43 m_str2oid.insert(std::make_pair(str, oid));
44 }
45}
secure_vector< T > lock(const std::vector< T > &in)
Definition secmem.h:81
lock_guard< T > lock_guard_type
Definition mutex.h:55

References Botan::lock().

Referenced by Botan::OID::register_oid().

◆ add_oid2str()

void Botan::OID_Map::add_oid2str ( const OID & oid,
std::string_view str )

Definition at line 58 of file oid_map.cpp.

58 {
59 if(lookup_static_oid(oid).has_value()) {
60 return;
61 }
62
64 if(!m_oid2str.contains(oid)) {
65 m_oid2str.insert(std::make_pair(oid, str));
66 }
67}

References Botan::lock().

Referenced by Botan::OIDS::add_oid2str().

◆ add_str2oid()

void Botan::OID_Map::add_str2oid ( const OID & oid,
std::string_view str )

Definition at line 47 of file oid_map.cpp.

47 {
48 if(lookup_static_oid_name(str).has_value()) {
49 return;
50 }
51
53 if(!m_str2oid.contains(std::string(str))) {
54 m_str2oid.insert(std::make_pair(str, oid));
55 }
56}

References Botan::lock().

Referenced by Botan::OIDS::add_str2oid().

◆ global_registry()

OID_Map & Botan::OID_Map::global_registry ( )
static

◆ oid2str()

std::string Botan::OID_Map::oid2str ( const OID & oid)

Definition at line 69 of file oid_map.cpp.

69 {
70 if(auto name = lookup_static_oid(oid)) {
71 return std::string(*name);
72 }
73
75
76 auto i = m_oid2str.find(oid);
77 if(i != m_oid2str.end()) {
78 return i->second;
79 }
80
81 return "";
82}

References Botan::lock().

Referenced by Botan::OID::human_name_or_empty().

◆ str2oid()

OID Botan::OID_Map::str2oid ( std::string_view str)

Definition at line 84 of file oid_map.cpp.

84 {
85 if(auto oid = lookup_static_oid_name(str)) {
86 return std::move(*oid);
87 }
88
90 auto i = m_str2oid.find(std::string(str));
91 if(i != m_str2oid.end()) {
92 return i->second;
93 }
94
95 return OID();
96}

References Botan::lock().

Referenced by Botan::OID::from_name(), and Botan::OID::from_string().


The documentation for this class was generated from the following files: