22 #ifndef NDN_DYNAMIC_UCHAR_VECTOR_HPP
23 #define NDN_DYNAMIC_UCHAR_VECTOR_HPP
27 #include <ndn-cpp/common.hpp>
28 #include "../c/util/dynamic-uint8-array.h"
54 if ((error = ndn_DynamicUInt8Array_ensureLength(
this, length)))
55 throw std::runtime_error(ndn_getErrorString(error));
67 copy(
const uint8_t *value,
size_t valueLength,
size_t offset)
70 if ((error = ndn_DynamicUInt8Array_copy(
this, value, valueLength, offset)))
71 throw std::runtime_error(ndn_getErrorString(error));
73 return offset + valueLength;
84 copy(
const std::vector<uint8_t>& value,
size_t offset)
86 return copy(&value[0], value.size(), offset);
99 if ((error = ndn_DynamicUInt8Array_ensureLengthFromBack(
this, length)))
100 throw std::runtime_error(ndn_getErrorString(error));
113 copyFromBack(
const uint8_t *value,
size_t valueLength,
size_t offsetFromBack)
116 if ((error = ndn_DynamicUInt8Array_copyFromBack
117 (
this, value, valueLength, offsetFromBack)))
118 throw std::runtime_error(ndn_getErrorString(error));
125 ptr_lib::shared_ptr<std::vector<uint8_t> >&
126 get() {
return vector_; }
129 operator [] (
size_t i) {
return (*vector_)[i]; }
132 operator [] (
size_t i)
const {
return (*vector_)[i]; }
145 ptr_lib::shared_ptr<std::vector<uint8_t> > vector_;
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
size_t copy(const std::vector< uint8_t > &value, size_t offset)
Copy value into the vector at offset, using ensureLength to make sure the vector has enough size...
Definition: dynamic-uint8-vector.hpp:84
void ensureLengthFromBack(size_t length)
Ensure that the vector size is greater than or equal to length.
Definition: dynamic-uint8-vector.hpp:96
A struct ndn_DynamicUInt8Array holds a pointer to an allocated array, the length of the allocated arr...
Definition: dynamic-uint8-array-types.h:40
size_t length
the length of the allocated array buffer
Definition: dynamic-uint8-array-types.h:42
DynamicUInt8Vector(size_t initialLength)
Create a new DynamicUInt8Vector with an initial length.
Definition: dynamic-uint8-vector.cpp:28
size_t copy(const uint8_t *value, size_t valueLength, size_t offset)
Copy value into the vector at offset, using ensureLength to make sure the vector has enough size...
Definition: dynamic-uint8-vector.hpp:67
void ensureLength(size_t length)
Ensure that the vector size is greater than or equal to length.
Definition: dynamic-uint8-vector.hpp:51
void copyFromBack(const uint8_t *value, size_t valueLength, size_t offsetFromBack)
First call ensureLengthFromBack to make sure the vector has offsetFromBack bytes. ...
Definition: dynamic-uint8-vector.hpp:113
A DynamicUInt8Vector extends ndn_DynamicUInt8Array to hold a shared_ptr > for use wit...
Definition: dynamic-uint8-vector.hpp:36
uint8_t * array
the allocated array buffer
Definition: dynamic-uint8-array-types.h:41