Home Libraries Author Links

stm::inputrange< FileRangeT, bufSize > Class Template Reference
[FilesysAids: File System Aids]

Inheritance diagram for stm::inputrange< FileRangeT, bufSize >:

Inheritance graph
[legend]

List of all members.


Detailed Description

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
class stm::inputrange< FileRangeT, bufSize >

Class template representing a range of input files.

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_typefile () const
 Return current input file.
const inputfile_typefile (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.

Member Typedef Documentation

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
typedef FileRangeT stm::inputrange< FileRangeT, bufSize >::filerange_type

Type of input file range.

Definition at line 672 of file filesysaids.hpp.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
typedef filerange_type::value_type stm::inputrange< FileRangeT, bufSize >::inputfile_type

Type of input files.

Definition at line 675 of file filesysaids.hpp.


Member Enumeration Documentation

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
anonymous enum

Maximal Length of the input buffer.

Definition at line 669 of file filesysaids.hpp.


Constructor & Destructor Documentation

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
virtual stm::inputrange< FileRangeT, bufSize >::~inputrange (  )  [virtual]

The destructor deletes the input buffer.


Member Function Documentation

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
void stm::inputrange< FileRangeT, bufSize >::clear (  ) 

Clears this inputrange.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
void stm::inputrange< FileRangeT, bufSize >::setInput ( const filerange_type inputFiles  ) 

Sets new input files for this inputrange.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
bool stm::inputrange< FileRangeT, bufSize >::isEnd (  )  const

Return true, if all input bytes have been read.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
bool stm::inputrange< FileRangeT, bufSize >::isError (  )  const

Return true, if an error did occur.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
const inputfile_type& stm::inputrange< FileRangeT, bufSize >::file (  )  const

Return current input file.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
long long stm::inputrange< FileRangeT, bufSize >::totalSize (  )  const

Return the total byte length of the concatenation of all input files.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
long long stm::inputrange< FileRangeT, bufSize >::notReadSize (  )  const

Return the not read byte length of the concatenation of all input files.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
void stm::inputrange< FileRangeT, bufSize >::bufSetup (  ) 

Setup the input buffer by setting the begin of the unprocessed range of the buffer to its begin, thus emptying the processed range.

As this method's operation is performed by the constructor and by a successful read, it is rarely needed to be called by the user.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
const byte* stm::inputrange< FileRangeT, bufSize >::bufPtr (  )  const

Return the start address of the unprocessed buffer range.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
const byte* stm::inputrange< FileRangeT, bufSize >::bufEnd (  )  const

Return the past-the-end address of the unprocessed buffer range.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
bool stm::inputrange< FileRangeT, bufSize >::bufExhausted (  )  const

Return true, if the unprocessed buffer range is empty.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
bool stm::inputrange< FileRangeT, bufSize >::bufFull (  )  const

Return true, if the unprocessed buffer range occupies the whole buffer.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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().

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
virtual void stm::inputrange< FileRangeT, bufSize >::reportOpen (  )  const [virtual]

Called when a new input file is opened.

The default implementation does nothing.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
virtual void stm::inputrange< FileRangeT, bufSize >::reportClose (  )  const [virtual]

Called when the current input file is closed.

The default implementation does nothing.

template<class FileRangeT = std::list<readablefile<pstring> >, size_t bufSize = 128 * 1024>
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).