rippled
Loading...
Searching...
No Matches
STLedgerEntry.h
1#pragma once
2
3#include <xrpl/protocol/Indexes.h>
4#include <xrpl/protocol/STObject.h>
5
6namespace xrpl {
7
8class Rules;
9namespace test {
10class Invariants_test;
11} // namespace test
12
13class STLedgerEntry final : public STObject, public CountedObject<STLedgerEntry>
14{
17
18public:
23
25 explicit STLedgerEntry(Keylet const& k);
27 STLedgerEntry(SerialIter& sit, uint256 const& index);
28 STLedgerEntry(SerialIter&& sit, uint256 const& index);
29 STLedgerEntry(STObject const& object, uint256 const& index);
30
32 getSType() const override;
33
35 getFullText() const override;
36
38 getText() const override;
39
41 getJson(JsonOptions options = JsonOptions::none) const override;
42
47 uint256 const&
48 key() const;
49
51 getType() const;
52
53 // is this a ledger entry that can be threaded
54 bool
55 isThreadedType(Rules const& rules) const;
56
57 bool
58 thread(
59 uint256 const& txID,
60 std::uint32_t ledgerSeq,
61 uint256& prevTxID,
62 std::uint32_t& prevLedgerID);
63
64private:
65 /* Make STObject comply with the template for this SLE type
66 Can throw
67 */
68 void
69 setSLEType();
70
71 friend test::Invariants_test; // this test wants access to the private
72 // type_
73
74 STBase*
75 copy(std::size_t n, void* buf) const override;
76 STBase*
77 move(std::size_t n, void* buf) override;
78
79 friend class detail::STVar;
80};
81
82using SLE = STLedgerEntry;
83
85 : STLedgerEntry(Keylet(type, key))
86{
87}
88
90 SerialIter&& sit, // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
91 uint256 const& index)
92 : STLedgerEntry(sit, index)
93{
94}
95
100inline uint256 const&
102{
103 return key_;
104}
105
106inline LedgerEntryType
108{
109 return type_;
110}
111
112} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
Tracks the number of instances of an object.
Rules controlling protocol behavior.
Definition Rules.h:18
A type which can be exported to a well known binary format.
Definition STBase.h:115
LedgerEntryType type_
uint256 const & key() const
Returns the 'key' (or 'index') of this item.
Json::Value getJson(JsonOptions options=JsonOptions::none) const override
std::string getFullText() const override
STBase * copy(std::size_t n, void *buf) const override
bool thread(uint256 const &txID, std::uint32_t ledgerSeq, uint256 &prevTxID, std::uint32_t &prevLedgerID)
LedgerEntryType getType() const
SerializedTypeID getSType() const override
STLedgerEntry(Keylet const &k)
Create an empty object with the given key and type.
std::string getText() const override
bool isThreadedType(Rules const &rules) const
STBase * move(std::size_t n, void *buf) override
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
SerializedTypeID
Definition SField.h:90
LedgerEntryType
Identifiers for on-ledger objects.
Note, should be treated as flags that can be | and &.
Definition STBase.h:17
A pair of SHAMap key and LedgerEntryType.
Definition Keylet.h:19