|
SoundFontInfoLib
2.21.6
Library for parsing and rendering SF2 files
|
Representation of a file position. More...
#include <Pos.hpp>
Classes | |
| struct | Mockery |
| RAII struct for handling mocking of the Pos file IO methods. More... | |
Public Types | |
| using | SeekProcType = off_t(*)(int fd, off_t offset, int whence) |
| Type of function to call to seek to a position in a file. More... | |
| using | ReadProcType = ssize_t(*)(int fd, void *buffer, size_t size) |
| Type of function to call to read from current position in a file. More... | |
Public Member Functions | |
| Pos (int fd, size_t pos, size_t end) | |
| Constructor. More... | |
| ChunkList | makeChunkList () const |
| Create a new ChunkList from the current position. More... | |
| Chunk | makeChunk () const |
| Create a new Chunk from the current position. More... | |
| template<typename T > | |
| Pos | readInto (T &buffer) const |
| Read bytes from the file at the current position and place them into the given buffer. More... | |
| template<typename T > | |
| Pos | readInto (T &buffer, size_t maxCount) const |
| Read bytes from the file at the current position and place them into the given buffer. More... | |
| Pos | readInto (void *buffer, size_t count) const |
| Read bytes from the file at the current position and place them into the given buffer. More... | |
| constexpr size_t | offset () const |
| Obtain the file offset represented by this instance. More... | |
| constexpr size_t | available () const |
| Pos | advance (size_t offset) const |
Calculate new Pos value after advancing offset bytes forward. More... | |
| constexpr | operator bool () const |
Static Public Attributes | |
| static SeekProcType | SeekProc = &::lseek |
| Function to call to seek to a position in a file. More... | |
| static ReadProcType | ReadProc = &::read |
| Function to call to read from current position in a file. More... | |
Friends | |
| bool | operator< (const Pos &lhs, const Pos &rhs) |
Representation of a file position.
Instances of this type are immutable by design. It has methods that will generate instances with new position values.
| using SF2::IO::Pos::ReadProcType = ssize_t (*)(int fd, void* buffer, size_t size) |
Type of function to call to read from current position in a file.
| using SF2::IO::Pos::SeekProcType = off_t (*)(int fd, off_t offset, int whence) |
Type of function to call to seek to a position in a file.
|
inline |
Constructor.
| fd | the file descriptor to read from |
| pos | the current location in the file being processed |
| end | the end of the file being processed |
Referenced by advance().
|
inline |
Calculate new Pos value after advancing offset bytes forward.
| offset | the number of bytes to advance |
References offset(), and Pos().
Referenced by SF2::IO::Chunk::advance(), SF2::IO::Chunk::end(), makeChunk(), makeChunkList(), and readInto().
|
inlineconstexpr |
| Chunk Pos::makeChunk | ( | ) | const |
Create a new Chunk from the current position.
References advance(), and SF2::IO::error.
| ChunkList Pos::makeChunkList | ( | ) | const |
Create a new ChunkList from the current position.
References advance(), and SF2::IO::error.
Referenced by SF2::IO::File::File(), and SF2::IO::Parser::parse().
|
inlineconstexpr |
|
inlineexplicitconstexpr |
|
inline |
Read bytes from the file at the current position and place them into the given buffer.
| buffer | the destination for the bytes |
Referenced by SF2::Entity::Bag::Bag(), SF2::IO::Chunk::extract(), SF2::IO::Chunk::extractSamples(), SF2::Entity::Generator::Generator::Generator(), SF2::Entity::Instrument::Instrument(), SF2::Entity::Version::load(), SF2::Entity::Modulator::Modulator::Modulator(), SF2::Entity::Preset::Preset(), readInto(), and SF2::Entity::SampleHeader::SampleHeader().
|
inline |
Read bytes from the file at the current position and place them into the given buffer.
| buffer | the destination for the bytes |
| maxCount | the maximum number of bytes to read, even if the size of the buffer is larger |
References readInto().
|
inline |
Read bytes from the file at the current position and place them into the given buffer.
| buffer | the destination for the bytes |
| count | the number number of bytes to read |
References advance(), and SF2::IO::error.
|
static |
Function to call to read from current position in a file.
Referenced by SF2::IO::Pos::Mockery::Mockery(), and SF2::IO::Pos::Mockery::~Mockery().
|
static |
Function to call to seek to a position in a file.
Referenced by SF2::IO::Pos::Mockery::Mockery(), and SF2::IO::Pos::Mockery::~Mockery().