byteme
C++ wrappers for buffered inputs
Loading...
Searching...
No Matches
byteme::SomeFileReader Class Reference

Read a file that may or may not be Gzipped. More...

#include <SomeFileReader.hpp>

Inheritance diagram for byteme::SomeFileReader:
Collaboration diagram for byteme::SomeFileReader:

Public Member Functions

 SomeFileReader (const char *path, size_t buffer_size=65536)
 
 SomeFileReader (const std::string &path, size_t buffer_size=65536)
 
bool load ()
 
const unsigned char * buffer () const
 
size_t available () const
 
- Public Member Functions inherited from byteme::Reader

Detailed Description

Read a file that may or may not be Gzipped.

This class will automatically detect whether path refers to a text file or a Gzip-compressed file, based on its initial magic numbers. After that, it will dispatch appropriately to RawFileReader or GzipFileReader respectively.

Constructor & Destructor Documentation

◆ SomeFileReader() [1/2]

byteme::SomeFileReader::SomeFileReader ( const char * path,
size_t buffer_size = 65536 )
inline
Parameters
pathPath to the file.
buffer_sizeSize of the buffer to use for reading.

◆ SomeFileReader() [2/2]

byteme::SomeFileReader::SomeFileReader ( const std::string & path,
size_t buffer_size = 65536 )
inline
Parameters
pathPath to the file.
buffer_sizeSize of the buffer to use for reading.

Member Function Documentation

◆ available()

size_t byteme::SomeFileReader::available ( ) const
inlinevirtual

This method should only be called after load() has been called and returns true. The return value is generally expected to be positive; however, it is possible to return a zero. Note that zero values should not be interpreted as the end of the source, which is strictly only defined by load() returning false.

Returns
Number of available bytes in buffer().

Implements byteme::Reader.

◆ buffer()

const unsigned char * byteme::SomeFileReader::buffer ( ) const
inlinevirtual

This method should only be called after load() has been called and returns true.

Returns
Pointer to the start of an array containing the available bytes. The number of available bytes is provided in available().

Implements byteme::Reader.

◆ load()

bool byteme::SomeFileReader::load ( )
inlinevirtual

Read the next chunk of bytes from the input source. To read the entire source, this function should be called repeatedly until false is returned.

Returns
Boolean indicating whether the read was successful. If false, it can be assumed that the end of the source was reached.

Implements byteme::Reader.


The documentation for this class was generated from the following file: