| /** |
| * @author: Jeff Thompson |
| * See COPYING for copyright and distribution information. |
| */ |
| |
| #ifndef NDN_BINARYXMLDECODER_HPP |
| #define NDN_BINARYXMLDECODER_HPP |
| |
| #include <stdexcept> |
| #include "../c/errors.h" |
| #include "../c/encoding/binary-xml-decoder.h" |
| |
| namespace ndn { |
| |
| |
| /** |
| * A BinaryXmlDecoder extends a C ndn_BinaryXmlDecoder struct and wraps related functions. |
| */ |
| class BinaryXmlDecoder : public ndn_BinaryXmlDecoder { |
| public: |
| /** |
| * Initialize the base ndn_BinaryXmlDecoder struct with the input. |
| */ |
| BinaryXmlDecoder(const unsigned char *input, unsigned int inputLength) |
| { |
| ndn_BinaryXmlDecoder_initialize(this, (unsigned char *)input, inputLength); |
| } |
| |
| /** |
| * Decode the header from the input starting at offset, and if it is a DTAG where the value is the expectedTag, |
| * then return true, else false. Do not update offset, including if throwing an exception. |
| * @param expectedTag the expected value for DTAG |
| * @return true if got the expected tag, else false |
| */ |
| bool peekDTag(unsigned int expectedTag) |
| { |
| int gotExpectedTag; |
| ndn_Error error; |
| if ((error = ndn_BinaryXmlDecoder_peekDTag(this, expectedTag, &gotExpectedTag))) |
| throw std::runtime_error(ndn_getErrorString(error)); |
| |
| return gotExpectedTag; |
| } |
| }; |
| |
| } |
| |
| #endif |