22 #ifndef NDN_TLV_DECODER_HPP
23 #define NDN_TLV_DECODER_HPP
26 #include "../c/encoding/tlv/tlv-decoder.h"
42 ndn_TlvDecoder_initialize(
this, input, inputLength);
46 readNestedTlvsStart(
unsigned int expectedType)
50 if ((error = ndn_TlvDecoder_readNestedTlvsStart
51 (
this, expectedType, &endOffset)))
52 throw runtime_error(ndn_getErrorString(error));
58 finishNestedTlvs(
int endOffset)
61 if ((error = ndn_TlvDecoder_finishNestedTlvs(
this, endOffset)))
62 throw runtime_error(ndn_getErrorString(error));
66 finishNestedTlvsSkipCritical(
int endOffset)
69 if ((error = ndn_TlvDecoder_finishNestedTlvsSkipCritical(
this, endOffset)))
70 throw runtime_error(ndn_getErrorString(error));
74 peekType(
unsigned int expectedType,
size_t endOffset)
78 if ((error = ndn_TlvDecoder_peekType
79 (
this, expectedType, endOffset, &gotExpectedType)))
80 throw runtime_error(ndn_getErrorString(error));
82 return gotExpectedType != 0 ?
true :
false;
86 readNonNegativeIntegerTlv(
unsigned int expectedType)
90 if ((error = ndn_TlvDecoder_readNonNegativeIntegerTlv
91 (
this, expectedType, &value)))
92 throw runtime_error(ndn_getErrorString(error));
98 readBlobTlv(unsigned int expectedType)
102 if ((error = ndn_TlvDecoder_readBlobTlv(
this, expectedType, &value)))
103 throw runtime_error(ndn_getErrorString(error));
109 readBooleanTlv(
unsigned int expectedType,
size_t endOffset)
113 if ((error = ndn_TlvDecoder_readBooleanTlv
114 (
this, expectedType, endOffset, &value)))
115 throw runtime_error(ndn_getErrorString(error));
121 skipTlv(
unsigned int expectedType)
124 if ((error = ndn_TlvDecoder_skipTlv(
this, expectedType)))
125 throw runtime_error(ndn_getErrorString(error));
129 skipOptionalTlv(
unsigned int expectedType,
size_t endOffset)
132 if ((error = ndn_TlvDecoder_skipOptionalTlv
133 (
this, expectedType, endOffset)))
134 throw runtime_error(ndn_getErrorString(error));
138 seek(
size_t offset) { ndn_TlvDecoder_seek(
this, offset); }
TlvDecoder(const uint8_t *input, size_t inputLength)
Initialize the base ndn_TlvDecoder struct with the input.
Definition: tlv-decoder.hpp:40
A TlvDecoder extends a C ndn_TlvDecoder struct and wraps related functions.
Definition: tlv-decoder.hpp:35
const uint8_t * value
pointer to the pre-allocated buffer for the value.
Definition: blob-types.h:34
Copyright (C) 2015-2018 Regents of the University of California.
Definition: blob-types.h:33
Copyright (C) 2014-2018 Regents of the University of California.
Definition: tlv-decoder.h:34