Optimal file reader.
More...
#include <base/io/FileReader.h>
Inherits Object.
Optimal file reader.
File reader utilizing the file mapping support.
- Version
- 1.0
◆ ReadIterator
Iterator used to traverse the elements within the current file mapping window.
◆ FileReader()
Initializes the object.
- Parameters
-
file | The file. |
position | The initial position. |
windowSize | The preferred size of the mapping window. The actual window size used may be less or greater. |
◆ getBytes()
const uint8* FileReader::getBytes |
( |
| ) |
const |
|
inlinenoexcept |
Returns the bytes of the entire window.
◆ getPosition()
long long FileReader::getPosition |
( |
| ) |
const |
|
inlinenoexcept |
Returns the current position indexed from the beginning of the file.
◆ getSize()
MemorySize FileReader::getSize |
( |
| ) |
const |
|
inlinenoexcept |
Returns the available bytes.
◆ peek()
Ensures that the specified number of bytes are mapped without changing the current position. Raises IOException if requested number of bytes cannot be mapped.
- Parameters
-
size | The number of bytes to peek at. |
- Returns
- A ReadIterator to the first element.
◆ read()
void FileReader::read |
( |
uint8 * |
buffer, |
|
|
unsigned int |
size |
|
) |
| |
Fills the specified buffer with the requested number of bytes and increments the position, respectively.
- Parameters
-
buffer | The buffer. |
size | The number of bytes the copy to the buffer. |
◆ requestRegion()
void FileReader::requestRegion |
( |
const FileRegion & |
region | ) |
|
|
protected |
Requests mapping of the specified region.
- Parameters
-
region | The region to be mapped. |
◆ seek()
void FileReader::seek |
( |
long long |
position | ) |
|
|
inline |
Sets the current position indexed from the beginning of the file. Used this method if you want to skip a large number of bytes. Raises IOException if the postion exceeds the end of the file.
- Parameters
-
position | The desired postion. |
◆ skip()
void FileReader::skip |
( |
unsigned int |
size | ) |
|
|
inline |
Skips the specified number of bytes. Normally used to skip a small number of bytes.
- Parameters
-
size | The number of bytes to skip. |
◆ DEFAULT_WINDOW_SIZE
constexpr unsigned int FileReader::DEFAULT_WINDOW_SIZE = 0x10000 |
|
staticconstexpr |
The default preferred window size.