mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-03 08:46:46 +00:00
110 lines
2.4 KiB
C++
110 lines
2.4 KiB
C++
#pragma once
|
|
|
|
namespace xrpl::detail {
|
|
|
|
template <class ValueType>
|
|
ReadViewFwdRange<ValueType>::Iterator::Iterator(Iterator const& other)
|
|
: view_(other.view_), impl_(other.impl_ ? other.impl_->copy() : nullptr), cache_(other.cache_)
|
|
{
|
|
}
|
|
|
|
template <class ValueType>
|
|
ReadViewFwdRange<ValueType>::Iterator::Iterator(Iterator&& other) noexcept
|
|
: view_(other.view_), impl_(std::move(other.impl_)), cache_(std::move(other.cache_))
|
|
{
|
|
}
|
|
|
|
template <class ValueType>
|
|
ReadViewFwdRange<ValueType>::Iterator::Iterator(
|
|
ReadView const* view,
|
|
std::unique_ptr<iter_base> impl)
|
|
: view_(view), impl_(std::move(impl))
|
|
{
|
|
}
|
|
|
|
template <class ValueType>
|
|
auto
|
|
ReadViewFwdRange<ValueType>::Iterator::operator=(Iterator const& other) -> Iterator&
|
|
{
|
|
if (this != &other)
|
|
{
|
|
view_ = other.view_;
|
|
impl_ = other.impl_ ? other.impl_->copy() : nullptr;
|
|
cache_ = other.cache_;
|
|
}
|
|
return *this;
|
|
}
|
|
|
|
template <class ValueType>
|
|
auto
|
|
ReadViewFwdRange<ValueType>::Iterator::operator=(Iterator&& other) noexcept -> Iterator&
|
|
{
|
|
if (this != &other)
|
|
{
|
|
view_ = other.view_;
|
|
impl_ = std::move(other.impl_);
|
|
cache_ = std::move(other.cache_);
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
template <class ValueType>
|
|
bool
|
|
ReadViewFwdRange<ValueType>::Iterator::operator==(Iterator const& other) const
|
|
{
|
|
XRPL_ASSERT(
|
|
view_ == other.view_,
|
|
"xrpl::detail::ReadViewFwdRange::iterator::operator==(iterator) "
|
|
"const : input view match");
|
|
|
|
if (impl_ != nullptr && other.impl_ != nullptr)
|
|
return impl_->equal(*other.impl_);
|
|
|
|
return impl_ == other.impl_;
|
|
}
|
|
|
|
template <class ValueType>
|
|
bool
|
|
ReadViewFwdRange<ValueType>::Iterator::operator!=(Iterator const& other) const
|
|
{
|
|
return !(*this == other);
|
|
}
|
|
|
|
template <class ValueType>
|
|
auto
|
|
ReadViewFwdRange<ValueType>::Iterator::operator*() const -> reference
|
|
{
|
|
if (!cache_)
|
|
cache_ = impl_->dereference();
|
|
return *cache_;
|
|
}
|
|
|
|
template <class ValueType>
|
|
auto
|
|
ReadViewFwdRange<ValueType>::Iterator::operator->() const -> pointer
|
|
{
|
|
return &**this;
|
|
}
|
|
|
|
template <class ValueType>
|
|
auto
|
|
ReadViewFwdRange<ValueType>::Iterator::operator++() -> Iterator&
|
|
{
|
|
impl_->increment();
|
|
cache_.reset();
|
|
return *this;
|
|
}
|
|
|
|
template <class ValueType>
|
|
auto
|
|
ReadViewFwdRange<ValueType>::Iterator::operator++(int) -> Iterator
|
|
{
|
|
Iterator prev(view_, impl_->copy());
|
|
prev.cache_ = std::move(cache_);
|
|
++(*this);
|
|
return prev;
|
|
}
|
|
|
|
} // namespace xrpl::detail
|