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-2019 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_SECURITY_V2_ADDITIONAL_DESCRIPTION_HPP
23 #define NDN_SECURITY_V2_ADDITIONAL_DESCRIPTION_HPP
24 
27 #include "ndn-cxx/encoding/tlv.hpp"
28 
29 #include <map>
30 
31 namespace ndn {
32 namespace security {
33 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 
91  begin() const;
92 
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 } // namespace v2
141 
143 
144 } // namespace security
145 } // namespace ndn
146 
147 #endif // NDN_SECURITY_V2_ADDITIONAL_DESCRIPTION_HPP
common.hpp
Common includes and macros used throughout the library.
ndn::security::v2::AdditionalDescription::get
const std::string & get(const std::string &key) const
Definition: additional-description.cpp:47
tlv.hpp
ndn::security::v2::AdditionalDescription::set
void set(const std::string &key, const std::string &value)
Definition: additional-description.cpp:57
ndn::security::v2::AdditionalDescription::begin
iterator begin()
Definition: additional-description.cpp:69
ndn::security::v2::AdditionalDescription::wireEncode
const Block & wireEncode() const
Encode ValidityPeriod into TLV block.
Definition: additional-description.cpp:116
ndn::security::v2::AdditionalDescription::operator!=
friend bool operator!=(const AdditionalDescription &lhs, const AdditionalDescription &rhs)
Definition: additional-description.hpp:124
block.hpp
ndn::security::v2::AdditionalDescription::end
iterator end()
Definition: additional-description.cpp:75
ndn::security::v2::NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS
NDN_CXX_DECLARE_WIRE_ENCODE_INSTANTIATIONS(AdditionalDescription)
ndn::security::v2::AdditionalDescription::AdditionalDescription
AdditionalDescription()=default
Create an empty AdditionalDescription.
ndn::security::v2::AdditionalDescription::has
bool has(const std::string &key) const
Definition: additional-description.cpp:63
ndn::security::v2::AdditionalDescription::wireDecode
void wireDecode(const Block &wire)
Decode ValidityPeriod from TLV block.
Definition: additional-description.cpp:134
ndn::security::v2::operator<<
std::ostream & operator<<(std::ostream &os, const AdditionalDescription &desc)
Definition: additional-description.cpp:167
ndn::security::v2::AdditionalDescription::size
size_t size() const
Definition: additional-description.hpp:73
ndn::security::v2::AdditionalDescription::iterator
std::map< std::string, std::string >::iterator iterator
Definition: additional-description.hpp:48
ndn::security::v2::AdditionalDescription::const_iterator
std::map< std::string, std::string >::const_iterator const_iterator
Definition: additional-description.hpp:49
ndn::security::v2::AdditionalDescription::Error
Definition: additional-description.hpp:43
ndn::encoding::EncodingImpl
Definition: encoding-buffer-fwd.hpp:36
ndn::Block
Represents a TLV element of NDN packet format.
Definition: block.hpp:43
ndn::security::v2::AdditionalDescription
Abstraction of AdditionalDescription.
Definition: additional-description.hpp:40
ndn::security::v2::AdditionalDescription::empty
bool empty() const
Definition: additional-description.hpp:79
ndn::tlv::AdditionalDescription
@ AdditionalDescription
Definition: tlv.hpp:147
ndn::tlv::Error
represents an error in TLV encoding or decoding
Definition: tlv.hpp:53
ndn::tlv::Error::Error
Error(const char *expectedType, uint32_t actualType)
Definition: tlv.cpp:27
ndn::security::v2::AdditionalDescription::operator==
friend bool operator==(const AdditionalDescription &lhs, const AdditionalDescription &rhs)
Definition: additional-description.hpp:118
ndn
Copyright (c) 2011-2015 Regents of the University of California.
Definition: ndn-strategy-choice-helper.hpp:34