blob: cee590cb6b3a8a6f9f99d4693418e39520c374a4 [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
Jeff Thompson2d27e2f2013-08-09 12:55:00 -07007#define NDN_BINARYXMLENCODER_HPP
Jeff Thompson2d28d492013-07-01 17:57:53 -07008
Jeff Thompson58d798f2013-07-02 14:16:25 -07009#include <vector>
Jeff Thompsonb0979fd2013-07-30 15:48:21 -070010#include "../common.hpp"
Jeff Thompsonfaaa2372013-08-12 13:16:35 -070011#include "../util/dynamic-uchar-vector.hpp"
Jeff Thompson53412192013-08-06 13:35:50 -070012#include "../c/encoding/binary-xml-encoder.h"
Jeff Thompson2d28d492013-07-01 17:57:53 -070013
14namespace ndn {
15
16/**
Jeff Thompsonf0fea002013-07-30 17:22:42 -070017 * A BinaryXmlEncoder extends a C ndn_BinaryXmlEncoder struct and wraps related functions.
Jeff Thompson2d28d492013-07-01 17:57:53 -070018 */
Jeff Thompsonf0fea002013-07-30 17:22:42 -070019class BinaryXmlEncoder : public ndn_BinaryXmlEncoder {
Jeff Thompson2d28d492013-07-01 17:57:53 -070020public:
21 /**
Jeff Thompsonf0fea002013-07-30 17:22:42 -070022 * Initialize the base ndn_BinaryXmlEncoder struct with an initial array of 16 bytes. Use simpleRealloc.
Jeff Thompson2d28d492013-07-01 17:57:53 -070023 */
Jeff Thompsonf0fea002013-07-30 17:22:42 -070024 BinaryXmlEncoder()
Jeff Thompsoneced5802013-08-12 13:34:52 -070025 : output_(16)
Jeff Thompson2d28d492013-07-01 17:57:53 -070026 {
Jeff Thompsond1427fb2013-08-29 17:20:32 -070027 ndn_BinaryXmlEncoder_initialize(this, &output_);
Jeff Thompson2d28d492013-07-01 17:57:53 -070028 }
29
30 /**
Jeff Thompsonf0570a62013-08-21 11:38:19 -070031 * Resize the output vector to the correct encoding length and return.
32 * @return The encoding as a shared_ptr. Assume that the caller now owns the vector.
Jeff Thompson58d798f2013-07-02 14:16:25 -070033 */
Jeff Thompson13774032013-08-16 17:08:33 -070034 const ptr_lib::shared_ptr<std::vector<unsigned char> > &getOutput()
Jeff Thompson58d798f2013-07-02 14:16:25 -070035 {
Jeff Thompsonf0570a62013-08-21 11:38:19 -070036 output_.get()->resize(offset);
Jeff Thompsonfaaa2372013-08-12 13:16:35 -070037 return output_.get();
Jeff Thompson58d798f2013-07-02 14:16:25 -070038 }
Jeff Thompsonfaaa2372013-08-12 13:16:35 -070039
40 DynamicUCharVector output_;
Jeff Thompson2d28d492013-07-01 17:57:53 -070041};
42
43}
44
45#endif