src/lib/ASN1ContentHandler.h
branchv_0
changeset 26 e39de9b8b3a1
parent 25 ba79cebde109
child 27 d9cc2d356cdb
--- a/src/lib/ASN1ContentHandler.h	Sat Jul 03 20:17:17 2021 +0200
+++ b/src/lib/ASN1ContentHandler.h	Sun Jul 04 11:37:27 2021 +0200
@@ -29,6 +29,46 @@
 namespace asn1 {
 namespace lib {
 
+namespace UniversalType {
+static const uint64_t EndOfContent = 0x00;
+static const uint64_t Boolean = 0x01;
+static const uint64_t Integer = 0x02;
+static const uint64_t BitString = 0x03;
+static const uint64_t OctetString = 0x04;
+static const uint64_t Null = 0x05;
+static const uint64_t ObjectIdentifier = 0x06;
+static const uint64_t ObjectDescriptor = 0x07;
+static const uint64_t External = 0x08;
+static const uint64_t Real = 0x09;
+static const uint64_t Enumerated = 0xA;
+static const uint64_t Embedded = 0xB;
+static const uint64_t UTF8String = 0xC;
+static const uint64_t RelativeObjectIdentifier = 0xD;
+static const uint64_t Time = 0xE;
+static const uint64_t Reserved = 0xF;
+static const uint64_t Sequence = 0x10;
+static const uint64_t Set = 0x11;
+static const uint64_t NumericString = 0x12;
+static const uint64_t PrintableString = 0x13;
+static const uint64_t T61String = 0x14;
+static const uint64_t VideotexString = 0x15;
+static const uint64_t IA5String = 0x16;
+static const uint64_t UTCTime = 0x17;
+static const uint64_t GeneralizedTime = 0x18;
+static const uint64_t GraphicString = 0x19;
+static const uint64_t VisibleString = 0x1A;
+static const uint64_t GeneralString = 0x1B;
+static const uint64_t UniversalString = 0x1C;
+static const uint64_t CharacterString = 0x1D;
+static const uint64_t BMPString = 0x1E;
+static const uint64_t Date = 0x1F;
+static const uint64_t TimeOfDay = 0x20;
+static const uint64_t DateTime = 0x21;
+static const uint64_t Duration = 0x22;
+static const uint64_t ObjectIdentifierIRI = 0x23;
+static const uint64_t RelativeObjectIdentifierIRI = 0x24;
+}
+
 class ASN1ContentHandler {
 public:
 
@@ -51,12 +91,6 @@
 		uint64_t tag;
 	};
 
-	enum class CollectionType : uint64_t {
-		Constructed, // TODO: special event?
-		Sequence = 16,
-		Set = 17
-	};
-
 	enum class StringType : uint64_t {
 		UTF8String = 0xC,
 		NumericString = 0x12,
@@ -83,6 +117,9 @@
 		// TODO: review date/time types
 	};
 
+
+	// TODO: separate implementation of particular types from the interface, separate SPI from API?
+
 	class Integer {
 	private:
 		// TODO: use std::string (of octets, not ASCII) instead of std::vector?
@@ -253,7 +290,7 @@
 	virtual void writeStreamStart() = 0;
 	virtual void writeStreamEnd() = 0;
 
-	virtual void writeCollectionStart(CollectionType type) = 0;
+	virtual void writeCollectionStart(const Header& header) = 0;
 	virtual void writeCollectionEnd() = 0;
 	virtual void writeBoolean(bool value) = 0;
 	virtual void writeNull() = 0;
@@ -300,8 +337,8 @@
 		handlers.forward(&ASN1ContentHandler::writeStreamEnd);
 	}
 
-	void writeCollectionStart(CollectionType type) override {
-		handlers.forward(&ASN1ContentHandler::writeCollectionStart, type);
+	void writeCollectionStart(const Header& header) override {
+		handlers.forward(&ASN1ContentHandler::writeCollectionStart, header);
 	}
 
 	void writeCollectionEnd() override {