16#ifndef LIEF_VECTOR_STREAM_H
17#define LIEF_VECTOR_STREAM_H
31 using BinaryStream::p;
32 using BinaryStream::end;
33 using BinaryStream::start;
35 static result<VectorStream>
from_file(
const std::string& file);
37 BinaryStream(BinaryStream::STREAM_TYPE::VECTOR),
38 binary_(std::move(data)),
46 VectorStream&
operator=(
const VectorStream&) =
delete;
49 VectorStream&
operator=(VectorStream&& other)
noexcept =
default;
51 uint64_t
size()
const override {
55 const std::vector<uint8_t>&
content()
const {
61 return std::move(binary_);
64 const uint8_t*
p()
const override {
65 return this->binary_.data() + this->pos();
68 const uint8_t*
start()
const override {
69 return this->binary_.data();
72 const uint8_t*
end()
const override {
73 return this->binary_.data() + this->binary_.size();
77 std::unique_ptr<SpanStream>
slice(uint32_t offset,
size_t size)
const;
78 std::unique_ptr<SpanStream>
slice(uint32_t offset)
const;
80 static bool classof(
const BinaryStream& stream) {
81 return stream.
type() == STREAM_TYPE::VECTOR;
85 result<const void*> read_at(uint64_t offset, uint64_t size, uint64_t )
const override {
86 const uint64_t stream_size = this->size();
87 if (offset > stream_size || (offset + size) > stream_size) {
90 return binary_.data() + offset;
92 std::vector<uint8_t> binary_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
STREAM_TYPE type() const
Definition BinaryStream.hpp:53
Definition SpanStream.hpp:32
Definition VectorStream.hpp:29
VectorStream(VectorStream &&other) noexcept=default
std::vector< uint8_t > && move_content()
Definition VectorStream.hpp:59
static bool classof(const BinaryStream &stream)
Definition VectorStream.hpp:80
static result< VectorStream > from_file(const std::string &file)
VectorStream(const VectorStream &)=delete
const uint8_t * p() const override
Definition VectorStream.hpp:64
VectorStream & operator=(const VectorStream &)=delete
uint64_t size() const override
Definition VectorStream.hpp:51
const std::vector< uint8_t > & content() const
Definition VectorStream.hpp:55
std::unique_ptr< SpanStream > slice(uint32_t offset) const
std::unique_ptr< SpanStream > slice(uint32_t offset, size_t size) const
VectorStream & operator=(VectorStream &&other) noexcept=default
const uint8_t * start() const override
Definition VectorStream.hpp:68
const uint8_t * end() const override
Definition VectorStream.hpp:72
VectorStream(std::vector< uint8_t > data)
Definition VectorStream.hpp:36
@ read_error
Definition errors.hpp:24
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create an standard error code from lief_errors.
Definition errors.hpp:52
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41