blob: b8cb39f59a41791b1d5e1bdffcf9f1d6e43725d1 [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_SIGNED_BLOB_H
14#define NDN_SIGNED_BLOB_H
15
16#include "blob.h"
17
18namespace ndn {
19
20/**
21 * @brief Class representing a blob, which has a signed portion (e.g., bytes of DATA packet)
22 */
23class SignedBlob : public Blob
24{
25public:
26 /**
27 * @brief Set signed portion of the blob
28 * @param offset An offset from the beginning of the blob
29 * @param size Size of the signed portion of the blob
30 */
31 inline void
32 setSignedPortion (size_t offset, size_t size);
33
34 /**
35 * @brief Get begin iterator to a signed portion of the blob
36 */
37 inline const_iterator
38 signed_begin () const;
39
40 /**
41 * @brief Get end iterator of a signed portion of the blob
42 */
43 inline const_iterator
44 signed_end () const;
45
46 /**
47 * @brief Get pointer to a first byte of the signed blob
48 */
49 inline const char*
50 signed_buf () const;
51
52 /**
53 * @brief Get size of the signed blob
54 */
55 inline size_t
56 signed_size () const;
57
58private:
59 const_iterator m_signedBegin;
60 const_iterator m_signedEnd;
61};
62
63
64inline void
65SignedBlob::setSignedPortion (size_t offset, size_t size)
66{
67 m_signedBegin = begin () + offset;
68 m_signedEnd = begin () + offset + size;
69}
70
71inline SignedBlob::const_iterator
72SignedBlob::signed_begin () const
73{
74 return m_signedBegin;
75}
76
77inline SignedBlob::const_iterator
78SignedBlob::signed_end () const
79{
80 return m_signedEnd;
81}
82
83inline const char*
84SignedBlob::signed_buf () const
85{
86 return &*m_signedBegin;
87}
88
89inline size_t
90SignedBlob::signed_size () const
91{
92 return m_signedEnd - m_signedBegin;
93}
94
Jeff Thompsonfa306642013-06-17 15:06:57 -070095} // ndn
96
97#endif // NDN_SIGNED_BLOB_H