Added ndn_BinaryXMLDecoder_readDTag
diff --git a/ndn-cpp/encoding/BinaryXMLDecoder.c b/ndn-cpp/encoding/BinaryXMLDecoder.c
index f68e9b9..2e4e103 100644
--- a/ndn-cpp/encoding/BinaryXMLDecoder.c
+++ b/ndn-cpp/encoding/BinaryXMLDecoder.c
@@ -30,3 +30,20 @@
*valueOut = value;
return (char *)0;
}
+
+char *ndn_BinaryXMLDecoder_readDTag(struct ndn_BinaryXMLDecoder *self, unsigned int tag)
+{
+ char *error;
+ unsigned int type;
+ unsigned int value;
+ if (error = ndn_BinaryXMLDecoder_decodeTypeAndValue(self, &type, &value))
+ return error;
+
+ if (type != ndn_BinaryXML_DTAG)
+ return "ndn_BinaryXMLDecoder_readDTag: header type is not a DTAG";
+
+ if (value != tag)
+ return "ndn_BinaryXMLDecoder_readDTag: did not get the expected DTAG";
+
+ return (char *)0;
+}
\ No newline at end of file
diff --git a/ndn-cpp/encoding/BinaryXMLDecoder.h b/ndn-cpp/encoding/BinaryXMLDecoder.h
index c9e558d..470e562 100644
--- a/ndn-cpp/encoding/BinaryXMLDecoder.h
+++ b/ndn-cpp/encoding/BinaryXMLDecoder.h
@@ -24,10 +24,26 @@
self->offset = 0;
}
-// Even though the first byte should not be zero, this silently ignores initial zeros.
+/**
+ * Decode the header's type and value from self's input starting at offset. Update offset.
+ * Even though the first byte should not be zero, this silently ignores initial zeros.
+ * @param self pointer to the ndn_BinaryXMLDecoder struct
+ * @param type output for the header type
+ * @param value output for the header value
+ * @return 0 for success, else an error string
+ */
char *ndn_BinaryXMLDecoder_decodeTypeAndValue(struct ndn_BinaryXMLDecoder *self, unsigned int *type, unsigned int *value);
/**
+ * Decode the header from self's input starting at offset, expecting the type to be DTAG and the value to be the
+ * given tag. Update offset.
+ * @param self pointer to the ndn_BinaryXMLDecoder struct
+ * @param tag the expected value for DTAG
+ * @return 0 for success, else an error string, including an error if not the expected tag
+ */
+char *ndn_BinaryXMLDecoder_readDTag(struct ndn_BinaryXMLDecoder *self, unsigned int tag);
+
+/**
* Set the offset into the input, used for the next read.
* @param self pointer to the ndn_BinaryXMLDecoder struct
* @param offset the new offset