blob: b24229b23b5e54876138a61c52b5a5136efce6bc [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 */
Jeff Thompson1e2180f2013-08-12 13:32:50 -070019class DynamicUCharVector : public ndn_DynamicUCharArray {
Jeff Thompson529779a2013-08-12 13:15:55 -070020public:
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 /**
Jeff Thompson1e2180f2013-08-12 13:32:50 -070035 * Implement the static realloc function using vector resize.
Jeff Thompson529779a2013-08-12 13:15:55 -070036 * @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
Jeff Thompson5dbf5432013-08-16 16:59:32 -070043 ptr_lib::shared_ptr<std::vector<unsigned char> > vector_;
Jeff Thompson529779a2013-08-12 13:15:55 -070044};
45
46}
47
48#endif