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::node_store {
14
15DecodedBlob::DecodedBlob(void const* key, void const* value, int valueBytes) : key_(key)
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 dataBytes_ = std::max(0, valueBytes - 9);
27
28 // VFALCO NOTE What about bytes 4 through 7 inclusive?
29
30 if (valueBytes > 8)
31 {
32 auto const* byte = static_cast<unsigned char const*>(value);
34 }
35
36 if (valueBytes > 9)
37 {
38 objectData_ = static_cast<unsigned char const*>(value) + 9;
39
40 switch (objectType_)
41 {
42 default:
43 break;
44
49 success_ = true;
50 break;
51 }
52 }
53}
54
57{
58 XRPL_ASSERT(success_, "xrpl::node_store::DecodedBlob::createObject : valid object type");
59
61
62 if (success_)
63 {
65
67 }
68
69 return object;
70}
71
72} // namespace xrpl::node_store
static BaseUInt fromVoid(void const *data)
Definition base_uint.h:339
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
DecodedBlob(void const *key, void const *value, int valueBytes)
Construct the decoded blob from raw data.
unsigned char const * objectData_
Definition DecodedBlob.h:48
std::shared_ptr< NodeObject > createObject()
Create a NodeObject from this data.
T max(T... args)
constexpr Dest safeCast(Src s) noexcept
Definition safe_cast.h:21
std::vector< unsigned char > Blob
Storage for linear binary data.
Definition Blob.h:11