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