rippled
Loading...
Searching...
No Matches
BookDirs.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_BOOK_DIRS_H_INCLUDED
21#define RIPPLE_LEDGER_BOOK_DIRS_H_INCLUDED
22
23#include <xrpld/ledger/ReadView.h>
24
25#include <xrpl/beast/utility/Journal.h>
26
27namespace ripple {
28
30{
31private:
32 ReadView const* view_ = nullptr;
37 unsigned int entry_ = 0;
39
40public:
41 class const_iterator;
43
44 BookDirs(ReadView const&, Book const&);
45
47 begin() const;
48
50 end() const;
51};
52
54{
55public:
57 using pointer = value_type const*;
58 using reference = value_type const&;
61
62 const_iterator() = default;
63
64 bool
65 operator==(const_iterator const& other) const;
66
67 bool
68 operator!=(const_iterator const& other) const
69 {
70 return !(*this == other);
71 }
72
74 operator*() const;
75
77 operator->() const
78 {
79 return &**this;
80 }
81
83 operator++();
84
86 operator++(int);
87
88private:
89 friend class BookDirs;
90
92 ReadView const& view,
93 uint256 const& root,
94 uint256 const& dir_key)
95 : view_(&view), root_(root), key_(dir_key), cur_key_(dir_key)
96 {
97 }
98
99 ReadView const* view_ = nullptr;
105 unsigned int entry_ = 0;
108
110};
111
112} // namespace ripple
113
114#endif
A generic endpoint for log messages.
Definition: Journal.h:60
bool operator==(const_iterator const &other) const
Definition: BookDirs.cpp:69
const_iterator & operator++()
Definition: BookDirs.cpp:95
reference operator*() const
Definition: BookDirs.cpp:84
const_iterator(ReadView const &view, uint256 const &root, uint256 const &dir_key)
Definition: BookDirs.h:91
std::optional< value_type > cache_
Definition: BookDirs.h:107
value_type const & reference
Definition: BookDirs.h:58
static beast::Journal j_
Definition: BookDirs.h:109
bool operator!=(const_iterator const &other) const
Definition: BookDirs.h:68
value_type const * pointer
Definition: BookDirs.h:57
std::shared_ptr< SLE const > sle_
Definition: BookDirs.h:104
pointer operator->() const
Definition: BookDirs.h:77
uint256 const next_quality_
Definition: BookDirs.h:34
unsigned int entry_
Definition: BookDirs.h:37
ReadView const * view_
Definition: BookDirs.h:32
uint256 const root_
Definition: BookDirs.h:33
std::shared_ptr< SLE const > sle_
Definition: BookDirs.h:36
const_iterator begin() const
Definition: BookDirs.cpp:46
std::shared_ptr< SLE const > value_type
Definition: BookDirs.h:42
const_iterator end() const
Definition: BookDirs.cpp:60
uint256 index_
Definition: BookDirs.h:38
uint256 const key_
Definition: BookDirs.h:35
Specifies an order book.
Definition: Book.h:35
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