xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
include
xrpl
protocol
STAccount.h
1
#pragma once
2
3
#include <xrpl/basics/Buffer.h>
4
#include <xrpl/basics/CountedObject.h>
5
#include <xrpl/protocol/AccountID.h>
6
#include <xrpl/protocol/SField.h>
7
#include <xrpl/protocol/STBase.h>
8
#include <xrpl/protocol/Serializer.h>
9
10
#include <
cstddef
>
11
#include <
string
>
12
13
namespace
xrpl
{
14
15
class
STAccount
final :
public
STBase
,
public
CountedObject
<STAccount>
16
{
17
private
:
18
// The original implementation of STAccount kept the value in an STBlob.
19
// But an STAccount is always 160 bits, so we can store it with less
20
// overhead in an xrpl::UInt160. However, so the serialized format of the
21
// STAccount stays unchanged, we serialize and deserialize like an STBlob.
22
AccountID
value_
;
23
bool
default_
;
24
25
public
:
26
using
value_type
=
AccountID
;
27
28
STAccount
();
29
30
STAccount
(
SField
const
& n);
31
STAccount
(
SField
const
& n,
Buffer
const
& v);
32
STAccount
(
SerialIter
& sit,
SField
const
& name);
33
STAccount
(
SField
const
& n,
AccountID
const
& v);
34
35
[[nodiscard]]
SerializedTypeID
36
getSType
()
const override
;
37
38
[[nodiscard]]
std::string
39
getText
()
const override
;
40
41
void
42
add
(
Serializer
& s)
const override
;
43
44
[[nodiscard]]
bool
45
isEquivalent
(
STBase
const
& t)
const override
;
46
47
[[nodiscard]]
bool
48
isDefault
()
const override
;
49
50
STAccount
&
51
operator=
(
AccountID
const
&
value
);
52
53
[[nodiscard]]
AccountID
const
&
54
value
() const noexcept;
55
56
void
57
setValue
(
AccountID
const& v);
58
59
private:
60
STBase
*
61
copy
(
std
::
size_t
n,
void
* buf) const override;
62
STBase
*
63
move
(
std
::
size_t
n,
void
* buf) override;
64
65
friend class
detail
::
STVar
;
66
};
67
68
inline
STAccount
&
69
STAccount
::operator=(
AccountID
const&
value
)
70
{
71
setValue
(
value
);
72
return
*
this
;
73
}
74
75
inline
AccountID
const
&
76
STAccount::value
() const noexcept
77
{
78
return
value_
;
79
}
80
81
inline
void
82
STAccount::setValue
(
AccountID
const
& v)
83
{
84
value_
= v;
85
default_
=
false
;
86
}
87
88
inline
bool
89
operator==
(
STAccount
const
& lhs,
STAccount
const
& rhs)
90
{
91
return
lhs.
value
() == rhs.
value
();
92
}
93
94
inline
auto
95
operator<
(
STAccount
const
& lhs,
STAccount
const
& rhs)
96
{
97
return
lhs.
value
() < rhs.
value
();
98
}
99
100
inline
bool
101
operator==
(
STAccount
const
& lhs,
AccountID
const
& rhs)
102
{
103
return
lhs.
value
() == rhs;
104
}
105
106
inline
auto
107
operator<
(
STAccount
const
& lhs,
AccountID
const
& rhs)
108
{
109
return
lhs.
value
() < rhs;
110
}
111
112
inline
auto
113
operator<
(
AccountID
const
& lhs,
STAccount
const
& rhs)
114
{
115
return
lhs < rhs.
value
();
116
}
117
118
}
// namespace xrpl
std::string
xrpl::Buffer
Like std::vector<char> but better.
Definition
Buffer.h:19
xrpl::CountedObject< STAccount >::CountedObject
CountedObject() noexcept
Definition
CountedObject.h:119
xrpl::SField
Identifies fields.
Definition
SField.h:132
xrpl::STAccount
Definition
STAccount.h:16
xrpl::STAccount::isDefault
bool isDefault() const override
Definition
STAccount.cpp:92
xrpl::STAccount::isEquivalent
bool isEquivalent(STBase const &t) const override
Definition
STAccount.cpp:85
xrpl::STAccount::STAccount
STAccount()
Definition
STAccount.cpp:20
xrpl::STAccount::value_type
AccountID value_type
Definition
STAccount.h:26
xrpl::STAccount::value_
AccountID value_
Definition
STAccount.h:22
xrpl::STAccount::add
void add(Serializer &s) const override
Definition
STAccount.cpp:72
xrpl::STAccount::move
STBase * move(std::size_t n, void *buf) override
Definition
STAccount.cpp:60
xrpl::STAccount::setValue
void setValue(AccountID const &v)
Definition
STAccount.h:82
xrpl::STAccount::STVar
friend class detail::STVar
Definition
STAccount.h:65
xrpl::STAccount::getSType
SerializedTypeID getSType() const override
Definition
STAccount.cpp:66
xrpl::STAccount::operator=
STAccount & operator=(AccountID const &value)
Definition
STAccount.h:69
xrpl::STAccount::default_
bool default_
Definition
STAccount.h:23
xrpl::STAccount::copy
STBase * copy(std::size_t n, void *buf) const override
Definition
STAccount.cpp:54
xrpl::STAccount::getText
std::string getText() const override
Definition
STAccount.cpp:98
xrpl::STAccount::value
AccountID const & value() const noexcept
Definition
STAccount.h:76
xrpl::STBase::STBase
STBase()
Definition
STBase.cpp:15
xrpl::STBase::operator==
bool operator==(STBase const &t) const
Definition
STBase.cpp:36
xrpl::SerialIter
Definition
Serializer.h:478
xrpl::Serializer
Definition
Serializer.h:23
cstddef
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::SerializedTypeID
SerializedTypeID
Definition
SField.h:94
xrpl::AccountID
BaseUInt< 160, detail::AccountIDTag > AccountID
A 160-bit unsigned that uniquely identifies an account.
Definition
AccountID.h:34
string
Generated by
1.17.0