blob: f372affa0897f8c9ff2a0ae01e7aa4ba168456cc [file] [log] [blame]
Jeff Thompson529779a2013-08-12 13:15:55 -07001/**
2 * @author: Jeff Thompson
3 * See COPYING for copyright and distribution information.
4 */
5
6#ifndef NDN_DYNAMIC_UCHAR_VECTOR_HPP
7#define NDN_DYNAMIC_UCHAR_VECTOR_HPP
8
9#include <vector>
10#include "../common.hpp"
11#include "../c/util/dynamic-uchar-array.h"
12
13namespace ndn {
14
15/**
16 * A DynamicUCharVector extends ndn_DynamicUCharArray to hold a shared_ptr<vector<unsigned char> > for use with
17 * C functions which need an ndn_DynamicUCharArray.
18 */
19class DynamicUCharVector : ndn_DynamicUCharArray {
20public:
21 /**
22 * Create a new DynamicUCharVector with an initial length.
23 * @param initialLength The initial size of the allocated vector.
24 */
25 DynamicUCharVector(unsigned int initialLength);
26
27 /**
28 * Get the shared_ptr to the allocated vector.
29 * @return The shared_ptr to the allocated vector.
30 */
31 const ptr_lib::shared_ptr<std::vector<unsigned char> > &get() { return vector_; }
32
33private:
34 /**
35 * Implement the static realloc function using vector reserve.
36 * @param self A pointer to this object.
37 * @param array Should be the front of the vector.
38 * @param length The new length for the vector.
39 * @return The front of the allocated vector.
40 */
41 static unsigned char *realloc(struct ndn_DynamicUCharArray *self, unsigned char *array, unsigned int length);
42
43 ndn::ptr_lib::shared_ptr<std::vector<unsigned char> > vector_;
44};
45
46}
47
48#endif