xrpld
Loading...
Searching...
No Matches
xrpl::STPathSet Class Referencefinal

#include <STPathSet.h>

Inheritance diagram for xrpl::STPathSet:
Collaboration diagram for xrpl::STPathSet:

Classes

struct  DeduplicationTag

Public Member Functions

 STPathSet ()=default
 STPathSet (DeduplicationTag)
 Deduplication tagged constructor.
 STPathSet (SField const &n)
 STPathSet (SerialIter &sit, SField const &name)
 STPathSet (STPathSet const &other)
 STPathSet (STPathSet &&)=default
STPathSet & operator= (STPathSet const &other)
STPathSet & operator= (STPathSet &&)=default
 ~STPathSet () override=default
void add (Serializer &s) const override
json::Value getJson (JsonOptions) const override
SerializedTypeID getSType () const override
bool assembleAdd (STPath const &base, STPathElement const &tail)
 assembleAdd adds a path to the set by combining a base path and a tail element.
bool isEquivalent (STBase const &t) const override
bool isDefault () const override
std::vector< STPath >::const_reference operator[] (std::vector< STPath >::size_type n) const
std::vector< STPath >::const_iterator begin () const
std::vector< STPath >::const_iterator end () const
std::vector< STPath >::size_type size () const
bool empty () const
bool pushBack (STPath const &e)
 pushBack adds a path to the set.
template<typename... Args>
bool emplaceBack (Args &&... args)
 emplaceBack adds a path to the set.
bool operator== (STBase const &t) const
template<class D>
D & downcast ()
template<class D>
D const & downcast () const
template<class D>
D const & downcast () const
virtual std::string getFullText () const
virtual std::string getText () const
void setFName (SField const &n)
 A STBase is a field.
SField const & getFName () const
void addFieldID (Serializer &s) const

Public Attributes

friend Object

Static Protected Member Functions

template<class T>
static STBase * emplace (std::size_t n, void *buf, T &&val)

Private Member Functions

STBase * copy (std::size_t n, void *buf) const override
STBase * move (std::size_t n, void *buf) override
template<typename Append>
bool appendUnique (Append &&append)
 Append a path via append, then register it in the deduplication index.

Static Private Member Functions

static auto & getCounter () noexcept

Private Attributes

std::vector< STPath > value_
std::unique_ptr< HardenedHashSet< STPath > > seen_
 Deduplication index over value_, for pathfinding.
SField const * fName_

Friends

class detail::STVar

Detailed Description

Definition at line 199 of file STPathSet.h.

Constructor & Destructor Documentation

◆ STPathSet() [1/6]

xrpl::STPathSet::STPathSet ( )
default

◆ STPathSet() [2/6]

xrpl::STPathSet::STPathSet ( DeduplicationTag )
explicit

Deduplication tagged constructor.

Use when you want to ensure that the STPathSet does not contain duplicate paths.

Definition at line 77 of file STPathSet.cpp.

◆ STPathSet() [3/6]

xrpl::STPathSet::STPathSet ( SField const & n)

Definition at line 600 of file STPathSet.h.

◆ STPathSet() [4/6]

xrpl::STPathSet::STPathSet ( SerialIter & sit,
SField const & name )

Definition at line 107 of file STPathSet.cpp.

◆ STPathSet() [5/6]

xrpl::STPathSet::STPathSet ( STPathSet const & other)

Definition at line 81 of file STPathSet.cpp.

◆ STPathSet() [6/6]

xrpl::STPathSet::STPathSet ( STPathSet && )
default

◆ ~STPathSet()

xrpl::STPathSet::~STPathSet ( )
overridedefault

Member Function Documentation

◆ operator=() [1/2]

STPathSet & xrpl::STPathSet::operator= ( STPathSet const & other)

Definition at line 92 of file STPathSet.cpp.

◆ operator=() [2/2]

STPathSet & xrpl::STPathSet::operator= ( STPathSet && )
default

◆ add()

void xrpl::STPathSet::add ( Serializer & s) const
overridevirtual

Reimplemented from xrpl::STBase.

Definition at line 262 of file STPathSet.cpp.

◆ getJson()

json::Value xrpl::STPathSet::getJson ( JsonOptions options) const
nodiscardoverridevirtual

Reimplemented from xrpl::STBase.

Definition at line 246 of file STPathSet.cpp.

◆ getSType()

SerializedTypeID xrpl::STPathSet::getSType ( ) const
nodiscardoverridevirtual

Reimplemented from xrpl::STBase.

Definition at line 256 of file STPathSet.cpp.

◆ assembleAdd()

bool xrpl::STPathSet::assembleAdd ( STPath const & base,
STPathElement const & tail )

assembleAdd adds a path to the set by combining a base path and a tail element.

Parameters
baseThe base path.
tailThe tail element.
Returns
true if the path was added, false if it was a duplicate and not added.
Remarks
Requires the STPathSet to be constructed with the DeduplicationTag. The return value indicates whether the combined path was inserted (true) or rejected as a duplicate (false). It is fine for callers to ignore the return value.

Definition at line 181 of file STPathSet.cpp.

◆ isEquivalent()

bool xrpl::STPathSet::isEquivalent ( STBase const & t) const
nodiscardoverridevirtual

Reimplemented from xrpl::STBase.

Definition at line 190 of file STPathSet.cpp.

◆ isDefault()

bool xrpl::STPathSet::isDefault ( ) const
nodiscardoverridevirtual

Reimplemented from xrpl::STBase.

Definition at line 197 of file STPathSet.cpp.

◆ operator[]()

std::vector< STPath >::const_reference xrpl::STPathSet::operator[] ( std::vector< STPath >::size_type n) const

