xrpld
Loading...
Searching...
No Matches
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
13namespace xrpl {
14
15class STCurrency final : public STBase
16{
17private:
19
20public:
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
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
57private:
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
70currencyFromJson(SField const& name, json::Value const& v);
71
72inline Currency const&
74{
75 return currency_;
76}
77
78inline Currency const&
79STCurrency::value() const noexcept
80{
81 return currency_;
82}
83
84inline void
89
90inline bool
91operator==(STCurrency const& lhs, STCurrency const& rhs)
92{
93 return lhs.currency() == rhs.currency();
94}
95
96inline bool
97operator<(STCurrency const& lhs, STCurrency const& rhs)
98{
99 return lhs.currency() < rhs.currency();
100}
101
102inline bool
103operator==(STCurrency const& lhs, Currency const& rhs)
104{
105 return lhs.currency() == rhs;
106}
107
108inline bool
109operator<(STCurrency const& lhs, Currency const& rhs)
110{
111 return lhs.currency() < rhs;
112}
113
114} // namespace xrpl
Identifies fields.
Definition SField.h:132
bool operator==(STBase const &t) const
Definition STBase.cpp:36
std::string getText() const override
void setCurrency(Currency const &currency)
Definition STCurrency.h:85
bool isEquivalent(STBase const &t) const override
friend class detail::STVar
Definition STCurrency.h:66
Currency const & currency() const
Definition STCurrency.h:73
STBase * copy(std::size_t n, void *buf) const override
Currency const & value() const noexcept
Definition STCurrency.h:79
bool isDefault() const override
Currency value_type
Definition STCurrency.h:21
STBase * move(std::size_t n, void *buf) override
SerializedTypeID getSType() const override
Currency currency_
Definition STCurrency.h:18
STCurrency()=default
void add(Serializer &s) const override
static std::unique_ptr< STCurrency > construct(SerialIter &, SField const &name)
json::Value getJson(JsonOptions) const override
JSON (JavaScript Object Notation).
Definition json_errors.h:5
STL namespace.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition Slice.h:212
STCurrency currencyFromJson(SField const &name, json::Value const &v)
BaseUInt< 160, detail::CurrencyTag > Currency
Currency is a hash representing a specific currency.
Definition UintTypes.h:42
SerializedTypeID
Definition SField.h:94
Note, should be treated as flags that can be | and &.
Definition STBase.h:22