--- a/src/lib/ASN1ContentHandler.h Sat Jun 12 20:43:07 2021 +0200
+++ b/src/lib/ASN1ContentHandler.h Sat Jun 12 21:29:18 2021 +0200
@@ -27,11 +27,50 @@
class ASN1ContentHandler {
public:
+ enum class CollectionType {
+ Sequence,
+ Set
+ };
+
+ enum class StringType {
+ OctetString,
+ UTF8String,
+ NumericString,
+ PrintableString,
+ T61String,
+ VideotexString,
+ IA5String,
+ GraphicString,
+ VisibleString,
+ GeneralString,
+ UniversalString,
+ CharacterString,
+ BMPString,
+ };
+
virtual ~ASN1ContentHandler() = default;
- virtual void abc() = 0; // FIXME: remove dummy method
- virtual void def(int a) = 0; // FIXME: remove dummy method
- virtual void ghi(int a, int b) = 0; // FIXME: remove dummy method
+ virtual void writeCollectionStart(CollectionType type) = 0;
+ virtual void writeCollectionEnd() = 0;
+ virtual void writeBoolean(bool value) = 0;
+ virtual void writeNull() = 0;
+ virtual void writeInteger(int64_t value) = 0;
+ virtual void writeString(StringType type, std::string value) = 0;
+ // virtual void writeOID(std::string value) = 0;
+ // Object descriptor
+ // virtual void writeReal(float value) = 0;
+ // Enumerated
+ // Embedded PVD
+ // Relative OID
+ // TIME
+ // UTC time
+ // Generalized time
+ // Date
+ // Time of day
+ // Date-time
+ // Duration
+ // OID-IRI
+ // Relative OID-IRI
};
@@ -46,16 +85,28 @@
#define handler for (auto ___h : handlers) ___h
- void abc() override {
- handler->abc();
+ void writeCollectionStart(CollectionType type) {
+ handler->writeCollectionStart(type);
+ }
+
+ void writeCollectionEnd() {
+ handler->writeCollectionEnd();
}
- void def(int a) override {
- handler->def(a);
+ void writeBoolean(bool value) {
+ handler->writeBoolean(value);
}
- void ghi(int a, int b) override {
- handler->ghi(a, b);
+ void writeNull() {
+ handler->writeNull();
+ }
+
+ void writeInteger(int64_t value) {
+ handler->writeInteger(value);
+ }
+
+ void writeString(StringType type, std::string value) {
+ handler->writeString(type, value);
}
#undef handler
--- a/src/lib/BasicASN1Reader.h Sat Jun 12 20:43:07 2021 +0200
+++ b/src/lib/BasicASN1Reader.h Sat Jun 12 21:29:18 2021 +0200
@@ -44,7 +44,7 @@
void update() override {
- handlers.abc();
+ handlers.writeNull();
if (state == State::A) {
--- a/src/lib/GenericASN1ContentHandler.h Sat Jun 12 20:43:07 2021 +0200
+++ b/src/lib/GenericASN1ContentHandler.h Sat Jun 12 21:29:18 2021 +0200
@@ -41,15 +41,29 @@
virtual ~GenericASN1ContentHandler() {
}
- void abc() override {
- handlers.writeComment("abc");
- };
+ void writeCollectionStart(CollectionType type) override {
+ handlers.writeComment("collection start");
+ }
+
+ void writeCollectionEnd() override {
+ handlers.writeComment("collection end");
+ }
+
+ void writeBoolean(bool value) override {
+ handlers.writeComment("boolean");
+ }
- void def(int a) override {
- };
+ void writeNull() override {
+ handlers.writeComment("null");
+ }
- void ghi(int a, int b) override {
- };
+ void writeInteger(int64_t value) override {
+ handlers.writeComment("integer");
+ }
+
+ void writeString(StringType type, std::string value) override {
+ handlers.writeComment("string");
+ }
};