Switch to unified view

a/src/rcldb/rcldb.h b/src/rcldb/rcldb.h
1
#ifndef _DB_H_INCLUDED_
1
#ifndef _DB_H_INCLUDED_
2
#define _DB_H_INCLUDED_
2
#define _DB_H_INCLUDED_
3
/* @(#$Id: rcldb.h,v 1.22 2006-01-11 15:08:21 dockes Exp $  (C) 2004 J.F.Dockes */
3
/* @(#$Id: rcldb.h,v 1.23 2006-01-26 12:28:50 dockes Exp $  (C) 2004 J.F.Dockes */
4
4
5
#include <string>
5
#include <string>
6
#include <list>
6
#include <list>
7
#include <vector>
7
#include <vector>
8
#ifndef NO_NAMESPACES
8
#ifndef NO_NAMESPACES
...
...
29
#ifndef NO_NAMESPACES
29
#ifndef NO_NAMESPACES
30
namespace Rcl {
30
namespace Rcl {
31
#endif
31
#endif
32
32
33
/**
33
/**
34
 * Dumb bunch holder for document attributes and data
34
 * Dumb holder for document attributes and data
35
 */
35
 */
36
class Doc {
36
class Doc {
37
 public:
37
 public:
38
    // These fields potentially go into the document data record
38
    // These fields potentially go into the document data record
39
    string url;
39
    string url;
...
...
43
    string dmtime;       // Data reference date (same format). Ie: mail date
43
    string dmtime;       // Data reference date (same format). Ie: mail date
44
    string origcharset;
44
    string origcharset;
45
    string title;
45
    string title;
46
    string keywords;
46
    string keywords;
47
    string abstract;
47
    string abstract;
48
    string fbytes;        // File size
49
    string dbytes;        // Doc size
48
50
51
    // The following fields don't go to the db. text is only used when
52
    // indexing
49
    string text;
53
    string text;
50
54
51
    int pc; // used by sortseq, convenience
55
    int pc; // used by sortseq, convenience
52
56
53
    void erase() {
57
    void erase() {
...
...
58
    dmtime.erase();
62
    dmtime.erase();
59
    origcharset.erase();
63
    origcharset.erase();
60
    title.erase();
64
    title.erase();
61
    keywords.erase();
65
    keywords.erase();
62
    abstract.erase();
66
    abstract.erase();
67
  fbytes.erase();
68
  dbytes.erase();
63
69
64
    text.erase();
70
    text.erase();
65
    }
71
    }
66
};
72
};
67
73
...
...
77
    list<string> filetypes; // restrict to types. Empty if inactive
83
    list<string> filetypes; // restrict to types. Empty if inactive
78
    string topdir; // restrict to subtree. Empty if inactive
84
    string topdir; // restrict to subtree. Empty if inactive
79
    string description; // Printable expanded version of the complete query
85
    string description; // Printable expanded version of the complete query
80
                        // returned after setQuery.
86
                        // returned after setQuery.
81
    void erase() {
87
    void erase() {
82
  allwords.erase();phrase.erase();orwords.erase();nowords.erase();
88
  allwords.erase();
83
  filetypes.clear(); topdir.erase();
89
  phrase.erase();
90
  orwords.erase();
91
  nowords.erase();
92
  filetypes.clear(); 
93
  topdir.erase();
84
    description.clear();
94
    description.erase();
85
    }
95
    }
86
};
96
};
87
 
97
 
88
 class DbPops;
98
class DbPops;
89
99
90
/**
100
/**
91
 * Wrapper class for the native database.
101
 * Wrapper class for the native database.
92
 */
102
 */
93
class Db {
103
class Db {
94
public:
104
 public:
95
    Db();
105
    Db();
96
    ~Db();
106
    ~Db();
107
97
    enum OpenMode {DbRO, DbUpd, DbTrunc};
108
    enum OpenMode {DbRO, DbUpd, DbTrunc};
109
    enum QueryOpts {QO_NONE=0, QO_STEM = 1, QO_BUILD_ABSTRACT = 2,
110
          QO_REPLACE_ABSTRACT = 4};
111
98
    bool open(const string &dbdir, OpenMode mode);
112
    bool open(const string &dbdir, OpenMode mode, int qops = 0);
99
    bool close();
113
    bool close();
100
    bool isopen();
114
    bool isopen();
101
115
102
    // Update-related functions
116
    // Update-related functions
103
    bool add(const string &filename, const Doc &doc);
117
    bool add(const string &filename, const Doc &doc, const struct stat *stp);
104
    bool needUpdate(const string &filename, const struct stat *stp);
118
    bool needUpdate(const string &filename, const struct stat *stp);
105
    bool purge();
119
    bool purge();
106
    bool createStemDb(const string &lang);
120
    bool createStemDb(const string &lang);
107
    bool deleteStemDb(const string &lang);
121
    bool deleteStemDb(const string &lang);
108
122
109
    // Query-related functions
123
    // Query-related functions
110
124
111
    // Parse query string and initialize query
125
    // Parse query string and initialize query
112
    enum QueryOpts {QO_NONE=0, QO_STEM = 1};
113
    bool setQuery(const string &q, QueryOpts opts = QO_NONE, 
126
    bool setQuery(const string &q, QueryOpts opts = QO_NONE, 
114
          const string& stemlang = "english");
127
          const string& stemlang = "english");
115
    bool setQuery(AdvSearchData &q, QueryOpts opts = QO_NONE,
128
    bool setQuery(AdvSearchData &q, QueryOpts opts = QO_NONE,
116
          const string& stemlang = "english");
129
          const string& stemlang = "english");
117
    bool getQueryTerms(list<string>& terms);
130
    bool getQueryTerms(list<string>& terms);
...
...
141
    AdvSearchData asdata;
154
    AdvSearchData asdata;
142
    vector<int> dbindices; // In case there is a postq filter: sequence of 
155
    vector<int> dbindices; // In case there is a postq filter: sequence of 
143
                           // db indices that match
156
                           // db indices that match
144
    void *pdata; // Pointer to private data. We don't want db(ie
157
    void *pdata; // Pointer to private data. We don't want db(ie
145
                 // xapian)-specific defs to show in here
158
                 // xapian)-specific defs to show in here
159
    unsigned int m_qOpts;
160
146
    /* Copyconst and assignemt private and forbidden */
161
    /* Copyconst and assignemt private and forbidden */
147
    Db(const Db &) {}
162
    Db(const Db &) {}
148
    Db & operator=(const Db &) {return *this;};
163
    Db & operator=(const Db &) {return *this;};
149
    bool dbDataToRclDoc(std::string &data, Doc &doc);
150
};
164
};
151
165
152
// Unaccent and lowercase data.
166
// Unaccent and lowercase data.
153
extern bool dumb_string(const string &in, string &out);
167
extern bool dumb_string(const string &in, string &out);
154
168