Change BinaryXMLEncoder to extend ndn_BinaryXMLEncoder
diff --git a/ndn-cpp/encoding/BinaryXMLEncoder.hpp b/ndn-cpp/encoding/BinaryXMLEncoder.hpp
index bb703b6..c1f8a1f 100644
--- a/ndn-cpp/encoding/BinaryXMLEncoder.hpp
+++ b/ndn-cpp/encoding/BinaryXMLEncoder.hpp
@@ -14,9 +14,9 @@
namespace ndn {
/**
- * A BinaryXMLEncoder wraps a C ndn_BinaryXMLEncoder struct and related functions.
+ * A BinaryXMLEncoder extends a C ndn_BinaryXMLEncoder struct and wraps related functions.
*/
-class BinaryXMLEncoder {
+class BinaryXMLEncoder : public ndn_BinaryXMLEncoder {
public:
/**
* Initialize the base ndn_BinaryXMLEncoder struct with an initial array of 16 bytes. Use simpleRealloc.
@@ -24,7 +24,7 @@
BinaryXMLEncoder()
{
const unsigned int initialLength = 16;
- ndn_BinaryXMLEncoder_init(&encoder_, (unsigned char *)malloc(initialLength), initialLength, simpleRealloc);
+ ndn_BinaryXMLEncoder_init(this, (unsigned char *)malloc(initialLength), initialLength, simpleRealloc);
}
/**
@@ -39,22 +39,13 @@
}
/**
- * Return a pointer to the base ndn_BinaryXMLEncoder struct.
- * @return
- */
- struct ndn_BinaryXMLEncoder *getEncoder() { return &encoder_; }
-
- /**
* Copy the encoded bytes to the end of the buffer.
* @param buffer a vector to receive the copy
*/
void appendTo(std::vector<unsigned char> &buffer)
{
- buffer.insert(buffer.end(), encoder_.output.array, encoder_.output.array + encoder_.offset);
+ buffer.insert(buffer.end(), this->output.array, this->output.array + this->offset);
}
-
-private:
- struct ndn_BinaryXMLEncoder encoder_;
};
}
diff --git a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
index 83261de..df5ad35 100644
--- a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
+++ b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
@@ -27,7 +27,7 @@
name.get(nameStruct);
BinaryXMLEncoder encoder;
- ndn_encodeBinaryXMLName(&nameStruct, encoder.getEncoder());
+ ndn_encodeBinaryXMLName(&nameStruct, &encoder);
encoder.appendTo(output);
}
@@ -59,7 +59,7 @@
interest.get(interestStruct);
BinaryXMLEncoder encoder;
- ndn_encodeBinaryXMLInterest(&interestStruct, encoder.getEncoder());
+ ndn_encodeBinaryXMLInterest(&interestStruct, &encoder);
encoder.appendTo(output);
}
@@ -92,7 +92,7 @@
contentObject.get(contentObjectStruct);
BinaryXMLEncoder encoder;
- ndn_encodeBinaryXMLContentObject(&contentObjectStruct, encoder.getEncoder());
+ ndn_encodeBinaryXMLContentObject(&contentObjectStruct, &encoder);
encoder.appendTo(output);
}