blob: d81d039e5f656e34e97e0dfe62f5684046a12014 [file] [log] [blame]
Jeff Thompsonfa306642013-06-17 15:06:57 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2/*
3 * Copyright (c) 2013, Regents of the University of California
4 * Alexander Afanasyev
5 * Zhenkai Zhu
6 *
7 * BSD license, See the LICENSE file for more information
8 *
9 * Author: Zhenkai Zhu <zhenkai@cs.ucla.edu>
10 * Alexander Afanasyev <alexander.afanasyev@ucla.edu>
11 */
12
13#ifndef NDN_BLOB_H
14#define NDN_BLOB_H
15
16#include <vector>
17#include <cstddef>
Jeff Thompson4454bf72013-06-18 13:33:12 -070018#include <boost/shared_ptr.hpp>
Jeff Thompsonfa306642013-06-17 15:06:57 -070019
20namespace ndn {
21
Jeff Thompsonfa306642013-06-17 15:06:57 -070022/**
23 * @brief Class representing a general-use binary blob
24 */
25class Blob : public std::vector<char>
26{
27public:
28 /**
29 * @brief Creates an empty blob
30 */
31 Blob ()
32 {
33 }
34
35 Blob (const void *buf, size_t length)
36 : std::vector<char> (reinterpret_cast<const char*> (buf), reinterpret_cast<const char*> (buf) + length)
37 {
38 }
39
40 /**
41 * @brief Get pointer to the first byte of the binary blob
42 */
43 inline char*
44 buf ()
45 {
46 return &front ();
47 }
48
49 /**
50 * @brief Get const pointer to the first byte of the binary blob
51 */
52 inline const char*
53 buf () const
54 {
55 return &front ();
56 }
57};
58
59} // ndn
60
61#endif // NDN_BLOB_H