rippled
Loading...
Searching...
No Matches
Dir.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2015 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_LEDGER_DIR_H_INCLUDED
21#define RIPPLE_LEDGER_DIR_H_INCLUDED
22
23#include <xrpl/ledger/ReadView.h>
24#include <xrpl/protocol/Indexes.h>
25
26namespace ripple {
27
40class Dir
41{
42private:
43 ReadView const* view_ = nullptr;
46 STVector256 const* indexes_ = nullptr;
47
48public:
49 class const_iterator;
51
52 Dir(ReadView const&, Keylet const&);
53
55 begin() const;
56
58 end() const;
59};
60
62{
63public:
65 using pointer = value_type const*;
66 using reference = value_type const&;
69
70 bool
71 operator==(const_iterator const& other) const;
72
73 bool
74 operator!=(const_iterator const& other) const
75 {
76 return !(*this == other);
77 }
78
80 operator*() const;
81
83 operator->() const
84 {
85 return &**this;
86 }
87
89 operator++();
90
92 operator++(int);
93
95 next_page();
96
98 page_size();
99
100 Keylet const&
101 page() const
102 {
103 return page_;
104 }
105
106 uint256
107 index() const
108 {
109 return index_;
110 }
111
112private:
113 friend class Dir;
114
115 const_iterator(ReadView const& view, Keylet const& root, Keylet const& page)
116 : view_(&view), root_(root), page_(page)
117 {
118 }
119
120 ReadView const* view_ = nullptr;
126 STVector256 const* indexes_ = nullptr;
128};
129
130} // namespace ripple
131
132#endif
Keylet const & page() const
Definition Dir.h:101
bool operator==(const_iterator const &other) const
Definition Dir.cpp:58
const_iterator(ReadView const &view, Keylet const &root, Keylet const &page)
Definition Dir.h:115
const_iterator & next_page()
Definition Dir.cpp:108
std::vector< uint256 >::const_iterator it_
Definition Dir.h:127
bool operator!=(const_iterator const &other) const
Definition Dir.h:74
reference operator*() const
Definition Dir.cpp:70
std::size_t page_size()
Definition Dir.cpp:137
uint256 index() const
Definition Dir.h:107
ReadView const * view_
Definition Dir.h:120
value_type const & reference
Definition Dir.h:66
std::optional< value_type > cache_
Definition Dir.h:124
STVector256 const * indexes_
Definition Dir.h:126
const_iterator & operator++()
Definition Dir.cpp:81
std::shared_ptr< SLE const > sle_
Definition Dir.h:125
value_type const * pointer
Definition Dir.h:65
pointer operator->() const
Definition Dir.h:83
A class that simplifies iterating ledger directory pages.
Definition Dir.h:41
std::shared_ptr< SLE const > sle_
Definition Dir.h:45
const_iterator end() const
Definition Dir.cpp:52
ReadView const * view_
Definition Dir.h:43
std::shared_ptr< SLE const > value_type
Definition Dir.h:50
STVector256 const * indexes_
Definition Dir.h:46
Keylet root_
Definition Dir.h:44
const_iterator begin() const
Definition Dir.cpp:34
A view into a ledger.
Definition ReadView.h:51
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
Number root(Number f, unsigned d)
Definition Number.cpp:636
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:39