Internal: Use C struct ndn_Blob where possible. Make ndn::Blob work with ndn_Blob.
diff --git a/ndn-cpp/c/encoding/binary-xml-encoder.h b/ndn-cpp/c/encoding/binary-xml-encoder.h
index c457185..81fa6b9 100644
--- a/ndn-cpp/c/encoding/binary-xml-encoder.h
+++ b/ndn-cpp/c/encoding/binary-xml-encoder.h
@@ -9,6 +9,7 @@
#include "../errors.h"
#include "../util/dynamic-uint8-array.h"
+#include "../util/blob.h"
#include "binary-xml.h"
#ifdef __cplusplus
@@ -66,36 +67,33 @@
/**
* 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
+ * @param value A Blob with the array of bytes for the value.
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, struct ndn_Blob *value);
/**
* 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
+ * @param value A Blob with the array of bytes for the value.
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value);
/**
* If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeBlobDTagElement.
- * @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
+ * @param self A pointer to the ndn_BinaryXmlEncoder struct.
+ * @param tag The DTAG tag.
+ * @param value A Blob with the array of bytes for the value.
* @return 0 for success, else an error code
*/
static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalBlobDTagElement
- (struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
+ (struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value)
{
- if (value && valueLength > 0)
- return ndn_BinaryXmlEncoder_writeBlobDTagElement(self, tag, value, valueLength);
+ if (value->value && value->length > 0)
+ return ndn_BinaryXmlEncoder_writeBlobDTagElement(self, tag, value);
else
return NDN_ERROR_success;
}
@@ -103,36 +101,33 @@
/**
* Write a UDATA header, then the bytes of the UDATA value to self->output.
* @param self pointer to the ndn_BinaryXmlEncoder struct
- * @param value an array of bytes for the value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeUData(struct ndn_BinaryXmlEncoder *self, struct ndn_Blob *value);
/**
* Write an element start header using DTAG with the tag to self->output, then the UDATA value, then an element close.
* (If you want to just write the UDATA value, use ndn_BinaryXmlEncoder_writeUData .)
* @param self pointer to the ndn_BinaryXmlEncoder struct
* @param tag the DTAG tag
- * @param value an array of bytes for the value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
* @return 0 for success, else an error code
*/
-ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength);
+ndn_Error ndn_BinaryXmlEncoder_writeUDataDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value);
/**
* If value or valueLen is 0 then do nothing, otherwise call ndn_BinaryXmlEncoder_writeUDataDTagElement.
* @param self pointer to the ndn_BinaryXmlEncoder struct
* @param tag the DTAG tag
- * @param value an array of bytes for the value
- * @param valueLength the length of the array
+ * @param value A Blob with the array of bytes for the value.
* @return 0 for success, else an error code
*/
static inline ndn_Error ndn_BinaryXmlEncoder_writeOptionalUDataDTagElement
- (struct ndn_BinaryXmlEncoder *self, unsigned int tag, uint8_t *value, size_t valueLength)
+ (struct ndn_BinaryXmlEncoder *self, unsigned int tag, struct ndn_Blob *value)
{
- if (value && valueLength > 0)
- return ndn_BinaryXmlEncoder_writeUDataDTagElement(self, tag, value, valueLength);
+ if (value->value && value->length > 0)
+ return ndn_BinaryXmlEncoder_writeUDataDTagElement(self, tag, value);
else
return NDN_ERROR_success;
}