NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
additional-description.hpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2013-2021 Regents of the University of California.
4  *
5  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
6  *
7  * ndn-cxx library is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License as published by the Free Software
9  * Foundation, either version 3 of the License, or (at your option) any later version.
10  *
11  * ndn-cxx library is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13  * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
14  *
15  * You should have received copies of the GNU General Public License and GNU Lesser
16  * General Public License along with ndn-cxx, e.g., in COPYING.md file. If not, see
17  * <http://www.gnu.org/licenses/>.
18  *
19  * See AUTHORS.md for complete list of ndn-cxx authors and contributors.
20  */
21 
22 #ifndef NDN_CXX_SECURITY_ADDITIONAL_DESCRIPTION_HPP
23 #define NDN_CXX_SECURITY_ADDITIONAL_DESCRIPTION_HPP
24 
27 #include "ndn-cxx/encoding/tlv.hpp"
28 
29 #include <map>
30 
31 namespace ndn {
32 namespace security {
33 inline namespace v2 {
34 
40 {
41 public:
42  class Error : public tlv::Error
43  {
44  public:
45  using tlv::Error::Error;
46  };
47 
48  typedef std::map<std::string, std::string>::iterator iterator;
49  typedef std::map<std::string, std::string>::const_iterator const_iterator;
50 
51 public:
55  AdditionalDescription() = default;
56 
60  explicit
61  AdditionalDescription(const Block& block);
62 
63  const std::string&
64  get(const std::string& key) const;
65 
66  void
67  set(const std::string& key, const std::string& value);
68 
69  bool
70  has(const std::string& key) const;
71 
72  size_t
73  size() const
74  {
75  return m_info.size();
76  }
77 
78  bool
79  empty() const
80  {
81  return m_info.empty();
82  }
83 
84  iterator
85  begin();
86 
87  iterator
88  end();
89 
90  const_iterator
91  begin() const;
92 
93  const_iterator
94  end() const;
95 
98  template<encoding::Tag TAG>
99  size_t
100  wireEncode(EncodingImpl<TAG>& encoder) const;
101 
104  const Block&
105  wireEncode() const;
106 
110  void
111  wireDecode(const Block& wire);
112 
113 private: // EqualityComparable concept
114  // NOTE: the following "hidden friend" operators are available via
115  // argument-dependent lookup only and must be defined inline.
116 
117  friend bool
119  {
120  return lhs.m_info == rhs.m_info;
121  }
122 
123  friend bool
125  {
126  return lhs.m_info != rhs.m_info;
127  }
128 
129 private:
130  std::map<std::string, std::string> m_info;
131 
132  mutable Block m_wire;
133 };
134 
136 
137 std::ostream&
138 operator<<(std::ostream& os, const AdditionalDescription& desc);
139 
140 } // inline namespace v2
141 
142 } // namespace security
143 } // namespace ndn
144 
145 #endif // NDN_CXX_SECURITY_ADDITIONAL_DESCRIPTION_HPP
bool has(const std::string &key) const
Copyright (c) 2011-2015 Regents of the University of California.
std::map< std::string, std::string >::const_iterator const_iterator
Represents an AdditionalDescription TLV element.
void wireDecode(const Block &wire)
Decode ValidityPeriod from TLV block.
friend bool operator==(const AdditionalDescription &lhs, const AdditionalDescription &rhs)
Represents a TLV element of the NDN packet format.
Definition: block.hpp:44
std::map< std::string, std::string >::iterator iterator
const Block & wireEncode() const
Encode ValidityPeriod into TLV block.
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdditionalDescription)
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &desc)
Common includes and macros used throughout the library.
friend bool operator!=(const AdditionalDescription &lhs, const AdditionalDescription &rhs)
AdditionalDescription()=default
Create an empty AdditionalDescription.
Error(const char *expectedType, uint32_t actualType)
Definition: tlv.cpp:27
represents an error in TLV encoding or decoding
Definition: tlv.hpp:52