Added ElementListener
diff --git a/ndn-cpp/encoding/BinaryXMLElementReader.cpp b/ndn-cpp/encoding/BinaryXMLElementReader.cpp
new file mode 100644
index 0000000..7658483
--- /dev/null
+++ b/ndn-cpp/encoding/BinaryXMLElementReader.cpp
@@ -0,0 +1,15 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#include "BinaryXMLElementReader.hpp"
+
+namespace ndn {
+
+void ElementListener::staticOnReceivedElement(struct ndn_ElementListener *self, unsigned char *element, unsigned int elementLength)
+{
+ ((ElementListener *)self)->onReceivedElement(element, elementLength);
+}
+
+}
diff --git a/ndn-cpp/encoding/BinaryXMLElementReader.hpp b/ndn-cpp/encoding/BinaryXMLElementReader.hpp
new file mode 100644
index 0000000..7a09679
--- /dev/null
+++ b/ndn-cpp/encoding/BinaryXMLElementReader.hpp
@@ -0,0 +1,44 @@
+/**
+ * @author: Jeff Thompson
+ * See COPYING for copyright and distribution information.
+ */
+
+#ifndef NDN_BINARYXMLELEMENTREADER_HPP
+#define NDN_BINARYXMLELEMENTREADER_HPP
+
+#include "../c/encoding/BinaryXMLElementReader.h"
+
+namespace ndn {
+
+/**
+ * An ElementListener extends an ndn_ElementListener struct to proved an abstract virtual onReceivedElement function which wraps
+ * the onReceivedElement used by the ndn_ElementListener struct. You must extend this class to override onReceivedElement.
+ */
+class ElementListener : private ndn_ElementListener {
+public:
+ ElementListener()
+ {
+ ndn_ElementListener_init(this, staticOnReceivedElement);
+ }
+
+ /**
+ * This is called when an entire binary XML element is received. You must extend this class to override this method.
+ * @param element pointer to the binary XML element. This buffer is only valid during this call. If you need the data
+ * later, you must copy.
+ * @param elementLength length of element
+ */
+ virtual void onReceivedElement(unsigned char *element, unsigned int elementLength) = 0;
+
+private:
+ /**
+ * Call the virtual method onReceivedElement. This is used to initialize the base ndn_ElementListener struct.
+ * @param self
+ * @param element
+ * @param elementLength
+ */
+ static void staticOnReceivedElement(struct ndn_ElementListener *self, unsigned char *element, unsigned int elementLength);
+};
+
+}
+
+#endif