rippled
EncodedBlob.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED
21 #define RIPPLE_NODESTORE_ENCODEDBLOB_H_INCLUDED
22 
23 #include <ripple/basics/Buffer.h>
24 #include <ripple/nodestore/NodeObject.h>
25 #include <cstddef>
26 
27 namespace ripple {
28 namespace NodeStore {
29 
33 // VFALCO TODO Make allocator aware and use short_alloc
35 {
36 public:
37  void prepare (std::shared_ptr<NodeObject> const& object);
38 
39  void const* getKey () const noexcept
40  {
41  return m_key;
42  }
43 
44  std::size_t getSize () const noexcept
45  {
46  return m_data.size();
47  }
48 
49  void const* getData () const noexcept
50  {
51  return reinterpret_cast<void const*>(m_data.data());
52  }
53 
54 private:
55  void const* m_key;
57 };
58 
59 }
60 }
61 
62 #endif
ripple::NodeStore::EncodedBlob::getSize
std::size_t getSize() const noexcept
Definition: EncodedBlob.h:44
std::shared_ptr< NodeObject >
ripple::Buffer
Like std::vector<char> but better.
Definition: Buffer.h:35
ripple::NodeStore::EncodedBlob::getData
void const * getData() const noexcept
Definition: EncodedBlob.h:49
ripple::NodeStore::EncodedBlob::m_key
void const * m_key
Definition: EncodedBlob.h:55
cstddef
ripple::Buffer::size
std::size_t size() const noexcept
Returns the number of bytes in the buffer.
Definition: Buffer.h:130
ripple::Buffer::data
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Definition: Buffer.h:154
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
std::size_t
ripple::NodeStore::EncodedBlob
Utility for producing flattened node objects.
Definition: EncodedBlob.h:34
ripple::NodeStore::EncodedBlob::getKey
void const * getKey() const noexcept
Definition: EncodedBlob.h:39
ripple::NodeStore::EncodedBlob::prepare
void prepare(std::shared_ptr< NodeObject > const &object)
Definition: EncodedBlob.cpp:27
ripple::NodeStore::EncodedBlob::m_data
Buffer m_data
Definition: EncodedBlob.h:56