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