1 #ifndef ASN1_CER_STREAM_H
2 #define ASN1_CER_STREAM_H
14 enum TokType { seq_tok, endseq_tok, restseq_tok, expl_tok, peekexpl_tok, endexpl_tok, opt_tok, endopt_tok };
15 explicit Token(TokType t) { type = t; }
16 virtual ~
Token() =
default;
29 explicit ExplicitToken(uint8_t token_tag, ASN1_Class token_tag_class = kAsn1Context)
30 :
Token(expl_tok), tag(token_tag), tag_class(token_tag_class) {}
38 explicit PeekExplicitToken(uint8_t* token_tag =
nullptr, ASN1_Class* token_tag_class =
nullptr)
39 :
Token(peekexpl_tok), tag(token_tag), tag_class(token_tag_class) {}
42 ASN1_Class* tag_class;
47 const Token restseq =
Token(Token::restseq_tok);
48 const Token endexpl =
Token(Token::endexpl_tok);
54 template <ASN1_UniversalTag Tag,
typename =
void>
57 template <ASN1_UniversalTag Tag>
64 template <ASN1_UniversalTag Tag>
71 template <ASN1_UniversalTag Tag>
78 template <ASN1_UniversalTag Tag>
85 template <ASN1_UniversalTag Tag>
92 template <ASN1_UniversalTag Tag>
95 const std::string&
data;
99 template <ASN1_UniversalTag Tag,
typename T>
106 const std::string& getResult() {
return result; }
110 Serializer& operator<<(
const std::string& val);
111 Serializer& operator<<(ASN1_UniversalTag tag);
116 ASN1_UniversalTag last_type{kUnknown};
119 template <ASN1_UniversalTag Tag,
typename T>
121 ser << Tag << imp.data;
135 const std::string& getData() {
return data; }
139 std::stack<int32_t> seq_lengths;
140 std::stack<int32_t> seq_consumed;
141 int32_t int_param{0};
142 std::string string_param;
144 int32_t opt_count{0};
145 bool opt_first{
false};
146 bool opt_present{
false};
149 template <ASN1_UniversalTag Tag,
typename T>
151 des >> Tag >> imp.data;
156 #endif // ASN1_CER_STREAM_H