blob: 85fd71bee1c8b55dde45d236f22ec4c21e5fbe94 [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>
18
19namespace ndn {
20
21/**
22 * @brief Class representing a general-use binary blob
23 */
24class Blob : public std::vector<char>
25{
26public:
27 /**
28 * @brief Creates an empty blob
29 */
30 Blob ()
31 {
32 }
33
34 Blob (const void *buf, size_t length)
35 : std::vector<char> (reinterpret_cast<const char*> (buf), reinterpret_cast<const char*> (buf) + length)
36 {
37 }
38
39 /**
40 * @brief Get pointer to the first byte of the binary blob
41 */
42 inline char*
43 buf ()
44 {
45 return &front ();
46 }
47
48 /**
49 * @brief Get const pointer to the first byte of the binary blob
50 */
51 inline const char*
52 buf () const
53 {
54 return &front ();
55 }
56};
57
58} // ndn
59
60#endif // NDN_BLOB_H