Added appendTo.
diff --git a/ndn-cpp/encoding/BinaryXMLEncoder.hpp b/ndn-cpp/encoding/BinaryXMLEncoder.hpp
index de00a97..1fd4244 100644
--- a/ndn-cpp/encoding/BinaryXMLEncoder.hpp
+++ b/ndn-cpp/encoding/BinaryXMLEncoder.hpp
@@ -9,6 +9,7 @@
#include <cstdlib>
#include <stdexcept>
+#include <vector>
#include "../c/encoding/BinaryXMLEncoder.h"
namespace ndn {
@@ -44,6 +45,15 @@
*/
struct ndn_BinaryXMLEncoder *getEncoder() { return &base_; }
+ /**
+ * 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(), base_.output.array, base_.output.array + base_.offset);
+ }
+
private:
struct ndn_BinaryXMLEncoder base_;
};
diff --git a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
index a103106..e56673b 100644
--- a/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
+++ b/ndn-cpp/encoding/BinaryXMLWireFormat.cpp
@@ -25,8 +25,8 @@
BinaryXMLEncoder encoder;
ndn_encodeBinaryXMLName(&nameStruct, encoder.getEncoder());
-
- output.insert(output.end(), encoder.getEncoder()->output.array, encoder.getEncoder()->output.array + encoder.getEncoder()->offset);
+
+ encoder.appendTo(output);
}
void BinaryXMLWireFormat::decodeName(Name &name, const unsigned char *input, unsigned int inputLength)