20#ifndef RIPPLE_PROTOCOL_SFIELD_H_INCLUDED
21#define RIPPLE_PROTOCOL_SFIELD_H_INCLUDED
23#include <xrpl/basics/safe_cast.h>
24#include <xrpl/json/json_value.h>
25#include <xrpl/protocol/Units.h>
57#pragma push_macro("XMACRO")
60#define XMACRO(STYPE) \
62 STYPE(STI_UNKNOWN, -2) \
63 STYPE(STI_NOTPRESENT, 0) \
64 STYPE(STI_UINT16, 1) \
67 STYPE(STI_UINT32, 2) \
68 STYPE(STI_UINT64, 3) \
69 STYPE(STI_UINT128, 4) \
70 STYPE(STI_UINT256, 5) \
71 STYPE(STI_AMOUNT, 6) \
73 STYPE(STI_ACCOUNT, 8) \
74 STYPE(STI_NUMBER, 9) \
75 STYPE(STI_INT32, 10) \
76 STYPE(STI_INT64, 11) \
79 STYPE(STI_OBJECT, 14) \
80 STYPE(STI_ARRAY, 15) \
83 STYPE(STI_UINT8, 16) \
84 STYPE(STI_UINT160, 17) \
85 STYPE(STI_PATHSET, 18) \
86 STYPE(STI_VECTOR256, 19) \
87 STYPE(STI_UINT96, 20) \
88 STYPE(STI_UINT192, 21) \
89 STYPE(STI_UINT384, 22) \
90 STYPE(STI_UINT512, 23) \
91 STYPE(STI_ISSUE, 24) \
92 STYPE(STI_XCHAIN_BRIDGE, 25) \
93 STYPE(STI_CURRENCY, 26) \
97 STYPE(STI_TRANSACTION, 10001) \
98 STYPE(STI_LEDGERENTRY, 10002) \
99 STYPE(STI_VALIDATION, 10003) \
100 STYPE(STI_METADATA, 10004)
102#pragma push_macro("TO_ENUM")
104#pragma push_macro("TO_MAP")
107#define TO_ENUM(name, value) name = value,
108#define TO_MAP(name, value) {#name, value},
117#pragma pop_macro("XMACRO")
118#pragma pop_macro("TO_ENUM")
119#pragma pop_macro("TO_MAP")
125 return (safe_cast<int>(
id) << 16) | index;
132 return (
id << 16) | index;
323 template <
class... Args>
339inline OptionaledField<T>
376#pragma push_macro("UNTYPED_SFIELD")
378#pragma push_macro("TYPED_SFIELD")
381#define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \
382 extern SField const sfName;
383#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \
384 extern SF_##stiSuffix const sfName;
389#include <xrpl/protocol/detail/sfields.macro>
392#pragma pop_macro("TYPED_SFIELD")
394#pragma pop_macro("UNTYPED_SFIELD")
Lightweight wrapper to tag static string.
Json::StaticString const & getJsonName() const
SField(SField const &)=delete
std::string const fieldName
static std::unordered_map< int, SField const * > knownCodeToField
bool operator==(SField const &f) const
static int getNumFields()
bool isDiscardable() const
std::string const & getName() const
SField & operator=(SField const &)=delete
bool shouldInclude(bool withSigningField) const
SField & operator=(SField &&)=delete
static IsSigning const notSigning
static SField const & getField(int type, int value)
static SField const & getField(SerializedTypeID type, int value)
Json::StaticString const jsonName
bool shouldMeta(int c) const
IsSigning const signingField
static SField const & getField(int fieldCode)
static std::unordered_map< int, SField const * > const & getKnownCodeToField()
SerializedTypeID const fieldType
static std::unordered_map< std::string, SField const * > knownNameToField
bool operator!=(SField const &f) const
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static std::map< std::string, int > const sTypeMap
constexpr ApplyFlags operator~(ApplyFlags const &flags)
int field_code(SerializedTypeID id, int index)
Indicate std::optional field semantics.
OptionaledField(TypedField< T > const &f_)
TypedField< T > const * f
A field with a type known at compile time.