7 #ifndef PACKAGER_MEDIA_BASE_BUFFER_READER_H_
8 #define PACKAGER_MEDIA_BASE_BUFFER_READER_H_
14 #include <packager/macros/classes.h>
25 : buf_(buf), size_(size), pos_(0) {}
30 bool HasBytes(
size_t count) {
return pos() + count <= size(); }
36 [[nodiscard]]
bool Read1(uint8_t* v);
37 [[nodiscard]]
bool Read2(uint16_t* v);
38 [[nodiscard]]
bool Read2s(int16_t* v);
39 [[nodiscard]]
bool Read4(uint32_t* v);
40 [[nodiscard]]
bool Read4s(int32_t* v);
41 [[nodiscard]]
bool Read8(uint64_t* v);
42 [[nodiscard]]
bool Read8s(int64_t* v);
51 [[nodiscard]]
bool ReadNBytesInto8s(int64_t* v,
size_t num_bytes);
54 [[nodiscard]]
bool ReadToVector(std::vector<uint8_t>* t,
size_t count);
55 [[nodiscard]]
bool ReadToString(std::string* str,
size_t size);
62 [[nodiscard]]
bool SkipBytes(
size_t num_bytes);
64 const uint8_t* data()
const {
return buf_; }
65 size_t size()
const {
return size_; }
66 void set_size(
size_t size) { size_ = size; }
67 size_t pos()
const {
return pos_; }
72 [[nodiscard]]
bool Read(T* t);
74 [[nodiscard]]
bool ReadNBytes(T* t,
size_t num_bytes);
All the methods that are virtual are virtual for mocking.