rippled
Loading...
Searching...
No Matches
ReadViewFwdRange.h
1#ifndef XRPL_LEDGER_READVIEWFWDRANGE_H_INCLUDED
2#define XRPL_LEDGER_READVIEWFWDRANGE_H_INCLUDED
3
4#include <cstddef>
5#include <memory>
6#include <optional>
7
8namespace ripple {
9
10class ReadView;
11
12namespace detail {
13
14// A type-erased ForwardIterator
15//
16template <class ValueType>
18{
19public:
21
22 using value_type = ValueType;
23
24 ReadViewFwdIter() = default;
27 operator=(ReadViewFwdIter const&) = default;
28
29 virtual ~ReadViewFwdIter() = default;
30
32 copy() const = 0;
33
34 virtual bool
35 equal(ReadViewFwdIter const& impl) const = 0;
36
37 virtual void
38 increment() = 0;
39
40 virtual value_type
41 dereference() const = 0;
42};
43
44// A range using type-erased ForwardIterator
45//
46template <class ValueType>
48{
49public:
51
52 static_assert(
54 "ReadViewFwdRange move and move assign constructors should be "
55 "noexcept");
56
58 {
59 public:
60 using value_type = ValueType;
61
62 using pointer = value_type const*;
63
64 using reference = value_type const&;
65
67
69
70 iterator() = default;
71
72 iterator(iterator const& other);
73 iterator(iterator&& other) noexcept;
74
75 // Used by the implementation
76 explicit iterator(
77 ReadView const* view,
79
81 operator=(iterator const& other);
82
84 operator=(iterator&& other) noexcept;
85
86 bool
87 operator==(iterator const& other) const;
88
89 bool
90 operator!=(iterator const& other) const;
91
92 // Can throw
94 operator*() const;
95
96 // Can throw
98 operator->() const;
99
100 iterator&
102
105
106 private:
107 ReadView const* view_ = nullptr;
110 };
111
114
116
117 using value_type = ValueType;
118
122 operator=(ReadViewFwdRange const&) = default;
123
124 explicit ReadViewFwdRange(ReadView const& view) : view_(&view)
125 {
126 }
127
128protected:
130};
131
132} // namespace detail
133} // namespace ripple
134
135#endif
A view into a ledger.
Definition ReadView.h:32
virtual value_type dereference() const =0
virtual std::unique_ptr< ReadViewFwdIter > copy() const =0
virtual ~ReadViewFwdIter()=default
ReadViewFwdIter(ReadViewFwdIter const &)=default
virtual bool equal(ReadViewFwdIter const &impl) const =0
ReadViewFwdIter & operator=(ReadViewFwdIter const &)=default
iterator(ReadView const *view, std::unique_ptr< iter_base > impl)
iterator & operator=(iterator const &other)
iterator & operator=(iterator &&other) noexcept
iterator(iterator &&other) noexcept
bool operator!=(iterator const &other) const
bool operator==(iterator const &other) const
ReadViewFwdRange(ReadViewFwdRange const &)=default
ReadViewFwdRange & operator=(ReadViewFwdRange const &)=default
ReadViewFwdRange(ReadView const &view)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6