rippled
Loading...
Searching...
No Matches
ReadViewFwdRange.h
1#pragma once
2
3#include <cstddef>
4#include <memory>
5#include <optional>
6
7namespace xrpl {
8
9class ReadView;
10
11namespace detail {
12
13// A type-erased ForwardIterator
14//
15template <class ValueType>
17{
18public:
20
21 using value_type = ValueType;
22
23 ReadViewFwdIter() = default;
26 operator=(ReadViewFwdIter const&) = default;
27
28 virtual ~ReadViewFwdIter() = default;
29
31 copy() const = 0;
32
33 virtual bool
34 equal(ReadViewFwdIter const& impl) const = 0;
35
36 virtual void
37 increment() = 0;
38
39 virtual value_type
40 dereference() const = 0;
41};
42
43// A range using type-erased ForwardIterator
44//
45template <class ValueType>
47{
48public:
50
51 static_assert(
53 "ReadViewFwdRange move and move assign constructors should be "
54 "noexcept");
55
57 {
58 public:
59 using value_type = ValueType;
60
61 using pointer = value_type const*;
62
63 using reference = value_type const&;
64
66
68
69 iterator() = default;
70
71 iterator(iterator const& other);
72 iterator(iterator&& other) noexcept;
73
74 // Used by the implementation
75 explicit iterator(ReadView const* view, std::unique_ptr<iter_base> impl);
76
78 operator=(iterator const& other);
79
81 operator=(iterator&& other) noexcept;
82
83 bool
84 operator==(iterator const& other) const;
85
86 bool
87 operator!=(iterator const& other) const;
88
89 // Can throw
91 operator*() const;
92
93 // Can throw
95 operator->() const;
96
99
102
103 private:
104 ReadView const* view_ = nullptr;
107 };
108
111
113
114 using value_type = ValueType;
115
119 operator=(ReadViewFwdRange const&) = default;
120
121 explicit ReadViewFwdRange(ReadView const& view) : view_(&view)
122 {
123 }
124
125protected:
127};
128
129} // namespace detail
130} // namespace xrpl
A view into a ledger.
Definition ReadView.h:31
virtual ~ReadViewFwdIter()=default
virtual value_type dereference() const =0
ReadViewFwdIter(ReadViewFwdIter const &)=default
virtual std::unique_ptr< ReadViewFwdIter > copy() const =0
ReadViewFwdIter & operator=(ReadViewFwdIter const &)=default
virtual bool equal(ReadViewFwdIter const &impl) const =0
bool operator!=(iterator const &other) const
iterator & operator=(iterator &&other) noexcept
bool operator==(iterator const &other) const
iterator(iterator &&other) noexcept
iterator & operator=(iterator const &other)
iterator(ReadView const *view, std::unique_ptr< iter_base > impl)
ReadViewFwdRange & operator=(ReadViewFwdRange const &)=default
ReadViewFwdRange(ReadViewFwdRange const &)=default
ReadViewFwdRange(ReadView const &view)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5