![]() |
Home | Libraries | Author | Links |
It provides an input buffer of bufSize bytes acting as sliding window over the concatenated input. This buffer consists of three parts, the processed range [buffer,bufPtr()), the unprocessed range [bufPtr(),bufEnd()) and the unassined range [bufEnd(),buffer+bufSize). The byte pointer bufPtr() addresses the current position within the buffer corresponding to the byte with the offset offset() in the concatenation of all input files. The method file() designates the current input file, i.e that input file containing the byte at offset offset() in the concatenation af all input files.
After construction the processed and unprocessed ranges have length 0. FileRangeT shall be a model of Forward Range and its value type shall represent a file accessible for reading, be convertable to std::string thus representing the file's name and have a method fileSize() yielding the file's byte size.
Definition at line 661 of file filesysaids.hpp.
Public Types | |
enum | |
Maximal Length of the input buffer. More... | |
typedef FileRangeT | filerange_type |
Type of input file range. | |
typedef filerange_type::value_type | inputfile_type |
Type of input files. | |
Public Member Functions | |
inputrange (const filerange_type &inputFiles=filerange_type()) | |
Construct an inputrange object for the input file range inputFiles having a buffer with processed and unprocessed ranges of length 0. | |
virtual | ~inputrange () |
The destructor deletes the input buffer. | |
void | clear () |
Clears this inputrange. | |
void | setInput (const filerange_type &inputFiles) |
Sets new input files for this inputrange. | |
bool | read () throw (std::runtime_error) |
Read bytes from the input files into the buffer. | |
bool | isEnd () const |
Return true, if all input bytes have been read. | |
bool | isError () const |
Return true, if an error did occur. | |
const inputfile_type & | file () const |
Return current input file. | |
const inputfile_type & | file (long long offs) const |
Return the input file containing the byte at offset offs within the concatenation of all input files. | |
ptrdiff_t | fileOffset (long long offs) const |
Return the file offset of the byte at offset offs within the concatenation of all input files in the file containing that byte. | |
long long | offset () const |
Return the byte offset within the concatenation of all input files corresponding to the current position within the input buffer. | |
long long | offset (const byte *ptr) const |
Return the byte offset within the concatenation of all input files corresponding to the byte address ptr within the input buffer. | |
long long | totalSize () const |
Return the total byte length of the concatenation of all input files. | |
long long | notReadSize () const |
Return the not read byte length of the concatenation of all input files. | |
void | setBufStep (ptrdiff_t step) |
Set the number of bytes to increase the processed buffer range and the byte offset within the concatenation of all input files. | |
void | bufSetup () |
Setup the input buffer by setting the begin of the unprocessed range of the buffer to its begin, thus emptying the processed range. | |
const byte * | bufPtr () const |
Return the start address of the unprocessed buffer range. | |
const byte * | bufEnd () const |
Return the past-the-end address of the unprocessed buffer range. | |
bool | bufExhausted () const |
Return true, if the unprocessed buffer range is empty. | |
bool | bufFull () const |
Return true, if the unprocessed buffer range occupies the whole buffer. | |
void | bufAdvance () |
Decrease the unprocessed buffer range, increase the processed buffer range and the byte offset within the concatenation of all input files as configured by setBufStep(). | |
virtual void | reportOpen () const |
Called when a new input file is opened. | |
virtual void | reportClose () const |
Called when the current input file is closed. | |
virtual void | reportError () const |
Called when a read error for the current input file occurs. |
typedef FileRangeT stm::inputrange< FileRangeT, bufSize >::filerange_type |
typedef filerange_type::value_type stm::inputrange< FileRangeT, bufSize >::inputfile_type |
anonymous enum |
stm::inputrange< FileRangeT, bufSize >::inputrange | ( | const filerange_type & | inputFiles = filerange_type() |
) | [explicit] |
Construct an inputrange object for the input file range inputFiles having a buffer with processed and unprocessed ranges of length 0.
virtual stm::inputrange< FileRangeT, bufSize >::~inputrange | ( | ) | [virtual] |
The destructor deletes the input buffer.
void stm::inputrange< FileRangeT, bufSize >::clear | ( | ) |
Clears this inputrange.
void stm::inputrange< FileRangeT, bufSize >::setInput | ( | const filerange_type & | inputFiles | ) |
Sets new input files for this inputrange.
bool stm::inputrange< FileRangeT, bufSize >::read | ( | ) | throw (std::runtime_error) |
Read bytes from the input files into the buffer.
At first the unprocessed buffer range is moved to the beginning of the buffer, thus emptying the processed buffer range. Then the unprocessed buffer range is enlarged by appending as many bytes as possible from the input files. The method returns true on success. If it returns false, either an error has occurred in which case isError() will return true or the unprocessed buffer range occupies the whole buffer, in which case bufFull() will return true, or all input files have been read in which case isEnd() will return true. The method may throw std::runtime_error, if a file handling function fails.
bool stm::inputrange< FileRangeT, bufSize >::isEnd | ( | ) | const |
Return true, if all input bytes have been read.
bool stm::inputrange< FileRangeT, bufSize >::isError | ( | ) | const |
Return true, if an error did occur.
const inputfile_type& stm::inputrange< FileRangeT, bufSize >::file | ( | ) | const |
Return current input file.
const inputfile_type& stm::inputrange< FileRangeT, bufSize >::file | ( | long long | offs | ) | const |
Return the input file containing the byte at offset offs within the concatenation of all input files.
ptrdiff_t stm::inputrange< FileRangeT, bufSize >::fileOffset | ( | long long | offs | ) | const |
Return the file offset of the byte at offset offs within the concatenation of all input files in the file containing that byte.
long long stm::inputrange< FileRangeT, bufSize >::offset | ( | ) | const |
Return the byte offset within the concatenation of all input files corresponding to the current position within the input buffer.
long long stm::inputrange< FileRangeT, bufSize >::offset | ( | const byte * | ptr | ) | const |
Return the byte offset within the concatenation of all input files corresponding to the byte address ptr within the input buffer.
long long stm::inputrange< FileRangeT, bufSize >::totalSize | ( | ) | const |
Return the total byte length of the concatenation of all input files.
long long stm::inputrange< FileRangeT, bufSize >::notReadSize | ( | ) | const |
Return the not read byte length of the concatenation of all input files.
void stm::inputrange< FileRangeT, bufSize >::setBufStep | ( | ptrdiff_t | step | ) |
Set the number of bytes to increase the processed buffer range and the byte offset within the concatenation of all input files.
void stm::inputrange< FileRangeT, bufSize >::bufSetup | ( | ) |
const byte* stm::inputrange< FileRangeT, bufSize >::bufPtr | ( | ) | const |
Return the start address of the unprocessed buffer range.
const byte* stm::inputrange< FileRangeT, bufSize >::bufEnd | ( | ) | const |
Return the past-the-end address of the unprocessed buffer range.
bool stm::inputrange< FileRangeT, bufSize >::bufExhausted | ( | ) | const |
Return true, if the unprocessed buffer range is empty.
bool stm::inputrange< FileRangeT, bufSize >::bufFull | ( | ) | const |
void stm::inputrange< FileRangeT, bufSize >::bufAdvance | ( | ) |
Decrease the unprocessed buffer range, increase the processed buffer range and the byte offset within the concatenation of all input files as configured by setBufStep().
virtual void stm::inputrange< FileRangeT, bufSize >::reportOpen | ( | ) | const [virtual] |
Called when a new input file is opened.
The default implementation does nothing.
virtual void stm::inputrange< FileRangeT, bufSize >::reportClose | ( | ) | const [virtual] |
Called when the current input file is closed.
The default implementation does nothing.
virtual void stm::inputrange< FileRangeT, bufSize >::reportError | ( | ) | const [virtual] |
Called when a read error for the current input file occurs.
The default implementation throws std::runtime_error.
© Copyright Tom Michaelis 2002-2007
Distributed under the SysToMath Software License (See the accompanying file license.txt or a copy at www.SysToMath.com).