equal
deleted
inserted
replaced
34 */ |
34 */ |
35 class BasicASN1Reader : public ASN1Reader { |
35 class BasicASN1Reader : public ASN1Reader { |
36 private: |
36 private: |
37 |
37 |
38 bool started = false; |
38 bool started = false; |
39 |
|
40 enum class TagClass : uint8_t { |
|
41 Universal = 0, |
|
42 Application = 1, |
|
43 ContextSpecific = 2, |
|
44 Private = 3 |
|
45 }; |
|
46 |
|
47 enum class PC : uint8_t { |
|
48 Primitive = 0, |
|
49 Constructed = 1 |
|
50 }; |
|
51 |
39 |
52 enum UniversalType : uint64_t { |
40 enum UniversalType : uint64_t { |
53 EndOfContent = 0x00, |
41 EndOfContent = 0x00, |
54 Boolean = 0x01, |
42 Boolean = 0x01, |
55 Integer = 0x02, |
43 Integer = 0x02, |
87 Duration = 0x22, |
75 Duration = 0x22, |
88 ObjectIdentifierIRI = 0x23, |
76 ObjectIdentifierIRI = 0x23, |
89 RelativeObjectIdentifierIRI = 0x24, |
77 RelativeObjectIdentifierIRI = 0x24, |
90 }; |
78 }; |
91 |
79 |
92 class Header { |
80 class BasicHeader : public ASN1ContentHandler::Header { |
93 public: |
81 public: |
94 TagClass tagClass; |
|
95 PC pc; |
|
96 uint64_t tag; |
|
97 bool definiteLength; |
82 bool definiteLength; |
98 size_t length; |
83 size_t length; |
99 }; |
84 }; |
100 |
85 |
101 class LevelMetadata { |
86 class LevelMetadata { |
116 checkRemainingItems(); // multiple collections may end at the same point |
101 checkRemainingItems(); // multiple collections may end at the same point |
117 } |
102 } |
118 } |
103 } |
119 } |
104 } |
120 |
105 |
121 Header readHeader() { |
106 BasicHeader readHeader() { |
122 Header h; |
107 using TagClass = ASN1ContentHandler::TagClass; |
|
108 using PC = ASN1ContentHandler::PC; |
|
109 |
|
110 BasicHeader h; |
123 |
111 |
124 memset(&h, 0, sizeof (h)); // TODO: remove, not needed |
112 memset(&h, 0, sizeof (h)); // TODO: remove, not needed |
125 |
113 |
126 uint8_t tagByte; |
114 uint8_t tagByte; |
127 read(&tagByte, 1); |
115 read(&tagByte, 1); |
162 |
150 |
163 return h; |
151 return h; |
164 } |
152 } |
165 |
153 |
166 void readNext() { |
154 void readNext() { |
|
155 using TagClass = ASN1ContentHandler::TagClass; |
|
156 using PC = ASN1ContentHandler::PC; |
|
157 |
167 checkRemainingItems(); |
158 checkRemainingItems(); |
168 Header typeHeader = readHeader(); |
159 BasicHeader typeHeader = readHeader(); |
169 // commit(); // TODO: commit here and recover later instead of rollback? |
160 // commit(); // TODO: commit here and recover later instead of rollback? |
170 |
161 |
171 if (!started) { |
162 if (!started) { |
172 handlers.writeStreamStart(); |
163 handlers.writeStreamStart(); |
173 started = true; |
164 started = true; |