Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

RVLDecompressStream.hpp

Go to the documentation of this file.
00001 /*==========================================================================
00002  * Copyright (c) 2004 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.lemurproject.org/license.html
00008  *
00009  *==========================================================================
00010 */
00011 
00012 
00013 //
00014 //
00015 //
00016 //
00017 //
00018 
00019 #ifndef INDRI_RVLDECOMPRESSSTREAM_HPP
00020 #define INDRI_RVLDECOMPRESSSTREAM_HPP
00021 
00024 class RVLDecompressStream {
00025 private:
00026   const char* _buffer;
00027   int _bufferSize;
00028   const char* _current;
00029 
00030 public:
00034   RVLDecompressStream( const char* buffer, int size ) {
00035     _buffer = buffer;
00036     _bufferSize = size;
00037     _current = buffer;
00038   }
00039 
00042   RVLDecompressStream& operator>> ( INT64& value ) {
00043     _current = RVLCompress::decompress_longlong( _current, value );
00044     assert( _current - _buffer <= _bufferSize );
00045     return *this;
00046   }
00047 
00050   RVLDecompressStream& operator>> ( UINT64& value ) {
00051     INT64 other;
00052     _current = RVLCompress::decompress_longlong( _current, other );
00053     assert( _current - _buffer <= _bufferSize );
00054     value = other;
00055     return *this;
00056   }
00057 
00060   RVLDecompressStream& operator>> ( int& value ) {
00061     _current = RVLCompress::decompress_int( _current, value );
00062     assert( _current - _buffer <= _bufferSize );    
00063     return *this;
00064   }
00065 
00068   RVLDecompressStream& operator>> ( unsigned int& value ) {
00069     int v;
00070     _current = RVLCompress::decompress_int( _current, v );
00071     value = (unsigned int) v;
00072     assert( _current - _buffer <= _bufferSize );    
00073     return *this;
00074   }
00075 
00078   RVLDecompressStream& operator>> ( float& value ) {
00079     // doubles aren't compressed
00080     memcpy( &value, _current, sizeof value );
00081     _current += sizeof value;
00082     return *this;
00083   }
00085   bool done() const {
00086     return (_current - _buffer) >= _bufferSize;
00087   }
00088 };
00089 
00090 #endif // INDRI_RVLDECOMPRESSSTREAM_HPP

Generated on Wed Nov 3 12:59:03 2004 for Lemur Toolkit by doxygen1.2.18