Added support for ContentObject
diff --git a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
index f3af9c8..83261de 100644
--- a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
+++ b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
@@ -6,7 +6,9 @@
#include <stdexcept>
#include "../c/encoding/BinaryXMLName.h"
#include "../c/encoding/BinaryXMLInterest.h"
+#include "../c/encoding/BinaryXMLContentObject.h"
#include "../Interest.hpp"
+#include "../ContentObject.hpp"
#include "BinaryXMLEncoder.hpp"
#include "../c/encoding/BinaryXMLDecoder.h"
#include "BinaryXMLWireFormat.hpp"
@@ -81,4 +83,35 @@
interest.set(interestStruct);
}
+void BinaryXMLWireFormat::encodeContentObject(const ContentObject &contentObject, vector<unsigned char> &output)
+{
+ struct ndn_NameComponent nameComponents[100];
+ struct ndn_ContentObject contentObjectStruct;
+ ndn_ContentObject_init
+ (&contentObjectStruct, nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
+ contentObject.get(contentObjectStruct);
+
+ BinaryXMLEncoder encoder;
+ ndn_encodeBinaryXMLContentObject(&contentObjectStruct, encoder.getEncoder());
+
+ encoder.appendTo(output);
+}
+
+void BinaryXMLWireFormat::decodeContentObject(ContentObject &contentObject, const unsigned char *input, unsigned int inputLength)
+{
+ struct ndn_NameComponent nameComponents[100];
+ struct ndn_ContentObject contentObjectStruct;
+ ndn_ContentObject_init
+ (&contentObjectStruct, nameComponents, sizeof(nameComponents) / sizeof(nameComponents[0]));
+
+ struct ndn_BinaryXMLDecoder decoder;
+ ndn_BinaryXMLDecoder_init(&decoder, (unsigned char *)input, inputLength);
+
+ ndn_Error error;
+ if (error = ndn_decodeBinaryXMLContentObject(&contentObjectStruct, &decoder))
+ throw std::runtime_error(ndn_getErrorString(error));
+
+ contentObject.set(contentObjectStruct);
+}
+
}