ulib  1.0
S.W. Lee's essential C++ library
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
uindexfile.h
Go to the documentation of this file.
1 #ifndef __UINDEXFILE__
2 #define __UINDEXFILE__
3 
4 #include <stdlib.h>
5 #include <string.h>
6 #include <stdio.h>
7 
8 #include "ulib.h"
9 using namespace std;
10 
11 
12 namespace ulib {
13 
15  public:
16  unsigned long start;
17  unsigned long end;
18  bool enable;
19 
20  public:
22  {
23  start = end = 0;
24  enable = true;
25  }
26  };
27 
28 
29  class CUIndexFile {
30  public:
31  CUIndexFile();
32  ~CUIndexFile();
33  public:
34 
35  bool Load( char *prefix );
36  bool IsLoaded();
37  void Close();
38  int GetNumRecord() { return info_map.size(); }
39  CUStringList GetKeyList();
40  bool HaveKey( char *key );
41  bool GetInfo( char *key, CUIndexFileInfo &info );
42  bool GetInfo( char *key, unsigned long &start, unsigned long &end );
43  bool GetValue( char *key, CUString &ret );
44  bool GetValue( CUIndexFileInfo info, CUString &ret );
45  bool GetValue( char *key, void *ret );
46  bool GetValue( CUIndexFileInfo info, void *ret );
47 
48  bool Create( char *prefix );
49  bool Insert( char *key, char *value );
50  bool Insert( char *key, char *value, int len );
51  //bool Delete( char *key );
52 
53  map<string, CUIndexFileInfo> info_map;
54 
55  private:
56  CUTextFile key_file;
57  CUTextFile value_file;
58 
59  };
60 
61 }
62 
63 #endif
64