xrpld
Loading...
Searching...
No Matches
xrpl::KnownFormats< KeyType, Derived > Class Template Reference

Manages a list of known formats. More...

#include <KnownFormats.h>

Collaboration diagram for xrpl::KnownFormats< KeyType, Derived >:

Classes

class  Item
 A known format. More...

Public Member Functions

virtual ~KnownFormats ()=default
 Destroy the known formats object.
 KnownFormats (KnownFormats const &)=delete
KnownFormatsoperator= (KnownFormats const &)=delete
KeyType findTypeByName (std::string const &name) const
 Retrieve the type for a format specified by name.
Item const * findByType (KeyType type) const
 Retrieve a format based on its type.
std::forward_list< Item >::const_iterator begin () const
std::forward_list< Item >::const_iterator end () const

Protected Member Functions

Item const * findByName (std::string const &name) const
 Retrieve a format based on its name.
Item const & add (char const *name, KeyType type, std::vector< SOElement > uniqueFields, std::vector< SOElement > commonFields={})
 Add a new format.

Private Member Functions

 KnownFormats ()
 Create the known formats object.

Private Attributes

std::string name_
std::forward_list< Itemformats_ {}
boost::container::flat_map< std::string, Item const * > names_ {}
boost::container::flat_map< KeyType, Item const * > types_ {}
friend Derived

Detailed Description

template<class KeyType, class Derived>
class xrpl::KnownFormats< KeyType, Derived >

Manages a list of known formats.

Each format has a name, an associated KeyType (typically an enumeration), and a predefined SOElement.

Template Parameters
KeyTypeThe type of key identifying the format.

Definition at line 22 of file KnownFormats.h.

Constructor & Destructor Documentation

◆ KnownFormats() [1/2]

template<class KeyType, class Derived>
xrpl::KnownFormats< KeyType, Derived >::KnownFormats ( )
private

Create the known formats object.

Derived classes will load the object with all the known formats.

Definition at line 78 of file KnownFormats.h.

◆ ~KnownFormats()

template<class KeyType, class Derived>
virtual xrpl::KnownFormats< KeyType, Derived >::~KnownFormats ( )
virtualdefault

Destroy the known formats object.

The defined formats are deleted.

◆ KnownFormats() [2/2]

template<class KeyType, class Derived>
xrpl::KnownFormats< KeyType, Derived >::KnownFormats ( KnownFormats< KeyType, Derived > const & )
delete

Member Function Documentation

◆ operator=()

template<class KeyType, class Derived>
KnownFormats & xrpl::KnownFormats< KeyType, Derived >::operator= ( KnownFormats< KeyType, Derived > const & )
delete

◆ findTypeByName()

template<class KeyType, class Derived>
KeyType xrpl::KnownFormats< KeyType, Derived >::findTypeByName ( std::string const & name) const
nodiscard

Retrieve the type for a format specified by name.

If the format name is unknown, an exception is thrown.

Parameters
nameThe name of the type.
Returns
The type.

Definition at line 100 of file KnownFormats.h.

◆ findByType()

template<class KeyType, class Derived>
Item const * xrpl::KnownFormats< KeyType, Derived >::findByType ( KeyType type) const
nodiscard

Retrieve a format based on its type.

Definition at line 112 of file KnownFormats.h.

◆ begin()

template<class KeyType, class Derived>
std::forward_list< Item >::const_iterator xrpl::KnownFormats< KeyType, Derived >::begin ( ) const
nodiscard

Definition at line 122 of file KnownFormats.h.

◆ end()

template<class KeyType, class Derived>
std::forward_list< Item >::const_iterator xrpl::KnownFormats< KeyType, Derived >::end ( ) const
nodiscard

Definition at line 128 of file KnownFormats.h.

◆ findByName()

template<class KeyType, class Derived>
Item const * xrpl::KnownFormats< KeyType, Derived >::findByName ( std::string const & name) const
nodiscardprotected

Retrieve a format based on its name.

Definition at line 137 of file KnownFormats.h.

◆ add()

template<class KeyType, class Derived>
Item const & xrpl::KnownFormats< KeyType, Derived >::add ( char const * name,
KeyType type,
std::vector< SOElement > uniqueFields,
std::vector< SOElement > commonFields = {} )
protected

Add a new format.

Parameters
nameThe name of this format.
typeThe type of this format.
uniqueFieldsA std::vector of unique fields
commonFieldsA std::vector of common fields
Returns
The created format.

Definition at line 155 of file KnownFormats.h.

Member Data Documentation

◆ name_

template<class KeyType, class Derived>
std::string xrpl::KnownFormats< KeyType, Derived >::name_
private

Definition at line 177 of file KnownFormats.h.

◆ formats_

template<class KeyType, class Derived>
std::forward_list<Item> xrpl::KnownFormats< KeyType, Derived >::formats_ {}
private

Definition at line 182 of file KnownFormats.h.

◆ names_

template<class KeyType, class Derived>
boost::container::flat_map<std::string, Item const*> xrpl::KnownFormats< KeyType, Derived >::names_ {}
private

Definition at line 184 of file KnownFormats.h.

◆ types_

template<class KeyType, class Derived>
boost::container::flat_map<KeyType, Item const*> xrpl::KnownFormats< KeyType, Derived >::types_ {}
private

Definition at line 185 of file KnownFormats.h.

◆ Derived

template<class KeyType, class Derived>
friend xrpl::KnownFormats< KeyType, Derived >::Derived
private

Definition at line 186 of file KnownFormats.h.