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

Keyfile.hpp

Go to the documentation of this file.
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 #ifndef _LEMUR_KEYFILE_H
00014 #define _LEMUR_KEYFILE_H
00015 
00018 class Keyfile {
00019 public:
00022   void put( const char* key, const void* value, int valueSize );
00025   void put( int key, const void* value, int valueSize );
00026 
00029   bool get( const char* key, void* value, int& actualSize, int maxSize ) const;
00032   bool get( const char* key, char** value, int& actualSize ) const;
00035   bool get( int key, void* value, int& actualSize, int maxSize ) const;
00038   bool get( int key, char** value, int& actualSize ) const;
00039 
00042   int getSize( const char* key ) const;
00045   int getSize( int key ) const;
00046 
00048   void remove( const char* key );
00050   void remove( int key );
00051 
00053   void open( const std::string& filename, int cacheSize = 1024 * 1024 );
00055   void open( const char* filename, int cacheSize = 1024 * 1024 );
00057   void create( const std::string& filename, int cacheSize = 1024 * 1024 );
00059   void create( const char* filename, int cacheSize = 1024 * 1024 );
00061   void close();
00063   void setFirst();
00065   bool getNext( int& key, void* value, int& actualSize, int maxSize ) const;
00067   bool getNext( char* key, int maxKeySize, void* value, 
00068                 int& actualSize, int maxSize ) const;
00070   //  Keyfile() : _handleSize(0), _handle(std::auto_ptr<char>(NULL)) {
00071   Keyfile() : _handleSize(0), _handle(NULL) {
00072   }
00073   
00074 private:
00075   //  std::auto_ptr<char> _handle; // file control block of the keyfile
00076   char* _handle; // file control block of the keyfile
00077   int _handleSize; // sizeof _handle buffer
00078 
00079   void _buildHandle( int cacheSize );
00080   void _createKey( char* keyBuf, int number ) const;
00081   int _decodeKey( char* keyBuf ) const;
00082 };
00083 
00084 #endif // _LEMUR_KEYFILE_H

Generated on Fri Jul 2 16:25:36 2004 for Lemur Toolkit by doxygen1.2.18