00001 /*========================================================================== 00002 * Copyright (c) 2003 University of Massachusetts. All Rights Reserved. 00003 * 00004 * Use of the Lemur Toolkit for Language Modeling and Information Retrieval 00005 * is subject to the terms of the software license set forth in the LICENSE 00006 * file included with this software, and also available at 00007 * http://www.cs.cmu.edu/~lemur/license.html 00008 * 00009 *========================================================================== 00010 */ 00011 00012 00013 // 00014 // ReadBuffer 00015 // 00016 // tds - 13 November 2003 00017 // 00018 00019 #ifndef LEMUR_READBUFFER_HPP 00020 #define LEMUR_READBUFFER_HPP 00021 00022 #include "File.hpp" 00023 00025 class ReadBuffer { 00026 private: 00027 File::offset_type _filePosition; 00028 char* _buffer; 00029 File& _file; 00030 int _bufferSize; 00031 int _bufferPosition; 00032 int _bufferDataLength; 00033 bool _gValid; 00034 00035 public: 00040 ReadBuffer( File& file, int bufferSize ); 00041 ~ReadBuffer(); 00042 00046 void read( char* data, int length ); 00047 00051 const char* peek( int length ); 00052 00056 const char* read( int length ); 00057 00062 void seekg( File::offset_type position, std::fstream::seekdir direction ); 00063 00066 File::offset_type tellg(); 00067 00071 int rdstate(); 00072 00076 void invalidateg(); 00077 }; 00078 00079 #endif // LEMUR_READBUFFER_HPP