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