rippled
Loading...
Searching...
No Matches
STAccount.h
1#ifndef XRPL_PROTOCOL_STACCOUNT_H_INCLUDED
2#define XRPL_PROTOCOL_STACCOUNT_H_INCLUDED
3
4#include <xrpl/basics/CountedObject.h>
5#include <xrpl/protocol/AccountID.h>
6#include <xrpl/protocol/STBase.h>
7
8#include <string>
9
10namespace ripple {
11
12class STAccount final : public STBase, public CountedObject<STAccount>
13{
14private:
15 // The original implementation of STAccount kept the value in an STBlob.
16 // But an STAccount is always 160 bits, so we can store it with less
17 // overhead in a ripple::uint160. However, so the serialized format of the
18 // STAccount stays unchanged, we serialize and deserialize like an STBlob.
21
22public:
24
25 STAccount();
26
27 STAccount(SField const& n);
28 STAccount(SField const& n, Buffer&& v);
29 STAccount(SerialIter& sit, SField const& name);
30 STAccount(SField const& n, AccountID const& v);
31
33 getSType() const override;
34
36 getText() const override;
37
38 void
39 add(Serializer& s) const override;
40
41 bool
42 isEquivalent(STBase const& t) const override;
43
44 bool
45 isDefault() const override;
46
49
50 AccountID const&
51 value() const noexcept;
52
53 void
54 setValue(AccountID const& v);
55
56private:
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
65inline STAccount&
66STAccount::operator=(AccountID const& value)
67{
69 return *this;
70}
71
72inline AccountID const&
73STAccount::value() const noexcept
74{
75 return value_;
76}
77
78inline void
80{
81 value_ = v;
82 default_ = false;
83}
84
85inline bool
86operator==(STAccount const& lhs, STAccount const& rhs)
87{
88 return lhs.value() == rhs.value();
89}
90
91inline auto
92operator<(STAccount const& lhs, STAccount const& rhs)
93{
94 return lhs.value() < rhs.value();
95}
96
97inline bool
98operator==(STAccount const& lhs, AccountID const& rhs)
99{
100 return lhs.value() == rhs;
101}
102
103inline auto
104operator<(STAccount const& lhs, AccountID const& rhs)
105{
106 return lhs.value() < rhs;
107}
108
109inline auto
110operator<(AccountID const& lhs, STAccount const& rhs)
111{
112 return lhs < rhs.value();
113}
114
115} // namespace ripple
116
117#endif
Like std::vector<char> but better.
Definition Buffer.h:17
Tracks the number of instances of an object.
Identifies fields.
Definition SField.h:127
void add(Serializer &s) const override
Definition STAccount.cpp:74
AccountID const & value() const noexcept
Definition STAccount.h:73
void setValue(AccountID const &v)
Definition STAccount.h:79
STAccount & operator=(AccountID const &value)
Definition STAccount.h:66
friend class detail::STVar
Definition STAccount.h:62
STBase * copy(std::size_t n, void *buf) const override
Definition STAccount.cpp:56
SerializedTypeID getSType() const override
Definition STAccount.cpp:68
STBase * move(std::size_t n, void *buf) override
Definition STAccount.cpp:62
bool isDefault() const override
Definition STAccount.cpp:97
std::string getText() const override
AccountID value_
Definition STAccount.h:19
bool isEquivalent(STBase const &t) const override
Definition STAccount.cpp:90
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
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:6
base_uint< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition AccountID.h:29
SerializedTypeID
Definition SField.h:91
bool operator<(Slice const &lhs, Slice const &rhs) noexcept
Definition Slice.h:204
STL namespace.