MCPcopy Create free account
hub / github.com/activeloopai/deeplake / read_buffer

Class read_buffer

cpp/base/read_buffer.hpp:17–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15namespace base {
16
17class read_buffer
18{
19public:
20 using value_type = uint8_t;
21
22 read_buffer() = default;
23
24 explicit read_buffer(std::string&& s)
25 {
26 auto h = std::make_shared<std::string>(std::move(s));
27 data_ = span_cast<const uint8_t>(std::span<const char>(h->data(), h->size()));
28 holder_ = std::move(h);
29 }
30
31 template <typename T>
32 explicit read_buffer(std::vector<T>&& b)
33 : data_(span_cast<const uint8_t>(std::span<T>(b.data(), b.size())))
34 , holder_(std::make_shared<std::vector<T>>(std::move(b)))
35 {
36 }
37
38 template <typename T>
39 explicit read_buffer(boost::container::vector<T>&& b)
40 : data_(span_cast<const uint8_t>(std::span<T>(b.data(), b.size())))
41 , holder_(std::make_shared<boost::container::vector<T>>(std::move(b)))
42 {
43 }
44
45 read_buffer(std::shared_ptr<void> holder, std::span<const uint8_t> data)
46 : data_(data)
47 , holder_(std::move(holder))
48 {
49 }
50
51 const uint8_t* data() const noexcept
52 {
53 return data_.data();
54 }
55
56 size_t size() const noexcept
57 {
58 return data_.size();
59 }
60
61 bool empty() const noexcept
62 {
63 return size() == 0;
64 }
65
66 template <typename T>
67 std::span<const T> span() const noexcept
68 {
69 return span_cast<const T>(span());
70 }
71
72 std::span<const uint8_t> span() const noexcept
73 {
74 return data_;

Callers 1

chunkMethod · 0.85

Calls 1

spanClass · 0.85

Tested by

no test coverage detected