/src/Botan-3.4.0/build/include/public/botan/oids.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * OID Registry |
3 | | * (C) 1999-2007 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_OIDS_H_ |
9 | | #define BOTAN_OIDS_H_ |
10 | | |
11 | | #include <botan/asn1_obj.h> |
12 | | |
13 | | BOTAN_DEPRECATED_HEADER("oids.h") |
14 | | |
15 | | namespace Botan::OIDS { |
16 | | |
17 | | /** |
18 | | * Register an OID to string mapping. |
19 | | * @param oid the oid to register |
20 | | * @param name the name to be associated with the oid |
21 | | */ |
22 | | BOTAN_DEPRECATED("Use OID::register_oid") |
23 | | |
24 | 0 | inline void add_oid(const OID& oid, std::string_view name) { |
25 | 0 | OID::register_oid(oid, name); |
26 | 0 | } |
27 | | |
28 | | BOTAN_DEPRECATED("Use OID::register_oid") |
29 | | BOTAN_UNSTABLE_API |
30 | | void add_oid2str(const OID& oid, std::string_view name); |
31 | | |
32 | | BOTAN_DEPRECATED("Use OID::register_oid") |
33 | | BOTAN_UNSTABLE_API |
34 | | void add_str2oid(const OID& oid, std::string_view name); |
35 | | |
36 | | BOTAN_DEPRECATED("Use OID::register_oid") |
37 | | |
38 | 0 | inline void add_oidstr(const char* oidstr, const char* name) { |
39 | 0 | OID::register_oid(OID(oidstr), name); |
40 | 0 | } |
41 | | |
42 | | /** |
43 | | * Resolve an OID |
44 | | * @param oid the OID to look up |
45 | | * @return name associated with this OID, or an empty string |
46 | | */ |
47 | | BOTAN_DEPRECATED("Use OID::human_name_or_empty") |
48 | | |
49 | 0 | inline std::string oid2str_or_empty(const OID& oid) { |
50 | 0 | return oid.human_name_or_empty(); |
51 | 0 | } |
52 | | |
53 | | /** |
54 | | * Find the OID to a name. The lookup will be performed in the |
55 | | * general OID section of the configuration. |
56 | | * @param name the name to resolve |
57 | | * @return OID associated with the specified name |
58 | | */ |
59 | | BOTAN_DEPRECATED("Use OID::from_name") |
60 | | |
61 | 0 | inline OID str2oid_or_empty(std::string_view name) { |
62 | 0 | return OID::from_name(name).value_or(OID()); |
63 | 0 | } |
64 | | |
65 | | BOTAN_DEPRECATED("Use OID::human_name_or_empty") |
66 | | |
67 | 0 | inline std::string oid2str_or_throw(const OID& oid) { |
68 | 0 | std::string s = oid.human_name_or_empty(); |
69 | 0 | if(s.empty()) { |
70 | 0 | throw Lookup_Error("No name associated with OID " + oid.to_string()); |
71 | 0 | } |
72 | 0 | return s; |
73 | 0 | } |
74 | | |
75 | | BOTAN_DEPRECATED("Use OID::human_name_or_empty") |
76 | | |
77 | 0 | inline std::string lookup(const OID& oid) { |
78 | 0 | return oid.human_name_or_empty(); |
79 | 0 | } |
80 | | |
81 | | BOTAN_DEPRECATED("Use OID::from_name") |
82 | | |
83 | 0 | inline OID lookup(std::string_view name) { |
84 | 0 | return OID::from_name(name).value_or(OID()); |
85 | 0 | } |
86 | | |
87 | | } // namespace Botan::OIDS |
88 | | |
89 | | #endif |