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