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 <xrpld/ledger/ReadView.h>
24
25#include <xrpl/protocol/Indexes.h>
26
27namespace ripple {
28
41class Dir
42{
43private:
44 ReadView const* view_ = nullptr;
47 STVector256 const* indexes_ = nullptr;
48
49public:
50 class const_iterator;
52
53 Dir(ReadView const&, Keylet const&);
54
56 begin() const;
57
59 end() const;
60};
61
63{
64public:
66 using pointer = value_type const*;
67 using reference = value_type const&;
70
71 bool
72 operator==(const_iterator const& other) const;
73
74 bool
75 operator!=(const_iterator const& other) const
76 {
77 return !(*this == other);
78 }
79
81 operator*() const;
82
84 operator->() const
85 {
86 return &**this;
87 }
88
90 operator++();
91
93 operator++(int);
94
96 next_page();
97
99 page_size();
100
101 Keylet const&
102 page() const
103 {
104 return page_;
105 }
106
107 uint256
108 index() const
109 {
110 return index_;
111 }
112
113private:
114 friend class Dir;
115
116 const_iterator(ReadView const& view, Keylet const& root, Keylet const& page)
117 : view_(&view), root_(root), page_(page)
118 {
119 }
120
121 ReadView const* view_ = nullptr;
127 STVector256 const* indexes_ = nullptr;
129};
130
131} // namespace ripple
132
133#endif
Keylet const & page() const
Definition: Dir.h:102
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:116
const_iterator & next_page()
Definition: Dir.cpp:108
std::vector< uint256 >::const_iterator it_
Definition: Dir.h:128
bool operator!=(const_iterator const &other) const
Definition: Dir.h:75
reference operator*() const
Definition: Dir.cpp:70
std::size_t page_size()
Definition: Dir.cpp:137
uint256 index() const
Definition: Dir.h:108
ReadView const * view_
Definition: Dir.h:121
value_type const & reference
Definition: Dir.h:67
std::optional< value_type > cache_
Definition: Dir.h:125
STVector256 const * indexes_
Definition: Dir.h:127
const_iterator & operator++()
Definition: Dir.cpp:81
std::shared_ptr< SLE const > sle_
Definition: Dir.h:126
value_type const * pointer
Definition: Dir.h:66
pointer operator->() const
Definition: Dir.h:84
A class that simplifies iterating ledger directory pages.
Definition: Dir.h:42
std::shared_ptr< SLE const > sle_
Definition: Dir.h:46
const_iterator end() const
Definition: Dir.cpp:52
ReadView const * view_
Definition: Dir.h:44
std::shared_ptr< SLE const > value_type
Definition: Dir.h:51
STVector256 const * indexes_
Definition: Dir.h:47
Keylet root_
Definition: Dir.h:45
const_iterator begin() const
Definition: Dir.cpp:34
A view into a ledger.
Definition: ReadView.h:52
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
Number root(Number f, unsigned d)
Definition: Number.cpp:636
A pair of SHAMap key and LedgerEntryType.
Definition: Keylet.h:39