binary-xml-decoder.h
1 
21 #ifndef NDN_BINARYXMLDECODER_H
22 #define NDN_BINARYXMLDECODER_H
23 
24 #include <ndn-cpp/c/common.h>
25 #include <ndn-cpp/c/errors.h>
26 #include "../util/blob.h"
27 #include "binary-xml.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
34  const uint8_t *input;
35  size_t inputLength;
36  size_t offset;
37  // peekDTag sets and checks these, and readElementStartDTag uses them to avoid reading again.
38  size_t previouslyPeekedDTagStartOffset;
39  size_t previouslyPeekedDTagEndOffset;
40  unsigned int previouslyPeekedDTag;
41 };
42 
43 static __inline void ndn_BinaryXmlDecoder_initialize(struct ndn_BinaryXmlDecoder *self, const uint8_t *input, size_t inputLength)
44 {
45  self->input = input;
46  self->inputLength = inputLength;
47  self->offset = 0;
48  self->previouslyPeekedDTagStartOffset = (size_t)-1;
49 }
50 
58 ndn_Error ndn_BinaryXmlDecoder_decodeTypeAndValue(struct ndn_BinaryXmlDecoder *self, unsigned int *type, unsigned int *value);
59 
67 ndn_Error ndn_BinaryXmlDecoder_readElementStartDTag(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag);
68 
74 ndn_Error ndn_BinaryXmlDecoder_readElementClose(struct ndn_BinaryXmlDecoder *self);
75 
84 ndn_Error ndn_BinaryXmlDecoder_peekDTag(struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int *gotExpectedTag);
85 
99 ndn_Error ndn_BinaryXmlDecoder_readBinaryDTagElement
100  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value);
101 
112 ndn_Error ndn_BinaryXmlDecoder_readOptionalBinaryDTagElement
113  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int allowNull, struct ndn_Blob *value);
114 
124 ndn_Error ndn_BinaryXmlDecoder_readUDataDTagElement
125  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value);
126 
136 ndn_Error ndn_BinaryXmlDecoder_readOptionalUDataDTagElement
137  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, struct ndn_Blob *value);
138 
149 ndn_Error ndn_BinaryXmlDecoder_readUnsignedIntegerDTagElement
150  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, unsigned int *value);
151 
161 ndn_Error ndn_BinaryXmlDecoder_readOptionalUnsignedIntegerDTagElement
162  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, int *value);
163 
173 ndn_Error ndn_BinaryXmlDecoder_readTimeMillisecondsDTagElement
174  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, double *milliseconds);
175 
184 ndn_Error ndn_BinaryXmlDecoder_readOptionalTimeMillisecondsDTagElement
185  (struct ndn_BinaryXmlDecoder *self, unsigned int expectedTag, double *milliseconds);
186 
194 double ndn_BinaryXmlDecoder_unsignedBigEndianToDouble(const uint8_t *bytes, size_t bytesLength);
195 
201 static __inline void ndn_BinaryXmlDecoder_seek(struct ndn_BinaryXmlDecoder *self, size_t offset)
202 {
203  self->offset = offset;
204 }
205 
206 #ifdef __cplusplus
207 }
208 #endif
209 
210 #endif
Copyright (C) 2015 Regents of the University of California.
Definition: blob-types.h:33
Copyright (C) 2013-2015 Regents of the University of California.
Definition: binary-xml-decoder.h:33