xrpld
Loading...
Searching...
No Matches
DecodedBlob.cpp
1#include <xrpl/nodestore/detail/DecodedBlob.h>
2
3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/safe_cast.h>
6#include <xrpl/beast/utility/instrumentation.h>
7#include <xrpl/nodestore/NodeObject.h>
8
9#include <algorithm>
10#include <memory>
11#include <utility>
12
13namespace xrpl::NodeStore {
14
15DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes)
16{
17 /* Data format:
18
19 Bytes
20
21 0...7 Unused
22 8 char One of NodeObjectType
23 9...end The body of the object data
24 */
25
26 success_ = false;
27 key_ = key;
29 objectData_ = nullptr;
30 dataBytes_ = std::max(0, valueBytes - 9);
31
32 // VFALCO NOTE What about bytes 4 through 7 inclusive?
33
34 if (valueBytes > 8)
35 {
36 unsigned char const* byte = static_cast<unsigned char const*>(value);
38 }
39
40 if (valueBytes > 9)
41 {
42 objectData_ = static_cast<unsigned char const*>(value) + 9;
43
44 switch (objectType_)
45 {
46 default:
47 break;
48
53 success_ = true;
54 break;
55 }
56 }
57}
58
61{
62 XRPL_ASSERT(success_, "xrpl::NodeStore::DecodedBlob::createObject : valid object type");
63
65
66 if (success_)
67 {
69
71 }
72
73 return object;
74}
75
76} // namespace xrpl::NodeStore
static BaseUInt fromVoid(void const *data)
Definition base_uint.h:322
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
std::shared_ptr< NodeObject > createObject()
Create a NodeObject from this data.
DecodedBlob(void const *key, void const *value, int valueBytes)
Construct the decoded blob from raw data.
unsigned char const * objectData_
Definition DecodedBlob.h:39
T max(T... args)
constexpr std::enable_if_t< std::is_integral_v< Dest > &&std::is_integral_v< Src >, Dest > safeCast(Src s) noexcept
Definition safe_cast.h:21
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:10