blob-lite.hpp
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
22 #ifndef NDN_BLOB_LITE_HPP
23 #define NDN_BLOB_LITE_HPP
24 
25 #include <ndn-cpp/c/util/blob-types.h>
26 
27 namespace ndn {
28 
37 class BlobLite : private ndn_Blob {
38 public:
42  BlobLite();
43 
49  BlobLite(const uint8_t* buf, size_t size);
50 
54  const uint8_t*
55  buf() const { return value; }
56 
60  size_t
61  size() const { return length; }
62 
67  bool
68  isNull() const { return !value; }
69 
75  static BlobLite&
76  downCast(ndn_Blob& blob) { return *(BlobLite*)&blob; }
77 
78  static const BlobLite&
79  downCast(const ndn_Blob& blob) { return *(BlobLite*)&blob; }
80 };
81 
82 }
83 
84 #endif
size_t size() const
Return size given to the constructor.
Definition: blob-lite.hpp:61
Copyright (C) 2013-2016 Regents of the University of California.
Definition: common.hpp:35
bool isNull() const
Check if the array pointer is null.
Definition: blob-lite.hpp:68
static BlobLite & downCast(ndn_Blob &blob)
Downcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:76
size_t length
the number of bytes in value.
Definition: blob-types.h:35
const uint8_t * value
pointer to the pre-allocated buffer for the value.
Definition: blob-types.h:34
A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScr...
Definition: blob-lite.hpp:37
Copyright (C) 2015-2016 Regents of the University of California.
Definition: blob-types.h:33
const uint8_t * buf() const
Return buf given to the constructor.
Definition: blob-lite.hpp:55
BlobLite()
Create a BlobLite where the buf and size are 0.
Definition: blob-lite.cpp:27