Added writeUnsignedDecimalIntDTagElement
diff --git a/ndn-cpp/c/encoding/BinaryXMLEncoder.c b/ndn-cpp/c/encoding/BinaryXMLEncoder.c
index 049cc44..a618abf 100644
--- a/ndn-cpp/c/encoding/BinaryXMLEncoder.c
+++ b/ndn-cpp/c/encoding/BinaryXMLEncoder.c
@@ -200,6 +200,7 @@
return error;
// Don't use memcpy to shift because its behavior is not guaranteed when the buffers overlap.
+ // We are shifting forward, so start from the end of the buffer.
unsigned char *source = self->output.array + startOffset + nIntegerBytes - 1;
unsigned char *dest = source + nHeaderBytes;
unsigned char *sourceFinal = self->output.array + startOffset;
@@ -215,3 +216,18 @@
return 0;
}
+
+ndn_Error ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement(struct ndn_BinaryXMLEncoder *self, unsigned int tag, unsigned int value)
+{
+ ndn_Error error;
+ if (error = ndn_BinaryXMLEncoder_writeElementStartDTag(self, tag))
+ return error;
+
+ if (error = ndn_BinaryXMLEncoder_writeUnsignedDecimalInt(self, value))
+ return error;
+
+ if (error = ndn_BinaryXMLEncoder_writeElementClose(self))
+ return error;
+
+ return 0;
+}
diff --git a/ndn-cpp/c/encoding/BinaryXMLEncoder.h b/ndn-cpp/c/encoding/BinaryXMLEncoder.h
index 66d28e7..a0f288f 100644
--- a/ndn-cpp/c/encoding/BinaryXMLEncoder.h
+++ b/ndn-cpp/c/encoding/BinaryXMLEncoder.h
@@ -86,13 +86,24 @@
ndn_Error ndn_BinaryXMLEncoder_writeBlobDTagElement(struct ndn_BinaryXMLEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength);
/**
- * Write a UDATA header, then the value as an unsigned decimal int.
+ * Write a UDATA header, then the value as an unsigned decimal integer.
* @param self pointer to the ndn_BinaryXMLEncoder struct
* @param value the unsigned int
* @return 0 for success, else an error code
*/
ndn_Error ndn_BinaryXMLEncoder_writeUnsignedDecimalInt(struct ndn_BinaryXMLEncoder *self, unsigned int value);
+/**
+ * Write an element start header using DTAG with the tag to self->output, then the value as an unsigned decimal integer,
+ * then an element close.
+ * (If you want to just write the integer, use ndn_BinaryXMLEncoder_writeUnsignedDecimalInt .)
+ * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param tag the DTAG tag
+ * @param value the unsigned int
+ * @return 0 for success, else an error code
+ */
+ndn_Error ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement(struct ndn_BinaryXMLEncoder *self, unsigned int tag, unsigned int value);
+
#ifdef __cplusplus
}
#endif