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 
68  static BlobLite&
69  upCast(ndn_Blob& blob) { return *(BlobLite*)&blob; }
70 
71  static const BlobLite&
72  upCast(const ndn_Blob& blob) { return *(BlobLite*)&blob; }
73 };
74 
75 }
76 
77 #endif
size_t size() const
Return size given to the constructor.
Definition: blob-lite.hpp:61
Copyright (C) 2013-2015 Regents of the University of California.
Definition: common.hpp:35
static BlobLite & upCast(ndn_Blob &blob)
Upcast the reference to the ndn_Blob struct to a BlobLite.
Definition: blob-lite.hpp:69
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 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