3#include <xrpl/basics/base_uint.h>
4#include <xrpl/basics/contract.h>
5#include <xrpl/beast/utility/Journal.h>
6#include <xrpl/beast/utility/instrumentation.h>
7#include <xrpl/ledger/ApplyView.h>
8#include <xrpl/ledger/ReadView.h>
9#include <xrpl/protocol/Keylet.h>
10#include <xrpl/protocol/LedgerFormats.h>
11#include <xrpl/protocol/STLedgerEntry.h>
63 if (
auto const applyView =
dynamic_cast<ApplyView*
>(
const_cast<ReadView*
>(&view)))
64 return applyView->peek(key);
65 return view.
read(key);
90template <
typename ViewT, LedgerEntryType EntryType = ltANY>
149 "xrpl::SLEBase::SLEBase : adopted SLE matches bound entry type");
164 "xrpl::SLEBase::SLEBase : keylet matches bound entry type");
180 template <
typename OtherViewT, LedgerEntryType OtherType>
183 (OtherType == EntryType || EntryType ==
ltANY))
200 "xrpl::SLEBase::SLEBase : keylet matches bound entry type");
229 return sle_ !=
nullptr;
236 operator bool()
const
274 return sle_->getType();
479 [[no_unique_address]]
501 "SLEBase must stay a thin value type; it must not acquire a vtable");
A generic endpoint for log messages.
static Sink & getNullSink()
Returns a Sink which does nothing.
Writeable view to a ledger, for applying a transaction.
virtual SLE::const_pointer read(Keylet const &k) const =0
Return the state item associated with a key.
View-parameterized base class for all ledger entries.
void erase()
Erases the entry from the view.
SLEBase(SLEBase< OtherViewT, OtherType > const &other)
Converting constructor: writable → read-only.
bool exists() const
Returns true if the ledger entry exists.
beast::Journal journal() const
SLEBase & operator=(SLEBase &&)=delete
STLedgerEntry const * operator->() const
Const dereference operators (always available).
void insert()
Inserts the entry into the view.
SLEBase(SLE::const_pointer sle, ViewRefType view, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
Constructor for read-only context (adopt an already-fetched SLE).
Keylet keylet() const
Returns the keylet identifying this entry.
std::conditional_t< kIsWritable, SLE::pointer, SLE::const_pointer > SlePtrType
LedgerEntryType type() const
Returns the ledger entry type of this entry.
SlePtrType const & mutableRawSle()
Returns the underlying SLE for write access.
std::conditional_t< kIsWritable, Keylet, Empty > key_
ApplyView & applyView()
Returns the apply view for write operations.
STLedgerEntry * operator->()
Mutable dereference operators.
ReadView const & readView() const
static constexpr bool kIsWritable
static constexpr LedgerEntryType kEntryType
SLE::const_pointer rawSle() const
SLEBase(Keylet const &key, ApplyViewContext const &ctx, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
Constructor for writable context, for call sites that hold an ApplyViewContext (peek from ctx....
static constexpr bool kIsTyped
std::conditional_t< kIsWritable, ApplyView &, ReadView const & > ViewRefType
STLedgerEntry & operator*()
SLEBase(SLEBase &&)=default
SLEBase(SLEBase const &)=default
SLEBase & operator=(SLEBase const &)=delete
STLedgerEntry const & operator*() const
SLEBase(Keylet const &key, ApplyView &view, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
Constructor for writable context (peek from view by keylet).
SLEBase(Keylet const &key, ViewRefType view, beast::Journal j=beast::Journal{beast::Journal::getNullSink()})
Constructor for read-only context (read from view by keylet).
A serialized ledger entry, commonly abbreviated "SLE".
std::shared_ptr< STLedgerEntry const > const_pointer
SLE::const_pointer resolveEntry(ReadView const &view, Keylet const &key)
Resolves a keylet for a read-only entry.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
SLEBase< ApplyView > WritableSLE
LedgerEntryType
Identifiers for on-ledger objects.
@ ltANY
A special type, matching any ledger entry type.
SLEBase< ReadView > ReadOnlySLE
Generic (any-entry-type) SLE entries.
XRPL_NO_SANITIZE_ADDRESS void Throw(Args &&... args)
Bundles the mutable ledger view and the transaction being applied.
A pair of SHAMap key and LedgerEntryType.