7 #ifndef MEDIA_BASE_BUFFER_READER_H_
8 #define MEDIA_BASE_BUFFER_READER_H_
15 #include "packager/base/compiler_specific.h"
16 #include "packager/base/macros.h"
18 namespace edash_packager {
27 : buf_(buf), size_(size), pos_(0) {}
32 bool HasBytes(
size_t count) {
return pos() + count <= size(); }
38 bool Read1(uint8_t* v) WARN_UNUSED_RESULT;
39 bool Read2(uint16_t* v) WARN_UNUSED_RESULT;
40 bool Read2s(int16_t* v) WARN_UNUSED_RESULT;
41 bool Read4(uint32_t* v) WARN_UNUSED_RESULT;
42 bool Read4s(int32_t* v) WARN_UNUSED_RESULT;
43 bool Read8(uint64_t* v) WARN_UNUSED_RESULT;
44 bool Read8s(int64_t* v) WARN_UNUSED_RESULT;
53 bool ReadNBytesInto8s(int64_t* v,
size_t num_bytes) WARN_UNUSED_RESULT;
56 bool ReadToVector(std::vector<uint8_t>* t,
size_t count) WARN_UNUSED_RESULT;
57 bool ReadToString(std::string* str,
size_t size) WARN_UNUSED_RESULT;
61 bool SkipBytes(
size_t num_bytes) WARN_UNUSED_RESULT;
63 const uint8_t* data()
const {
return buf_; }
64 size_t size()
const {
return size_; }
65 void set_size(
size_t size) { size_ = size; }
66 size_t pos()
const {
return pos_; }
71 bool Read(T* t) WARN_UNUSED_RESULT;
73 bool ReadNBytes(T* t,
size_t num_bytes) WARN_UNUSED_RESULT;
85 #endif // MEDIA_BASE_BUFFER_READER_H_