Definition at line 606 of file STPathSet.h.

◆ begin()

std::vector< STPath >::const_iterator xrpl::STPathSet::begin ( ) const
nodiscard

Definition at line 612 of file STPathSet.h.

◆ end()

std::vector< STPath >::const_iterator xrpl::STPathSet::end ( ) const
nodiscard

Definition at line 618 of file STPathSet.h.

◆ size()

std::vector< STPath >::size_type xrpl::STPathSet::size ( ) const
nodiscard

Definition at line 624 of file STPathSet.h.

◆ empty()

bool xrpl::STPathSet::empty ( ) const
nodiscard

Definition at line 630 of file STPathSet.h.

◆ pushBack()

bool xrpl::STPathSet::pushBack ( STPath const & e)

pushBack adds a path to the set.

Parameters
eThe path to add.
Returns
true if the path was added, false if it was a duplicate and not added.
Remarks
If the STPathSet was constructed with the DeduplicationTag, then this method will check for duplicates and only add the path if it is not already present in the set. If the STPathSet was constructed without the DeduplicationTag, then this method will always add the path to the set, regardless of duplicates. It is fine for callers to ignore the return value.

Definition at line 669 of file STPathSet.h.

◆ emplaceBack()

template<typename... Args>
bool xrpl::STPathSet::emplaceBack ( Args &&... args)

emplaceBack adds a path to the set.

Parameters
argsThe arguments to construct the path with.
Returns
true if the path was added, false if it was a duplicate and not added.
Remarks
If the STPathSet was constructed with the DeduplicationTag, then this method will check for duplicates and only add the path if it is not already present in the set. If the STPathSet was constructed without the DeduplicationTag, then this method will always add the path to the set, regardless of duplicates. It is fine for callers to ignore the return value.
Note
The path is constructed before the duplicate check, so on a false return the constructed path is discarded and any argument forwarded as an rvalue is left in a moved-from state. Use pushBack when the caller needs to keep its path on rejection.

Definition at line 676 of file STPathSet.h.

◆ copy()

STBase * xrpl::STPathSet::copy ( std::size_t n,
void * buf ) const
overrideprivatevirtual

Reimplemented from xrpl::STBase.

Definition at line 169 of file STPathSet.cpp.

◆ move()

STBase * xrpl::STPathSet::move ( std::size_t n,
void * buf )
overrideprivatevirtual

Reimplemented from xrpl::STBase.

Definition at line 175 of file STPathSet.cpp.

◆ appendUnique()

template<typename Append>
bool xrpl::STPathSet::appendUnique ( Append && append)
private

Append a path via append, then register it in the deduplication index.

Parameters
appendInvoked with value_; must append exactly one path to it.
Returns
true if the path was kept, false if it was a duplicate and was rolled back.
Remarks
Appends to the vector before touching the index, so that a failed allocation there leaves both containers untouched rather than leaving the index holding a path the vector does not. If the index insert reports a duplicate, or throws, the append is rolled back so the two containers stay consistent; in the throwing case the exception propagates. With no index (constructed without the DeduplicationTag) the append is unconditional.

Definition at line 637 of file STPathSet.h.

◆ operator==()

bool xrpl::STBase::operator== ( STBase const & t) const
inherited

Definition at line 36 of file STBase.cpp.

◆ downcast() [1/3]

template<class D>
D & xrpl::STBase::downcast ( )
inherited

Definition at line 206 of file STBase.h.

◆ downcast() [2/3]

template<class D>
D const & xrpl::STBase::downcast ( ) const
inherited

◆ downcast() [3/3]

template<class D>
D const & xrpl::STBase::downcast ( ) const
nodiscardinherited

Definition at line 216 of file STBase.h.

◆ getFullText()

std::string xrpl::STBase::getFullText ( ) const
nodiscardvirtualinherited

Reimplemented in xrpl::STAmount, xrpl::STArray, xrpl::STLedgerEntry, xrpl::STObject, and xrpl::STTx.

Definition at line 60 of file STBase.cpp.

◆ getText()

◆ setFName()

void xrpl::STBase::setFName ( SField const & n)
inherited

A STBase is a field.

This sets the name.

Definition at line 113 of file STBase.cpp.

◆ getFName()

SField const & xrpl::STBase::getFName ( ) const
nodiscardinherited

Definition at line 120 of file STBase.cpp.

◆ addFieldID()

void xrpl::STBase::addFieldID ( Serializer & s) const
inherited

Definition at line 126 of file STBase.cpp.

◆ emplace()

template<class T>
STBase * xrpl::STBase::emplace ( std::size_t n,
void * buf,
T && val )
staticprotectedinherited

Definition at line 226 of file STBase.h.

◆ getCounter()

auto & xrpl::CountedObject< STPathSet >::getCounter ( )
staticprivatenoexceptinherited

Definition at line 113 of file CountedObject.h.

◆ detail::STVar

friend class detail::STVar
friend

Definition at line 335 of file STPathSet.h.

Member Data Documentation

◆ value_

std::vector<STPath> xrpl::STPathSet::value_
private

Definition at line 201 of file STPathSet.h.

◆ seen_

std::unique_ptr<HardenedHashSet<STPath> > xrpl::STPathSet::seen_
private

Deduplication index over value_, for pathfinding.

The use of a std::unique_ptr is intentional as it only requires 8 additional bytes of storage for the pointer as opposed to 64 bytes with an optional. This keeps the size of the STPathSet to within the STVar::kMaxSize limit of 72 bytes.

Definition at line 210 of file STPathSet.h.

◆ fName_

SField const* xrpl::STBase::fName_
privateinherited

Definition at line 130 of file STBase.h.

◆ Object

Definition at line 138 of file CountedObject.h.