Main Page   Namespace List   Class Hierarchy   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:
00021   enum access_mode{ random, sequential };
00022 
00025   void put( const char* key, const void* value, int valueSize );
00028   void put( int key, const void* value, int valueSize );
00029 
00032   bool get( const char* key, void* value, int& actualSize, int maxSize );
00035   bool get( const char* key, char** value, int& actualSize );
00038   bool get( int key, void* value, int& actualSize, int maxSize );
00041   bool get( int key, char** value, int& actualSize );
00042 
00045   int getSize( const char* key );
00048   int getSize( int key );
00049 
00051   void remove( const char* key );
00053   void remove( int key );
00054 
00057   void open( const std::string& filename, access_mode mode, 
00058              int cacheSize = 1024 * 1024 );
00061   void open( const char* filename, access_mode mode, 
00062              int cacheSize = 1024 * 1024 );
00065   void create( const std::string& filename, access_mode mode,
00066                int cacheSize = 1024 * 1024 );
00069   void create( const char* filename, access_mode mode, 
00070                int cacheSize = 1024 * 1024 );
00072   void close();
00073   
00074 private:
00075   std::auto_ptr<char> _handle; // file control block of the keyfile
00076   int _handleSize; // sizeof _handle buffer
00077 
00078   void _buildHandle( int cacheSize );
00079   void _createKey( char* keyBuf, int number );
00080   int _decodeKey( char* keyBuf );
00081 };
00082 
00083 #endif // _LEMUR_KEYFILE_H

Generated on Fri Feb 6 07:11:47 2004 for LEMUR by doxygen1.2.16