blob: f31de460183a59adc5074bc116e2c0d93ddd4c23 [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 Thompsonb0979fd2013-07-30 15:48:21 -070010#include "../common.hpp"
Jeff Thompson45545092013-07-16 18:36:26 -070011#include "../c/util/ndn_realloc.h"
Jeff Thompson2d28d492013-07-01 17:57:53 -070012#include "../c/encoding/BinaryXMLEncoder.h"
13
14namespace ndn {
15
16/**
Jeff Thompson0adcbea2013-07-15 16:29:52 -070017 * A BinaryXMLEncoder extends a C ndn_BinaryXMLEncoder struct and wraps related functions.
Jeff Thompson2d28d492013-07-01 17:57:53 -070018 */
Jeff Thompson0adcbea2013-07-15 16:29:52 -070019class BinaryXMLEncoder : public ndn_BinaryXMLEncoder {
Jeff Thompson2d28d492013-07-01 17:57:53 -070020public:
21 /**
22 * Initialize the base ndn_BinaryXMLEncoder struct with an initial array of 16 bytes. Use simpleRealloc.
23 */
24 BinaryXMLEncoder()
25 {
26 const unsigned int initialLength = 16;
Jeff Thompson45545092013-07-16 18:36:26 -070027 ndn_BinaryXMLEncoder_init(this, (unsigned char *)malloc(initialLength), initialLength, ndn_realloc);
Jeff Thompson2d28d492013-07-01 17:57:53 -070028 }
29
30 /**
Jeff Thompsonb0979fd2013-07-30 15:48:21 -070031 * Return the output as a shared_ptr.
Jeff Thompson58d798f2013-07-02 14:16:25 -070032 */
Jeff Thompsonb0979fd2013-07-30 15:48:21 -070033 ptr_lib::shared_ptr<std::vector<unsigned char> > getOutput()
Jeff Thompson58d798f2013-07-02 14:16:25 -070034 {
Jeff Thompsonb0979fd2013-07-30 15:48:21 -070035 return ptr_lib::shared_ptr<std::vector<unsigned char> >(new std::vector<unsigned char>(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