blob: 2ae51966b4f6d7834315bac4ecdbfc387509dc8b [file] [log] [blame]
Jeff Thompson47eecfc2013-07-07 22:56:46 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
Jeff Thompson2d28d492013-07-01 17:57:53 -07004 */
5
6#ifndef NDN_BINARYXMLENCODER_HPP
7#define NDN_BINARYXMLENCODER_HPP
8
Jeff Thompson58d798f2013-07-02 14:16:25 -07009#include <vector>
Jeff Thompson45545092013-07-16 18:36:26 -070010#include "../c/util/ndn_realloc.h"
Jeff Thompson2d28d492013-07-01 17:57:53 -070011#include "../c/encoding/BinaryXMLEncoder.h"
12
13namespace ndn {
14
15/**
Jeff Thompson0adcbea2013-07-15 16:29:52 -070016 * A BinaryXMLEncoder extends a C ndn_BinaryXMLEncoder struct and wraps related functions.
Jeff Thompson2d28d492013-07-01 17:57:53 -070017 */
Jeff Thompson0adcbea2013-07-15 16:29:52 -070018class BinaryXMLEncoder : public ndn_BinaryXMLEncoder {
Jeff Thompson2d28d492013-07-01 17:57:53 -070019public:
20 /**
21 * Initialize the base ndn_BinaryXMLEncoder struct with an initial array of 16 bytes. Use simpleRealloc.
22 */
23 BinaryXMLEncoder()
24 {
25 const unsigned int initialLength = 16;
Jeff Thompson45545092013-07-16 18:36:26 -070026 ndn_BinaryXMLEncoder_init(this, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
Jeff Thompson2d28d492013-07-01 17:57:53 -070027 }
28
29 /**
Jeff Thompson58d798f2013-07-02 14:16:25 -070030 * Copy the encoded bytes to the end of the buffer.
31 * @param buffer a vector to receive the copy
32 */
33 void appendTo(std::vector<unsigned char> &buffer)
34 {
Jeff Thompson66f6c9a2013-07-15 16:33:22 -070035 buffer.insert(buffer.end(), output.array, output.array + offset);
Jeff Thompson58d798f2013-07-02 14:16:25 -070036 }
Jeff Thompson2d28d492013-07-01 17:57:53 -070037};
38
39}
40
41#endif