1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
// Copyright Contributors to the DNF5 project.
// Copyright Contributors to the libdnf project.
// SPDX-License-Identifier: LGPL-2.1-or-later
//
// This file is part of libdnf: https://github.com/rpm-software-management/libdnf/
//
// Libdnf is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 2.1 of the License, or
// (at your option) any later version.
//
// Libdnf is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libdnf. If not, see <https://www.gnu.org/licenses/>.
#include "libdnf5/advisory/advisory_set_iterator.hpp"
#include "advisory_set_impl.hpp"
#include "solv/solv_map.hpp"
namespace libdnf5::advisory {
class AdvisorySetIterator::Impl : private libdnf5::solv::SolvMap::iterator {
private:
Impl(const AdvisorySet & advisory_set)
: libdnf5::solv::SolvMap::iterator(advisory_set.p_impl->get_map()),
advisory_set{&advisory_set} {}
AdvisorySetIterator::Impl & operator++() {
libdnf5::solv::SolvMap::iterator::operator++();
return *this;
}
const AdvisorySet * advisory_set;
friend AdvisorySetIterator;
};
AdvisorySetIterator::AdvisorySetIterator(const AdvisorySet & advisory_set) : p_impl{new Impl(advisory_set)} {}
AdvisorySetIterator::AdvisorySetIterator(const AdvisorySetIterator & other) : p_impl{new Impl(*other.p_impl)} {}
AdvisorySetIterator::~AdvisorySetIterator() = default;
AdvisorySetIterator & AdvisorySetIterator::operator=(const AdvisorySetIterator & other) {
*p_impl = *other.p_impl;
return *this;
}
AdvisorySetIterator AdvisorySetIterator::begin(const AdvisorySet & advisory_set) {
AdvisorySetIterator it(advisory_set);
it.begin();
return it;
}
AdvisorySetIterator AdvisorySetIterator::end(const AdvisorySet & advisory_set) {
AdvisorySetIterator it(advisory_set);
it.end();
return it;
}
void AdvisorySetIterator::begin() {
p_impl->begin();
}
void AdvisorySetIterator::end() {
p_impl->end();
}
Advisory AdvisorySetIterator::operator*() {
return {p_impl->advisory_set->get_base(), libdnf5::advisory::AdvisoryId(**p_impl)};
}
AdvisorySetIterator & AdvisorySetIterator::operator++() {
++*p_impl;
return *this;
}
AdvisorySetIterator AdvisorySetIterator::operator++(int) {
AdvisorySetIterator it(*this);
++*p_impl;
return it;
}
bool AdvisorySetIterator::operator==(const AdvisorySetIterator & other) const {
return *p_impl == *other.p_impl;
}
bool AdvisorySetIterator::operator!=(const AdvisorySetIterator & other) const {
return *p_impl != *other.p_impl;
}
} // namespace libdnf5::advisory
|