Code style: Rename BinaryXML to BinaryXml
diff --git a/ndn-cpp/c/encoding/BinaryXMLEncoder.c b/ndn-cpp/c/encoding/BinaryXMLEncoder.c
index b7f1db1..0b38f87 100644
--- a/ndn-cpp/c/encoding/BinaryXMLEncoder.c
+++ b/ndn-cpp/c/encoding/BinaryXMLEncoder.c
@@ -10,20 +10,20 @@
#include "BinaryXMLEncoder.h"
enum {
- ENCODING_LIMIT_1_BYTE = ((1 << ndn_BinaryXML_TT_VALUE_BITS) - 1),
- ENCODING_LIMIT_2_BYTES = ((1 << (ndn_BinaryXML_TT_VALUE_BITS + ndn_BinaryXML_REGULAR_VALUE_BITS)) - 1),
- ENCODING_LIMIT_3_BYTES = ((1 << (ndn_BinaryXML_TT_VALUE_BITS + 2 * ndn_BinaryXML_REGULAR_VALUE_BITS)) - 1)
+ ENCODING_LIMIT_1_BYTE = ((1 << ndn_BinaryXml_TT_VALUE_BITS) - 1),
+ ENCODING_LIMIT_2_BYTES = ((1 << (ndn_BinaryXml_TT_VALUE_BITS + ndn_BinaryXml_REGULAR_VALUE_BITS)) - 1),
+ ENCODING_LIMIT_3_BYTES = ((1 << (ndn_BinaryXml_TT_VALUE_BITS + 2 * ndn_BinaryXml_REGULAR_VALUE_BITS)) - 1)
};
/**
* Call ndn_DynamicUCharArray_ensureLength to ensure that there is enough room in the output, and copy
* array to the output. This does not write a header.
- * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param self pointer to the ndn_BinaryXmlEncoder struct
* @param array the array to copy
* @param arrayLength the length of the array
* @return 0 for success, else an error code
*/
-static ndn_Error writeArray(struct ndn_BinaryXMLEncoder *self, unsigned char *array, unsigned int arrayLength)
+static ndn_Error writeArray(struct ndn_BinaryXmlEncoder *self, unsigned char *array, unsigned int arrayLength)
{
ndn_Error error;
if (error = ndn_DynamicUCharArray_ensureLength(&self->output, self->offset + arrayLength))
@@ -52,10 +52,10 @@
// Last byte gives you TT_VALUE_BITS.
// Remainder each gives you REGULAR_VALUE_BITS.
- x >>= ndn_BinaryXML_TT_VALUE_BITS;
+ x >>= ndn_BinaryXml_TT_VALUE_BITS;
while (x != 0) {
++nBytes;
- x >>= ndn_BinaryXML_REGULAR_VALUE_BITS;
+ x >>= ndn_BinaryXml_REGULAR_VALUE_BITS;
}
return nBytes;
@@ -88,11 +88,11 @@
* Write x as an unsigned decimal integer to the output with the digits in reverse order, using ndn_DynamicUCharArray_ensureLength.
* This does not write a header.
* We encode in reverse order, because this is the natural way to encode the digits, and the caller can reverse as needed.
- * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param self pointer to the ndn_BinaryXmlEncoder struct
* @param x the unsigned int to write
* @return 0 for success, else an error code
*/
-static ndn_Error encodeReversedUnsignedDecimalInt(struct ndn_BinaryXMLEncoder *self, unsigned int x)
+static ndn_Error encodeReversedUnsignedDecimalInt(struct ndn_BinaryXmlEncoder *self, unsigned int x)
{
while (1) {
ndn_Error error;
@@ -114,13 +114,13 @@
* then encode the header at startOffset.
* startOffser it the position in self-output.array of the first byte of the buffer and self->offset is the first byte past the end.
* We reverse and shift in the same function to avoid unnecessary copying if we first reverse then shift.
- * @param self pointer to the ndn_BinaryXMLEncoder struct
+ * @param self pointer to the ndn_BinaryXmlEncoder struct
* @param startOffset the offset in self->output.array of the start of the buffer to shift right
* @param type the header type
* @return 0 for success, else an error code
*/
static ndn_Error reverseBufferAndInsertHeader
- (struct ndn_BinaryXMLEncoder *self, unsigned int startOffset, unsigned int type)
+ (struct ndn_BinaryXmlEncoder *self, unsigned int startOffset, unsigned int type)
{
unsigned int nBufferBytes = self->offset - startOffset;
unsigned int nHeaderBytes = getNHeaderEncodingBytes(nBufferBytes);
@@ -141,7 +141,7 @@
// Override the offset to force encodeTypeAndValue to encode at startOffset, then fix the offset.
self->offset = startOffset;
- if (error = ndn_BinaryXMLEncoder_encodeTypeAndValue(self, ndn_BinaryXML_UDATA, nBufferBytes))
+ if (error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_UDATA, nBufferBytes))
// We don't really expect to get an error, since we have already ensured the length.
return error;
self->offset = startOffset + nHeaderBytes + nBufferBytes;
@@ -170,9 +170,9 @@
*hi32 = (unsigned long)((x - lo32Double) / twoPower32);
}
-ndn_Error ndn_BinaryXMLEncoder_encodeTypeAndValue(struct ndn_BinaryXMLEncoder *self, unsigned int type, unsigned int value)
+ndn_Error ndn_BinaryXmlEncoder_encodeTypeAndValue(struct ndn_BinaryXmlEncoder *self, unsigned int type, unsigned int value)
{
- if (type > ndn_BinaryXML_UDATA)
+ if (type > ndn_BinaryXml_UDATA)
return NDN_ERROR_header_type_is_out_of_range;
// Encode backwards. Calculate how many bytes we need.
@@ -183,16 +183,16 @@
// Bottom 4 bits of value go in last byte with tag.
self->output.array[self->offset + nEncodingBytes - 1] =
- (ndn_BinaryXML_TT_MASK & type |
- ((ndn_BinaryXML_TT_VALUE_MASK & value) << ndn_BinaryXML_TT_BITS)) |
- ndn_BinaryXML_TT_FINAL; // set top bit for last byte
- value >>= ndn_BinaryXML_TT_VALUE_BITS;
+ (ndn_BinaryXml_TT_MASK & type |
+ ((ndn_BinaryXml_TT_VALUE_MASK & value) << ndn_BinaryXml_TT_BITS)) |
+ ndn_BinaryXml_TT_FINAL; // set top bit for last byte
+ value >>= ndn_BinaryXml_TT_VALUE_BITS;
// Rest of value goes into preceding bytes, 7 bits per byte. (Zero top bit is "more" flag.)
unsigned int i = self->offset + nEncodingBytes - 2;
while (value != 0 && i >= self->offset) {
- self->output.array[i] = (value & ndn_BinaryXML_REGULAR_VALUE_MASK);
- value >>= ndn_BinaryXML_REGULAR_VALUE_BITS;
+ self->output.array[i] = (value & ndn_BinaryXml_REGULAR_VALUE_MASK);
+ value >>= ndn_BinaryXml_REGULAR_VALUE_BITS;
--i;
}
if (value != 0)
@@ -204,22 +204,22 @@
return 0;
}
-ndn_Error ndn_BinaryXMLEncoder_writeElementClose(struct ndn_BinaryXMLEncoder *self)
+ndn_Error ndn_BinaryXmlEncoder_writeElementClose(struct ndn_BinaryXmlEncoder *self)
{
ndn_Error error;
if (error = ndn_DynamicUCharArray_ensureLength(&self->output, self->offset + 1))
return error;
- self->output.array[self->offset] = ndn_BinaryXML_CLOSE;
+ self->output.array[self->offset] = ndn_BinaryXml_CLOSE;
self->offset += 1;
return 0;
}
-ndn_Error ndn_BinaryXMLEncoder_writeBlob(struct ndn_BinaryXMLEncoder *self, unsigned char *value, unsigned int valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeBlob(struct ndn_BinaryXmlEncoder *self, unsigned char *value, unsigned int valueLength)
{
ndn_Error error;
- if (error = ndn_BinaryXMLEncoder_encodeTypeAndValue(self, ndn_BinaryXML_BLOB, valueLength))
+ if (error = ndn_BinaryXmlEncoder_encodeTypeAndValue(self, ndn_BinaryXml_BLOB, valueLength))
return error;
if (error = writeArray(self, value, valueLength))
@@ -228,22 +228,22 @@
return 0;
}
-ndn_Error ndn_BinaryXMLEncoder_writeBlobDTagElement(struct ndn_BinaryXMLEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength)
+ndn_Error ndn_BinaryXmlEncoder_writeBlobDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, unsigned char *value, unsigned int valueLength)
{
ndn_Error error;
- if (error = ndn_BinaryXMLEncoder_writeElementStartDTag(self, tag))
+ if (error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag))
return error;
- if (error = ndn_BinaryXMLEncoder_writeBlob(self, value, valueLength))
+ if (error = ndn_BinaryXmlEncoder_writeBlob(self, value, valueLength))
return error;
- if (error = ndn_BinaryXMLEncoder_writeElementClose(self))
+ if (error = ndn_BinaryXmlEncoder_writeElementClose(self))
return error;
return 0;
}
-ndn_Error ndn_BinaryXMLEncoder_writeUnsignedDecimalInt(struct ndn_BinaryXMLEncoder *self, unsigned int value)
+ndn_Error ndn_BinaryXmlEncoder_writeUnsignedDecimalInt(struct ndn_BinaryXmlEncoder *self, unsigned int value)
{
// First write the decimal int (to find out how many bytes it is), then shift it forward to make room for the header.
unsigned int startOffset = self->offset;
@@ -252,28 +252,28 @@
if (error = encodeReversedUnsignedDecimalInt(self, value))
return error;
- if (error = reverseBufferAndInsertHeader(self, startOffset, ndn_BinaryXML_UDATA))
+ if (error = reverseBufferAndInsertHeader(self, startOffset, ndn_BinaryXml_UDATA))
return error;
return 0;
}
-ndn_Error ndn_BinaryXMLEncoder_writeUnsignedDecimalIntDTagElement(struct ndn_BinaryXMLEncoder *self, unsigned int tag, unsigned int value)
+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))
+ if (error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag))
return error;
- if (error = ndn_BinaryXMLEncoder_writeUnsignedDecimalInt(self, value))
+ if (error = ndn_BinaryXmlEncoder_writeUnsignedDecimalInt(self, value))
return error;
- if (error = ndn_BinaryXMLEncoder_writeElementClose(self))
+ if (error = ndn_BinaryXmlEncoder_writeElementClose(self))
return error;
return 0;
}
-ndn_Error ndn_BinaryXMLEncoder_writeAbsDoubleBigEndianBlob(struct ndn_BinaryXMLEncoder *self, double value)
+ndn_Error ndn_BinaryXmlEncoder_writeAbsDoubleBigEndianBlob(struct ndn_BinaryXmlEncoder *self, double value)
{
unsigned long hi32, lo32;
splitAbsDouble(value, &hi32, &lo32);
@@ -309,22 +309,22 @@
}
}
- if (error = reverseBufferAndInsertHeader(self, startOffset, ndn_BinaryXML_BLOB))
+ if (error = reverseBufferAndInsertHeader(self, startOffset, ndn_BinaryXml_BLOB))
return error;
return 0;
}
-ndn_Error ndn_BinaryXMLEncoder_writeTimeMillisecondsDTagElement(struct ndn_BinaryXMLEncoder *self, unsigned int tag, double milliseconds)
+ndn_Error ndn_BinaryXmlEncoder_writeTimeMillisecondsDTagElement(struct ndn_BinaryXmlEncoder *self, unsigned int tag, double milliseconds)
{
ndn_Error error;
- if (error = ndn_BinaryXMLEncoder_writeElementStartDTag(self, tag))
+ if (error = ndn_BinaryXmlEncoder_writeElementStartDTag(self, tag))
return error;
- if (error = ndn_BinaryXMLEncoder_writeAbsDoubleBigEndianBlob(self, (milliseconds / 1000.0) * 4096.0))
+ if (error = ndn_BinaryXmlEncoder_writeAbsDoubleBigEndianBlob(self, (milliseconds / 1000.0) * 4096.0))
return error;
- if (error = ndn_BinaryXMLEncoder_writeElementClose(self))
+ if (error = ndn_BinaryXmlEncoder_writeElementClose(self))
return error;
return 0;