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