26 #include "../common.hpp"
42 class Blob :
public ptr_lib::shared_ptr<const std::vector<uint8_t> > {
56 Blob(
const uint8_t* value,
size_t valueLength)
57 :
ptr_lib::shared_ptr<const
std::vector<uint8_t> >(new
std::vector<uint8_t>(value, value + valueLength))
67 Blob(
const std::vector<uint8_t> &value)
68 :
ptr_lib::shared_ptr<const
std::vector<uint8_t> >(new
std::vector<uint8_t>(value))
83 :
ptr_lib::shared_ptr<const
std::vector<uint8_t> >(blob)
95 Blob(
const ptr_lib::shared_ptr<std::vector<uint8_t> > &value,
bool copy)
96 :
ptr_lib::shared_ptr<const
std::vector<uint8_t> >
97 ((const
ptr_lib::shared_ptr<const
std::vector<uint8_t> > &)value)
100 this->reset(
new std::vector<uint8_t>(*value));
102 Blob(
const ptr_lib::shared_ptr<
const std::vector<uint8_t> > &value,
bool copy)
103 :
ptr_lib::shared_ptr<const
std::vector<uint8_t> >(value)
106 this->reset(
new std::vector<uint8_t>(*value));
113 DEPRECATED_IN_NDN_CPP
Blob(
const ptr_lib::shared_ptr<std::vector<uint8_t> > &value)
114 :
ptr_lib::shared_ptr<const
std::vector<uint8_t> >((const
ptr_lib::shared_ptr<const
std::vector<uint8_t> > &)value)
117 DEPRECATED_IN_NDN_CPP
Blob(
const ptr_lib::shared_ptr<
const std::vector<uint8_t> > &value)
118 :
ptr_lib::shared_ptr<const
std::vector<uint8_t> >(value)
129 return (*this)->size();
141 return &(*this)->front();
169 return (*
this) ? std::string((
const char*)(&(*this)->front()), (*this)->size())
188 return (**
this) == (*other);
197 get(
struct ndn_Blob& blobStruct)
const;
201 operator << (std::ostream& os,
const Blob& blob)
203 for (
size_t i = 0; i < blob.size(); ++i)
DEPRECATED_IN_NDN_CPP Blob(const ptr_lib::shared_ptr< std::vector< uint8_t > > &value)
Create a new Blob to point to an existing byte array.
Definition: blob.hpp:113
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
Copyright (C) 2015 Regents of the University of California.
bool isNull() const
Check if the array pointer is null.
Definition: blob.hpp:151
Blob(const Blob &blob)
Create a new Blob and take another pointer to the given blob's buffer.
Definition: blob.hpp:82
A Blob holds a pointer to an immutable byte array implemented as const std::vector.
Definition: blob.hpp:42
const uint8_t * buf() const
Return a const pointer to the first byte of the immutable byte array, or 0 if the pointer is null...
Definition: blob.hpp:138
size_t size() const
Return the length of the immutable byte array.
Definition: blob.hpp:126
std::string toRawStr() const
Return the bytes of the byte array as a raw str of the same length.
Definition: blob.hpp:167
Blob()
Create a new Blob with a null pointer.
Definition: blob.hpp:47
Copyright (C) 2015 Regents of the University of California.
Definition: blob-types.h:33
std::string toHex(const uint8_t *array, size_t arrayLength)
Return the hex representation of the bytes in array.
Definition: common.cpp:30
Blob(const uint8_t *value, size_t valueLength)
Create a new Blob with an immutable copy of the given array.
Definition: blob.hpp:56
Blob(const ptr_lib::shared_ptr< std::vector< uint8_t > > &value, bool copy)
Create a new Blob to point to an existing byte array.
Definition: blob.hpp:95
std::string toHex() const
Return the hex representation of the bytes in array.
Definition: blob.hpp:159
bool equals(const Blob &other) const
Check if the value of this Blob equals the other blob.
Definition: blob.hpp:180
Blob(const std::vector< uint8_t > &value)
Create a new Blob with an immutable copy of the array in the given vector.
Definition: blob.hpp:67