Kagome
Polkadot Runtime Engine in C++17
map_cursor.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_STORAGE_MAP_CURSOR_HPP
7 #define KAGOME_STORAGE_MAP_CURSOR_HPP
8 
9 #include <optional>
10 
11 #include "outcome/outcome.hpp"
12 
13 namespace kagome::storage::face {
14 
21  template <typename K, typename V, typename KView = K>
22  struct MapCursor {
23  virtual ~MapCursor() = default;
24 
29  virtual outcome::result<bool> seekFirst() = 0;
30 
35  virtual outcome::result<bool> seek(const KView &key) = 0;
36 
41  virtual outcome::result<bool> seekLast() = 0;
42 
48  virtual bool isValid() const = 0;
49 
53  virtual outcome::result<void> next() = 0;
54 
59  virtual std::optional<K> key() const = 0;
60 
65  virtual std::optional<V> value() const = 0;
66  };
67 
68 } // namespace kagome::storage::face
69 
70 #endif // KAGOME_STORAGE_MAP_CURSOR_HPP
An abstraction over generic map cursor.
Definition: map_cursor.hpp:22
virtual std::optional< V > value() const =0
Getter for value of the element currently pointed at.
virtual std::optional< K > key() const =0
Getter for the key of the element currently pointed at.
virtual outcome::result< void > next()=0
Make step forward.
virtual bool isValid() const =0
Is the cursor in a valid state?
virtual outcome::result< bool > seekFirst()=0
Same as std::begin(...);.
virtual outcome::result< bool > seek(const KView &key)=0
Find given key and seek iterator to this key.
virtual outcome::result< bool > seekLast()=0
Same as std::rbegin(...);, e.g. points to the last valid element.