Public Member Functions | Static Public Member Functions | List of all members
ndn::BlobLite Class Reference

A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScript string which is a pointer to an immutable string. More...

#include <blob-lite.hpp>

Inheritance diagram for ndn::BlobLite:
ndn_Blob

Public Member Functions

 BlobLite ()
 Create a BlobLite where the buf and size are 0.
 
 BlobLite (const uint8_t *buf, size_t size)
 Create a BlobLite with the given buffer. More...
 
const uint8_t * buf () const
 Return buf given to the constructor.
 
size_t size () const
 Return size given to the constructor.
 
bool isNull () const
 Check if the array pointer is null. More...
 

Static Public Member Functions

static BlobLitedownCast (ndn_Blob &blob)
 Downcast the reference to the ndn_Blob struct to a BlobLite. More...
 
static const BlobLitedownCast (const ndn_Blob &blob)
 

Detailed Description

A BlobLite holds a pointer to an immutable pre-allocated buffer and its length This is like a JavaScript string which is a pointer to an immutable string.

It is OK to pass a pointer to the string because the new owner can't change the bytes of the string. However, like a JavaScript string, it is possible to change the pointer, and so this does allow the copy constructor and assignment to change the pointer. Also remember that the pointer can be null.

Constructor & Destructor Documentation

ndn::BlobLite::BlobLite ( const uint8_t *  buf,
size_t  size 
)

Create a BlobLite with the given buffer.

Parameters
bufThe pre-allocated buffer for the value, or 0 for none.
sizeThe number of bytes in buf.

Member Function Documentation

static BlobLite& ndn::BlobLite::downCast ( ndn_Blob blob)
inlinestatic

Downcast the reference to the ndn_Blob struct to a BlobLite.

Parameters
blobA reference to the ndn_Blob struct.
Returns
The same reference as BlobLite.
bool ndn::BlobLite::isNull ( ) const
inline

Check if the array pointer is null.

Returns
true if the buffer pointer is null, otherwise false.

The documentation for this class was generated from the following files: