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

RVLCompressStream.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 // RVLCompressStream
00015 //
00016 // 9 February 2004 -- tds
00017 //
00018 
00019 #ifndef INDRI_RVLCOMPRESSSTREAM_HPP
00020 #define INDRI_RVLCOMPRESSSTREAM_HPP
00021 
00024 class RVLCompressStream {
00025 private:
00026   char* _buffer;
00027   size_t _bufferSize;
00028   char* _current;
00029 
00030 public:
00034   RVLCompressStream( char* buffer, size_t size ) {
00035     _buffer = buffer;
00036     _bufferSize = size;
00037     _current = _buffer;
00038   }
00039 
00041   const char* data() const {
00042     return _buffer;
00043   }
00045   size_t dataSize() const {
00046     return _current - _buffer;
00047   }
00048 
00051   RVLCompressStream& operator<< ( int value ) {
00052     _current = RVLCompress::compress_int( _current, value );
00053     assert( _bufferSize >= size_t(_current - _buffer) );
00054     return *this;
00055   }
00056 
00059   RVLCompressStream& operator<< ( unsigned int value ) {
00060     _current = RVLCompress::compress_int( _current, value );
00061     assert( _bufferSize >= size_t(_current - _buffer) );
00062     return *this;
00063   }
00064 
00067   RVLCompressStream& operator<< ( INT64 value ) {
00068     _current = RVLCompress::compress_longlong( _current, value );
00069     assert( _bufferSize >= size_t(_current - _buffer) );
00070     return *this;
00071   }
00072 
00075   RVLCompressStream& operator << ( float value ) {
00076     // can't compress a float, unfortunately
00077     memcpy( _current, &value, sizeof value );
00078     _current += sizeof value;
00079     return *this;
00080   }
00081 };
00082 
00083 #endif // INDRI_RVLCOMPRESSSTREAM_HPP
00084 

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