xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
protocol
STCurrency.h
1
#pragma once
2
3
#include <xrpl/json/json_value.h>
4
#include <xrpl/protocol/SField.h>
5
#include <xrpl/protocol/STBase.h>
6
#include <xrpl/protocol/Serializer.h>
7
#include <xrpl/protocol/UintTypes.h>
8
9
#include <
cstddef
>
10
#include <
memory
>
11
#include <
string
>
12
13
namespace
xrpl
{
14
15
class
STCurrency
final :
public
STBase
16
{
17
private
:
18
Currency
currency_
;
19
20
public
:
21
using
value_type
=
Currency
;
22
23
STCurrency
() =
default
;
24
25
explicit
STCurrency
(
SerialIter
& sit,
SField
const
& name);
26
27
explicit
STCurrency
(
SField
const
& name,
Currency
const
&
currency
);
28
29
explicit
STCurrency
(
SField
const
& name);
30
31
[[nodiscard]]
Currency
const
&
32
currency
()
const
;
33
34
[[nodiscard]]
Currency
const
&
35
value
() const noexcept;
36
37
void
38
setCurrency
(
Currency
const&
currency
);
39
40
[[nodiscard]]
SerializedTypeID
41
getSType
() const override;
42
43
[[nodiscard]]
std
::
string
44
getText
() const override;
45
46
[[nodiscard]]
json
::Value
getJson
(
JsonOptions
) const override;
47
48
void
49
add
(
Serializer
& s) const override;
50
51
[[nodiscard]]
bool
52
isEquivalent
(
STBase
const& t) const override;
53
54
[[nodiscard]]
bool
55
isDefault
() const override;
56
57
private:
58
static
std
::unique_ptr<
STCurrency
>
59
construct
(
SerialIter
&,
SField
const& name);
60
61
STBase
*
62
copy
(
std
::
size_t
n,
void
* buf) const override;
63
STBase
*
64
move
(
std
::
size_t
n,
void
* buf) override;
65
66
friend class
detail
::
STVar
;
67
};
68
69
STCurrency
70
currencyFromJson
(
SField
const& name,
json
::Value const& v);
71
72
inline
Currency
const&
73
STCurrency
::
currency
()
const
74
{
75
return
currency_
;
76
}
77
78
inline
Currency
const
&
79
STCurrency::value
() const noexcept
80
{
81
return
currency_
;
82
}
83
84
inline
void
85
STCurrency::setCurrency
(
Currency
const
&
currency
)
86
{
87
currency_
=
currency
;
88
}
89
90
inline
bool
91
operator==
(
STCurrency
const
& lhs,
STCurrency
const
& rhs)
92
{
93
return
lhs.
currency
() == rhs.
currency
();
94
}
95
96
inline
bool
97
operator<
(
STCurrency
const
& lhs,
STCurrency
const
& rhs)
98
{
99
return
lhs.
currency
() < rhs.
currency
();
100
}
101
102
inline
bool
103
operator==
(
STCurrency
const
& lhs,
Currency
const
& rhs)
104
{
105
return
lhs.
currency
() == rhs;
106
}
107
108
inline
bool
109
operator<
(
STCurrency
const
& lhs,
Currency
const
& rhs)
110
{
111
return
lhs.
currency
() < rhs;
112
}
113
114
}
// namespace xrpl
xrpl::SField
Identifies fields.
Definition
SField.h:132
xrpl::STBase::STBase
STBase()
Definition
STBase.cpp:15
xrpl::STBase::operator==
bool operator==(STBase const &t) const
Definition
STBase.cpp:36
xrpl::STCurrency
Definition
STCurrency.h:16
xrpl::STCurrency::getText
std::string getText() const override
Definition
STCurrency.cpp:39
xrpl::STCurrency::setCurrency
void setCurrency(Currency const ¤cy)
Definition
STCurrency.h:85
xrpl::STCurrency::isEquivalent
bool isEquivalent(STBase const &t) const override
Definition
STCurrency.cpp:57
xrpl::STCurrency::STVar
friend class detail::STVar
Definition
STCurrency.h:66
xrpl::STCurrency::currency
Currency const & currency() const
Definition
STCurrency.h:73
xrpl::STCurrency::copy
STBase * copy(std::size_t n, void *buf) const override
Definition
STCurrency.cpp:76
xrpl::STCurrency::value
Currency const & value() const noexcept
Definition
STCurrency.h:79
xrpl::STCurrency::isDefault
bool isDefault() const override
Definition
STCurrency.cpp:64
xrpl::STCurrency::value_type
Currency value_type
Definition
STCurrency.h:21
xrpl::STCurrency::move
STBase * move(std::size_t n, void *buf) override
Definition
STCurrency.cpp:82
xrpl::STCurrency::getSType
SerializedTypeID getSType() const override
Definition
STCurrency.cpp:33
xrpl::STCurrency::currency_
Currency currency_
Definition
STCurrency.h:18
xrpl::STCurrency::STCurrency
STCurrency()=default
xrpl::STCurrency::add
void add(Serializer &s) const override
Definition
STCurrency.cpp:51
xrpl::STCurrency::construct
static std::unique_ptr< STCurrency > construct(SerialIter &, SField const &name)
Definition
STCurrency.cpp:70
xrpl::STCurrency::getJson
json::Value getJson(JsonOptions) const override
Definition
STCurrency.cpp:45
xrpl::SerialIter
Definition
Serializer.h:478
xrpl::Serializer
Definition
Serializer.h:23
cstddef
memory
json
JSON (JavaScript Object Notation).
Definition
json_errors.h:5
std
STL namespace.
xrpl::detail
Definition
base_uint.h:37
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::operator<
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition
Slice.h:212
xrpl::currencyFromJson
STCurrency currencyFromJson(SField const &name, json::Value const &v)
Definition
STCurrency.cpp:88
xrpl::Currency
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition
UintTypes.h:42
xrpl::SerializedTypeID
SerializedTypeID
Definition
SField.h:94
string
xrpl::JsonOptions
Note, should be treated as flags that can be | and &.
Definition
STBase.h:22
Generated by
1.17.0