Botan  2.11.0
Crypto and TLS for C++11
asn1_oid.h
Go to the documentation of this file.
1 /*
2 * ASN.1 OID
3 * (C) 1999-2007 Jack Lloyd
4 *
5 * Botan is released under the Simplified BSD License (see license.txt)
6 */
7 
8 #ifndef BOTAN_ASN1_OID_H_
9 #define BOTAN_ASN1_OID_H_
10 
11 #include <botan/asn1_obj.h>
12 #include <string>
13 #include <vector>
14 
15 namespace Botan {
16 
17 /**
18 * This class represents ASN.1 object identifiers.
19 */
20 class BOTAN_PUBLIC_API(2,0) OID final : public ASN1_Object
21  {
22  public:
23  void encode_into(class DER_Encoder&) const override;
24  void decode_from(class BER_Decoder&) override;
25 
26  /**
27  * Find out whether this OID is empty
28  * @return true is no OID value is set
29  */
30  bool empty() const { return m_id.empty(); }
31 
32  /**
33  * Find out whether this OID has a value
34  * @return true is this OID has a value
35  */
36  bool has_value() const { return (m_id.empty() == false); }
37 
38  /**
39  * Get this OID as list (vector) of its components.
40  * @return vector representing this OID
41  */
42  const std::vector<uint32_t>& get_id() const { return m_id; }
43 
44  /**
45  * Get this OID as a string
46  * @return string representing this OID
47  */
48  std::string BOTAN_DEPRECATED("Use OID::to_string") as_string() const
49  {
50  return this->to_string();
51  }
52 
53  /**
54  * Get this OID as a string
55  * @return string representing this OID
56  */
57  std::string to_string() const;
58 
59  /**
60  * Compare two OIDs.
61  * @return true if they are equal, false otherwise
62  */
63  bool operator==(const OID&) const;
64 
65  /**
66  * Reset this instance to an empty OID.
67  */
68  void clear();
69 
70  /**
71  * Add a component to this OID.
72  * @param new_comp the new component to add to the end of this OID
73  * @return reference to *this
74  */
75  OID& operator+=(uint32_t new_comp);
76 
77  /**
78  * Construct an OID from a string.
79  * @param str a string in the form "a.b.c" etc., where a,b,c are numbers
80  */
81  explicit OID(const std::string& str = "");
82 
83  explicit OID(std::initializer_list<uint32_t> init) : m_id(init) {}
84  private:
85  std::vector<uint32_t> m_id;
86  };
87 
88 /**
89 * Append another component onto the OID.
90 * @param oid the OID to add the new component to
91 * @param new_comp the new component to add
92 */
93 OID BOTAN_PUBLIC_API(2,0) operator+(const OID& oid, uint32_t new_comp);
94 
95 /**
96 * Compare two OIDs.
97 * @param a the first OID
98 * @param b the second OID
99 * @return true if a is not equal to b
100 */
101 bool BOTAN_PUBLIC_API(2,0) operator!=(const OID& a, const OID& b);
102 
103 /**
104 * Compare two OIDs.
105 * @param a the first OID
106 * @param b the second OID
107 * @return true if a is lexicographically smaller than b
108 */
109 bool BOTAN_PUBLIC_API(2,0) operator<(const OID& a, const OID& b);
110 
111 }
112 
113 #endif
bool const OID & b
Definition: asn1_oid.h:109
int(* final)(unsigned char *, CTX *)
std::string to_string(ErrorType type)
Definition: exceptn.cpp:11
size_t const BigInt & a
Definition: numthry.h:111
class BOTAN_PUBLIC_API(2, 0) OID final OID uint32_t new_comp
Definition: asn1_oid.h:93
const char * str
Definition: ffi.h:769
std::vector< T, Alloc > & operator+=(std::vector< T, Alloc > &out, const std::vector< T, Alloc2 > &in)
Definition: secmem.h:110
Definition: alg_id.cpp:13
class BOTAN_PUBLIC_API(2, 0) AlgorithmIdentifier final bool BOTAN_PUBLIC_API(2, 0) operator
Name Constraints.
Definition: asn1_obj.h:66
int(* init)(CTX *)
bool operator==(const AlgorithmIdentifier &a1, const AlgorithmIdentifier &a2)
Definition: alg_id.cpp:75