/src/botan/build/include/botan/asn1_str.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * ASN.1 string type |
3 | | * (C) 1999-2010 Jack Lloyd |
4 | | * |
5 | | * Botan is released under the Simplified BSD License (see license.txt) |
6 | | */ |
7 | | |
8 | | #ifndef BOTAN_ASN1_STRING_H_ |
9 | | #define BOTAN_ASN1_STRING_H_ |
10 | | |
11 | | #include <botan/asn1_obj.h> |
12 | | |
13 | | namespace Botan { |
14 | | |
15 | | /** |
16 | | * ASN.1 string type |
17 | | * This class normalizes all inputs to a UTF-8 std::string |
18 | | */ |
19 | | class BOTAN_PUBLIC_API(2,0) ASN1_String final : public ASN1_Object |
20 | | { |
21 | | public: |
22 | | void encode_into(class DER_Encoder&) const override; |
23 | | void decode_from(class BER_Decoder&) override; |
24 | | |
25 | 1.06k | ASN1_Tag tagging() const { return m_tag; } |
26 | | |
27 | 269k | const std::string& value() const { return m_utf8_str; } |
28 | | |
29 | 0 | size_t size() const { return value().size(); } |
30 | | |
31 | 110k | bool empty() const { return m_utf8_str.empty(); } |
32 | | |
33 | | std::string BOTAN_DEPRECATED("Use value() to get UTF-8 string instead") |
34 | | iso_8859() const; |
35 | | |
36 | | /** |
37 | | * Return true iff this is a tag for a known string type we can handle. |
38 | | * This ignores string types that are not supported, eg teletexString |
39 | | */ |
40 | | static bool is_string_type(ASN1_Tag tag); |
41 | | |
42 | | bool operator==(const ASN1_String& other) const |
43 | 0 | { return value() == other.value(); } |
44 | | |
45 | | explicit ASN1_String(const std::string& utf8 = ""); |
46 | | ASN1_String(const std::string& utf8, ASN1_Tag tag); |
47 | | private: |
48 | | std::vector<uint8_t> m_data; |
49 | | std::string m_utf8_str; |
50 | | ASN1_Tag m_tag; |
51 | | }; |
52 | | |
53 | | } |
54 | | |
55 | | #endif |