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