Make ndn_decodeBinaryXMLName take the ndn_BinaryXMLDecoder.
diff --git a/ndn-cpp/c/encoding/BinaryXMLName.c b/ndn-cpp/c/encoding/BinaryXMLName.c
index 4e3f4d7..799e93d 100644
--- a/ndn-cpp/c/encoding/BinaryXMLName.c
+++ b/ndn-cpp/c/encoding/BinaryXMLName.c
@@ -27,18 +27,15 @@
return 0;
}
-char *ndn_decodeBinaryXMLName(struct ndn_Name *name, unsigned char *input, unsigned int inputLength)
+char *ndn_decodeBinaryXMLName(struct ndn_Name *name, struct ndn_BinaryXMLDecoder *decoder)
{
- struct ndn_BinaryXMLDecoder decoder;
- ndn_BinaryXMLDecoder_init(&decoder, input, inputLength);
-
char *error;
- if (error = ndn_BinaryXMLDecoder_readElementStartDTag(&decoder, ndn_BinaryXML_DTag_Name))
+ if (error = ndn_BinaryXMLDecoder_readElementStartDTag(decoder, ndn_BinaryXML_DTag_Name))
return error;
while (1) {
int gotExpectedTag;
- if (error = ndn_BinaryXMLDecoder_peekDTag(&decoder, ndn_BinaryXML_DTag_Component, &gotExpectedTag))
+ if (error = ndn_BinaryXMLDecoder_peekDTag(decoder, ndn_BinaryXML_DTag_Component, &gotExpectedTag))
return error;
if (!gotExpectedTag)
@@ -47,7 +44,7 @@
unsigned char *component;
unsigned int componentLen;
- if (error = ndn_BinaryXMLDecoder_readBinaryDTagElement(&decoder, ndn_BinaryXML_DTag_Component, 0, &component, &componentLen))
+ if (error = ndn_BinaryXMLDecoder_readBinaryDTagElement(decoder, ndn_BinaryXML_DTag_Component, 0, &component, &componentLen))
return error;
// Add the component to the name.
@@ -57,7 +54,7 @@
++name->nComponents;
}
- if (error = ndn_BinaryXMLDecoder_readElementClose(&decoder))
+ if (error = ndn_BinaryXMLDecoder_readElementClose(decoder))
return error;
return 0;
diff --git a/ndn-cpp/c/encoding/BinaryXMLName.h b/ndn-cpp/c/encoding/BinaryXMLName.h
index 58552c5..c943f4b 100644
--- a/ndn-cpp/c/encoding/BinaryXMLName.h
+++ b/ndn-cpp/c/encoding/BinaryXMLName.h
@@ -16,7 +16,7 @@
char *ndn_encodeBinaryXMLName(struct ndn_Name *name, struct ndn_BinaryXMLEncoder *encoder);
-char *ndn_decodeBinaryXMLName(struct ndn_Name *name, unsigned char *input, unsigned int inputLength);
+char *ndn_decodeBinaryXMLName(struct ndn_Name *name, struct ndn_BinaryXMLDecoder *decoder);
#ifdef __cplusplus
}
diff --git a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
index 5789394..e89afaf 100644
--- a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
+++ b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
@@ -9,6 +9,7 @@
#include "../c/encoding/BinaryXMLInterest.h"
#include "../Interest.hpp"
#include "BinaryXMLEncoder.hpp"
+#include "../c/encoding/BinaryXMLDecoder.h"
#include "BinaryXMLWireFormat.hpp"
using namespace std;
@@ -36,8 +37,11 @@
struct ndn_Name nameStruct;
ndn_Name_init(&nameStruct, components, sizeof(components) / sizeof(components[0]));
+ struct ndn_BinaryXMLDecoder decoder;
+ ndn_BinaryXMLDecoder_init(&decoder, (unsigned char *)input, inputLength);
+
char *error;
- if (error = ndn_decodeBinaryXMLName(&nameStruct, (unsigned char *)input, inputLength))
+ if (error = ndn_decodeBinaryXMLName(&nameStruct, &decoder))
throw std::runtime_error(error);
name.set(nameStruct);
@@ -49,8 +53,11 @@
struct ndn_Interest interestStruct;
ndn_Interest_init(&interestStruct, components, sizeof(components) / sizeof(components[0]));
+ struct ndn_BinaryXMLDecoder decoder;
+ ndn_BinaryXMLDecoder_init(&decoder, (unsigned char *)input, inputLength);
+
char *error;
- if (error = ndn_decodeBinaryXMLInterest(&interestStruct, (unsigned char *)input, inputLength))
+ if (error = ndn_decodeBinaryXMLInterest(&interestStruct, &decoder))
throw std::runtime_error(error);
interest.set(interestStruct);