xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
libxrpl
protocol
STBlob.cpp
1
#include <xrpl/protocol/STBlob.h>
2
3
#include <xrpl/basics/strHex.h>
4
#include <xrpl/beast/utility/instrumentation.h>
5
#include <xrpl/protocol/SField.h>
6
#include <xrpl/protocol/STBase.h>
7
#include <xrpl/protocol/Serializer.h>
8
9
#include <
cstddef
>
10
#include <
string
>
11
#include <
utility
>
12
13
namespace
xrpl
{
14
15
STBlob::STBlob
(
SerialIter
& st,
SField
const
& name) :
STBase
(name),
value_
(st.getVLBuffer())
16
{
17
}
18
19
STBase
*
20
STBlob::copy
(
std::size_t
n,
void
* buf)
const
21
{
22
return
emplace
(n, buf, *
this
);
23
}
24
25
STBase
*
26
STBlob::move
(
std::size_t
n,
void
* buf)
27
{
28
return
emplace
(n, buf, std::move(*
this
));
29
}
30
31
SerializedTypeID
32
STBlob::getSType
()
const
33
{
34
return
STI_VL;
35
}
36
37
std::string
38
STBlob::getText
()
const
39
{
40
return
strHex
(
value_
);
41
}
42
43
void
44
STBlob::add
(
Serializer
& s)
const
45
{
46
XRPL_ASSERT(
getFName
().isBinary(),
"xrpl::STBlob::add : field is binary"
);
47
XRPL_ASSERT(
48
(
getFName
().fieldType == STI_VL) || (
getFName
().fieldType == STI_ACCOUNT),
49
"xrpl::STBlob::add : valid field type"
);
50
s.
addVL
(
value_
.data(),
value_
.size());
51
}
52
53
bool
54
STBlob::isEquivalent
(
STBase
const
& t)
const
55
{
56
auto
const
* v =
dynamic_cast<
STBlob
const*
>
(&t);
57
return
(v !=
nullptr
) && (
value_
== v->value_);
58
}
59
60
bool
61
STBlob::isDefault
()
const
62
{
63
return
value_
.empty();
64
}
65
66
}
// namespace xrpl
std::string
xrpl::SField
Identifies fields.
Definition
SField.h:132
xrpl::STBase
A type which can be exported to a well known binary format.
Definition
STBase.h:129
xrpl::STBase::getFName
SField const & getFName() const
Definition
STBase.cpp:120
xrpl::STBase::emplace
static STBase * emplace(std::size_t n, void *buf, T &&val)
Definition
STBase.h:226
xrpl::STBase::STBase
STBase()
Definition
STBase.cpp:15
xrpl::STBlob::isEquivalent
bool isEquivalent(STBase const &t) const override
Definition
STBlob.cpp:54
xrpl::STBlob::value_
Buffer value_
Definition
STBlob.h:20
xrpl::STBlob::add
void add(Serializer &s) const override
Definition
STBlob.cpp:44
xrpl::STBlob::getSType
SerializedTypeID getSType() const override
Definition
STBlob.cpp:32
xrpl::STBlob::STBlob
STBlob()=default
xrpl::STBlob::copy
STBase * copy(std::size_t n, void *buf) const override
Definition
STBlob.cpp:20
xrpl::STBlob::move
STBase * move(std::size_t n, void *buf) override
Definition
STBlob.cpp:26
xrpl::STBlob::isDefault
bool isDefault() const override
Definition
STBlob.cpp:61
xrpl::STBlob::getText
std::string getText() const override
Definition
STBlob.cpp:38
xrpl::SerialIter
Definition
Serializer.h:478
xrpl::Serializer
Definition
Serializer.h:23
xrpl::Serializer::addVL
int addVL(Blob const &vector)
Definition
libxrpl/protocol/Serializer.cpp:180
cstddef
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition
strHex.h:13
xrpl::SerializedTypeID
SerializedTypeID
Definition
SField.h:94
std::size_t
string
utility
Generated by
1.17.0