1#ifndef XRPL_PROTOCOL_SFIELD_H_INCLUDED
2#define XRPL_PROTOCOL_SFIELD_H_INCLUDED
4#include <xrpl/basics/safe_cast.h>
5#include <xrpl/json/json_value.h>
6#include <xrpl/protocol/Units.h>
38#pragma push_macro("XMACRO")
41#define XMACRO(STYPE) \
43 STYPE(STI_UNKNOWN, -2) \
44 STYPE(STI_NOTPRESENT, 0) \
45 STYPE(STI_UINT16, 1) \
48 STYPE(STI_UINT32, 2) \
49 STYPE(STI_UINT64, 3) \
50 STYPE(STI_UINT128, 4) \
51 STYPE(STI_UINT256, 5) \
52 STYPE(STI_AMOUNT, 6) \
54 STYPE(STI_ACCOUNT, 8) \
55 STYPE(STI_NUMBER, 9) \
56 STYPE(STI_INT32, 10) \
57 STYPE(STI_INT64, 11) \
60 STYPE(STI_OBJECT, 14) \
61 STYPE(STI_ARRAY, 15) \
64 STYPE(STI_UINT8, 16) \
65 STYPE(STI_UINT160, 17) \
66 STYPE(STI_PATHSET, 18) \
67 STYPE(STI_VECTOR256, 19) \
68 STYPE(STI_UINT96, 20) \
69 STYPE(STI_UINT192, 21) \
70 STYPE(STI_UINT384, 22) \
71 STYPE(STI_UINT512, 23) \
72 STYPE(STI_ISSUE, 24) \
73 STYPE(STI_XCHAIN_BRIDGE, 25) \
74 STYPE(STI_CURRENCY, 26) \
78 STYPE(STI_TRANSACTION, 10001) \
79 STYPE(STI_LEDGERENTRY, 10002) \
80 STYPE(STI_VALIDATION, 10003) \
81 STYPE(STI_METADATA, 10004)
83#pragma push_macro("TO_ENUM")
85#pragma push_macro("TO_MAP")
88#define TO_ENUM(name, value) name = value,
89#define TO_MAP(name, value) {#name, value},
98#pragma pop_macro("XMACRO")
99#pragma pop_macro("TO_ENUM")
100#pragma pop_macro("TO_MAP")
106 return (safe_cast<int>(
id) << 16) | index;
113 return (
id << 16) | index;
304 template <
class... Args>
320inline OptionaledField<T>
357#pragma push_macro("UNTYPED_SFIELD")
359#pragma push_macro("TYPED_SFIELD")
362#define UNTYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \
363 extern SField const sfName;
364#define TYPED_SFIELD(sfName, stiSuffix, fieldValue, ...) \
365 extern SF_##stiSuffix const sfName;
370#include <xrpl/protocol/detail/sfields.macro>
373#pragma pop_macro("TYPED_SFIELD")
375#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.