blob: 955089924996d0a4dba0cb31918887c6e74693db [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 */
Jeff Thompson97223af2013-09-24 17:01:27 -070026 DynamicUInt8Vector(size_t initialLength);
Jeff Thompson10ad12a2013-09-24 16:19:11 -070027
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*
Jeff Thompson97223af2013-09-24 17:01:27 -070044 realloc(struct ndn_DynamicUInt8Array *self, uint8_t *array, size_t length);
Jeff Thompson10ad12a2013-09-24 16:19:11 -070045
46 ptr_lib::shared_ptr<std::vector<uint8_t> > vector_;
47};
48
49}
50
51#endif