10#ifndef NEWGRF_BYTEREADER_H
11#define NEWGRF_BYTEREADER_H
20 const uint8_t *ReadBytes(
size_t size)
22 if (this->data + size >= this->end) {
24 this->data = this->
end;
28 const uint8_t *ret = this->
data;
39 if (this->data < this->
end)
return *this->data++;
50 return val | (this->
ReadByte() << 8);
60 return val == 0xFF ? this->
ReadWord() : val;
70 return val | (this->
ReadWord() << 16);
77 size_t Remaining()
const
79 return this->end - this->
data;
82 bool HasData(
size_t count = 1)
const
84 return this->data + count <= this->
end;
Class to read from a NewGRF file.
const uint8_t * data
Current position within data.
uint32_t PeekDWord()
Read a single DWord (32 bits).
uint32_t ReadDWord()
Read a single DWord (32 bits).
uint16_t ReadWord()
Read a single Word (16 bits).
std::string_view ReadString()
Read a string.
uint16_t ReadExtendedByte()
Read a single Extended Byte (8 or 16 bits).
uint32_t ReadVarSize(uint8_t size)
Read a value of the given number of bytes.
uint8_t ReadByte()
Read a single byte (8 bits).
const uint8_t * end
Last position of data.