blob: fa8d058c376bcc4013a72c8973a8a3b5c926148d [file] [log] [blame]
Yingdi Yub8f8b342015-04-27 11:06:42 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
Yingdi Yu6ee2d362015-07-16 21:48:05 -07003 * Copyright (c) 2013-2017 Regents of the University of California.
Yingdi Yub8f8b342015-04-27 11:06:42 -07004 *
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#include "certificate-container.hpp"
23#include "pib-impl.hpp"
24
25namespace ndn {
26namespace security {
Yingdi Yu6ee2d362015-07-16 21:48:05 -070027namespace pib {
Yingdi Yub8f8b342015-04-27 11:06:42 -070028
29CertificateContainer::const_iterator::const_iterator(std::set<Name>::const_iterator it,
30 shared_ptr<PibImpl> impl)
31 : m_it(it)
32 , m_impl(impl)
33{
34}
35
Yingdi Yu6ee2d362015-07-16 21:48:05 -070036v2::Certificate
Yingdi Yub8f8b342015-04-27 11:06:42 -070037CertificateContainer::const_iterator::operator*()
38{
39 return m_impl->getCertificate(*m_it);
40}
41
42CertificateContainer::const_iterator&
43CertificateContainer::const_iterator::operator++()
44{
45 ++m_it;
46 return *this;
47}
48
49CertificateContainer::const_iterator
50CertificateContainer::const_iterator::operator++(int)
51{
52 const_iterator it(m_it, m_impl);
53 ++m_it;
54 return it;
55}
56
57bool
58CertificateContainer::const_iterator::operator==(const const_iterator& other)
59{
60 return (m_impl == other.m_impl && m_it == other.m_it);
61}
62
63bool
64CertificateContainer::const_iterator::operator!=(const const_iterator& other)
65{
66 return !(*this == other);
67}
68
69CertificateContainer::CertificateContainer()
70{
71}
72
73CertificateContainer::CertificateContainer(std::set<Name>&& certNames,
74 shared_ptr<PibImpl> impl)
75 : m_certNames(certNames)
76 , m_impl(impl)
77{
78}
79
80CertificateContainer::const_iterator
81CertificateContainer::begin() const
82{
83 return const_iterator(m_certNames.begin(), m_impl);
84}
85
86CertificateContainer::const_iterator
87CertificateContainer::end() const
88{
89 return const_iterator(m_certNames.end(), m_impl);
90}
91
92CertificateContainer::const_iterator
93CertificateContainer::find(const Name& certName) const
94{
95 return const_iterator(m_certNames.find(certName), m_impl);
96}
97
98size_t
99CertificateContainer::size() const
100{
101 return m_certNames.size();
102}
103
Yingdi Yu6ee2d362015-07-16 21:48:05 -0700104} // namespace pib
Yingdi Yub8f8b342015-04-27 11:06:42 -0700105} // namespace security
106} // namespace ndn