16#ifndef LIEF_SPAN_STREAM_H
17#define LIEF_SPAN_STREAM_H
69 uint64_t
size()
const override {
73 const uint8_t*
p()
const override {
74 return data_.data() + this->
pos();
77 const uint8_t*
start()
const override {
81 const uint8_t*
end()
const override {
82 return data_.data() +
size();
86 return {data_.begin(), data_.end()};
90 if (offset > data_.size() || (offset +
size) > data_.size()) {
93 return data_.subspan(offset,
size);
96 if (offset > data_.size()) {
99 return data_.subspan(offset, data_.size() - offset);
110 const uint64_t stream_size = this->
size();
111 if (offset > stream_size || (offset +
size) > stream_size) {
114 return data_.data() + offset;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
STREAM_TYPE
Definition BinaryStream.hpp:38
virtual const uint8_t * p() const
Definition BinaryStream.hpp:199
size_t pos() const
Definition BinaryStream.hpp:125
virtual uint8_t * start()
Definition BinaryStream.hpp:203
STREAM_TYPE type() const
Definition BinaryStream.hpp:54
virtual uint8_t * end()
Definition BinaryStream.hpp:211
Definition SpanStream.hpp:29
~SpanStream() override=default
SpanStream & operator=(SpanStream &&other) noexcept=default
const uint8_t * p() const override
Definition SpanStream.hpp:73
SpanStream(const uint8_t *p, size_t size)
Definition SpanStream.hpp:52
static bool classof(const BinaryStream &stream)
Definition SpanStream.hpp:102
SpanStream(const SpanStream &)=delete
SpanStream(span< uint8_t > data)
Definition SpanStream.hpp:48
result< SpanStream > slice(size_t offset, size_t size) const
Definition SpanStream.hpp:89
static result< SpanStream > from_vector(const std::vector< uint8_t > &data)
Definition SpanStream.hpp:35
static result< SpanStream > from_array(const std::array< uint8_t, N > &data)
Definition SpanStream.hpp:40
const uint8_t * start() const override
Definition SpanStream.hpp:77
SpanStream(const std::vector< uint8_t > &data)
Definition SpanStream.hpp:57
SpanStream(SpanStream &&other) noexcept=default
const uint8_t * end() const override
Definition SpanStream.hpp:81
result< SpanStream > slice(size_t offset) const
Definition SpanStream.hpp:95
SpanStream & operator=(const SpanStream &)=delete
uint64_t size() const override
Definition SpanStream.hpp:69
std::vector< uint8_t > content() const
Definition SpanStream.hpp:85
SpanStream(span< const uint8_t > data)
Definition SpanStream.hpp:44
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create an standard error code from lief_errors.
Definition errors.hpp:51
LIEF namespace.
Definition Abstract/Binary.hpp:32
tcb::span< ElementType, Extent > span
Definition span.hpp:22
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:74