src/lib/ASN1ContentHandler.h
branchv_0
changeset 24 114810ee2386
parent 23 8941a679299f
child 25 ba79cebde109
--- a/src/lib/ASN1ContentHandler.h	Fri Jul 02 00:42:01 2021 +0200
+++ b/src/lib/ASN1ContentHandler.h	Sat Jul 03 18:56:15 2021 +0200
@@ -22,6 +22,8 @@
 #include <iomanip>
 #include <cmath>
 
+#include "ProxyVector.h"
+
 namespace relpipe {
 namespace in {
 namespace asn1 {
@@ -264,65 +266,61 @@
 
 class ASN1ContentHandlerProxy : public ASN1ContentHandler {
 private:
-	std::vector<std::shared_ptr<ASN1ContentHandler>> handlers;
+	ProxyVector<ASN1ContentHandler> handlers;
 public:
 
 	void addHandler(std::shared_ptr<ASN1ContentHandler> handler) {
 		handlers.push_back(handler);
 	}
 
-#define handler for (auto ___h : handlers) ___h
-
 	void writeStreamStart() override {
-		handler->writeStreamStart();
+		handlers.forward(&ASN1ContentHandler::writeStreamStart);
 	}
 
 	void writeStreamEnd() override {
-		handler->writeStreamEnd();
+		handlers.forward(&ASN1ContentHandler::writeStreamEnd);
 	}
 
 	void writeCollectionStart(CollectionType type) override {
-		handler->writeCollectionStart(type);
+		handlers.forward(&ASN1ContentHandler::writeCollectionStart, type);
 	}
 
 	void writeCollectionEnd() override {
-		handler->writeCollectionEnd();
+		handlers.forward(&ASN1ContentHandler::writeCollectionEnd);
 	}
 
 	void writeBoolean(bool value) override {
-		handler->writeBoolean(value);
+		handlers.forward(&ASN1ContentHandler::writeBoolean, value);
 	}
 
 	void writeNull() override {
-		handler->writeNull();
+		handlers.forward(&ASN1ContentHandler::writeNull);
 	}
 
 	void writeInteger(Integer value) override {
-		handler->writeInteger(value);
+		handlers.forward(&ASN1ContentHandler::writeInteger, value);
 	}
 
 	void writeTextString(StringType type, std::string value) override {
-		handler->writeTextString(type, value);
+		handlers.forward(&ASN1ContentHandler::writeTextString, type, value);
 	}
 
 	void writeOctetString(std::string value) override {
-		handler->writeOctetString(value);
+		handlers.forward(&ASN1ContentHandler::writeOctetString, value);
 	}
 
 	void writeBitString(std::vector<bool> value) override {
-		handler->writeBitString(value);
+		handlers.forward(&ASN1ContentHandler::writeBitString, value);
 	}
 
 	void writeOID(ObjectIdentifier value) override {
-		handler->writeOID(value);
+		handlers.forward(&ASN1ContentHandler::writeOID, value);
 	}
 
 	void writeDateTime(DateTimeType type, DateTime value) override {
-		handler->writeDateTime(type, value);
+		handlers.forward(&ASN1ContentHandler::writeDateTime, type, value);
 	}
 
-#undef handler
-
 };