00001
00002
00003
00004
00005
00006
00007
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
00071 Keyfile() : _handleSize(0), _handle(NULL) {
00072 }
00073
00074 private:
00075
00076 char* _handle;
00077 int _handleSize;
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