Implement writeElementStartDTag, writeBlobDTagElement, etc.
diff --git a/ndn-cpp/c/encoding/BinaryXMLEncoder.h b/ndn-cpp/c/encoding/BinaryXMLEncoder.h
index e606dee..8c5047c 100644
--- a/ndn-cpp/c/encoding/BinaryXMLEncoder.h
+++ b/ndn-cpp/c/encoding/BinaryXMLEncoder.h
@@ -8,11 +8,15 @@
#define NDN_BINARYXMLENCODER_H
#include "../util/DynamicUCharArray.h"
+#include "BinaryXML.h"
#ifdef __cplusplus
extern "C" {
#endif
+/** An ndn_BinaryXMLEncoder struct is used by all the encoding functions. You should initialize it with
+ * ndn_BinaryXMLEncoder_init.
+ */
struct ndn_BinaryXMLEncoder {
struct ndn_DynamicUCharArray output; /**< receives the encoded output */
unsigned int offset; /**< the offset into output.array for the next encoding */
@@ -28,14 +32,59 @@
*/
static inline void ndn_BinaryXMLEncoder_init
(struct ndn_BinaryXMLEncoder *self, unsigned char *outputArray, unsigned int outputArrayLength,
- unsigned char (*reallocFunction)(unsigned char *, unsigned int))
+ unsigned char * (*reallocFunction)(unsigned char *, unsigned int))
{
ndn_DynamicUCharArray_init(&self->output, outputArray, outputArrayLength, reallocFunction);
self->offset = 0;
}
+/**
+ * Encode a header with the type and value and write it to self->output.
+ * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param type the header type
+ * @param value the header value
+ * @return 0 for success, else an error string
+ */
char *ndn_BinaryXMLEncoder_encodeTypeAndValue(struct ndn_BinaryXMLEncoder *self, unsigned int type, unsigned int value);
+/**
+ * Write an element start header using DTAG with the tag to self->output.
+ * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param tag the DTAG tag
+ * @return 0 for success, else an error string
+ */
+static inline char *ndn_BinaryXMLEncoder_writeElementStartDTag(struct ndn_BinaryXMLEncoder *self, unsigned int tag)
+{
+ return ndn_BinaryXMLEncoder_encodeTypeAndValue(self, ndn_BinaryXML_DTAG, tag);
+}
+
+/**
+ * Write an element close to self->output.
+ * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @return 0 for success, else an error string
+ */
+char *ndn_BinaryXMLEncoder_writeElementClose(struct ndn_BinaryXMLEncoder *self);
+
+/**
+ * Write a BLOB header, then the bytes of the blob value to self->output.
+ * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param value an array of bytes for the blob value
+ * @param valueLength the length of the array
+ * @return 0 for success, else an error string
+ */
+char *ndn_BinaryXMLEncoder_writeBlob(struct ndn_BinaryXMLEncoder *self, unsigned char *value, unsigned int valueLength);
+
+/**
+ * Write an element start header using DTAG with the tag to self->output, then the blob, then an element close.
+ * (If you want to just write the blob, use ndn_BinaryXMLEncoder_writeBlob .)
+ * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param tag the DTAG tag
+ * @param value an array of bytes for the blob value
+ * @param valueLength the length of the array
+ * @return 0 for success, else an error string
+ */
+char *ndn_BinaryXMLEncoder_writeBlobDTagElement(struct ndn_BinaryXMLEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength);
+
#ifdef __cplusplus
}
#endif