Jeff Thompson | c896365 | 2013-06-28 20:17:43 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Author: Jeff Thompson |
| 3 | * |
| 4 | * BSD license, See the LICENSE file for more information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NDN_BINARYXMLENCODER_H |
| 8 | #define NDN_BINARYXMLENCODER_H |
| 9 | |
| 10 | #include "../util/DynamicUCharArray.h" |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | struct ndn_BinaryXMLEncoder { |
| 17 | struct ndn_DynamicUCharArray output; /**< receives the encoded output */ |
| 18 | unsigned int offset; /**< the offset into output.array for the next encoding */ |
| 19 | }; |
| 20 | |
| 21 | /** |
| 22 | * Initialize an ndn_BinaryXMLEncoder_init struct with the arguments for initializing the ndn_DynamicUCharArray. |
| 23 | * @param self pointer to the ndn_BinaryXMLEncoder struct |
| 24 | * @param outputArray the allocated array buffer to receive the encoding |
| 25 | * @param outputArrayLength the length of outputArray |
| 26 | * @param reallocFunction the realloc function used by ndn_DynamicUCharArray_ensureLength. If outputArrayLength |
| 27 | * is large enough to receive the entire encoding, this can be 0. |
| 28 | */ |
| 29 | static inline void ndn_BinaryXMLEncoder_init |
| 30 | (struct ndn_BinaryXMLEncoder *self, unsigned char *outputArray, unsigned int outputArrayLength, |
| 31 | unsigned char (*reallocFunction)(unsigned char *, unsigned int)) |
| 32 | { |
| 33 | ndn_DynamicUCharArray_init(&self->output, outputArray, outputArrayLength, reallocFunction); |
| 34 | self->offset = 0; |
| 35 | } |
| 36 | |
Jeff Thompson | 433e6da | 2013-07-01 15:09:00 -0700 | [diff] [blame^] | 37 | char *ndn_BinaryXMLEncoder_encodeTypeAndValue(struct ndn_BinaryXMLEncoder *self, unsigned int type, unsigned int value); |
| 38 | |
Jeff Thompson | c896365 | 2013-06-28 20:17:43 -0700 | [diff] [blame] | 39 | #ifdef __cplusplus |
| 40 | } |
| 41 | #endif |
| 42 | |
| 43 | #endif |
| 44 | |