Switch to unified view

a/src/query/wasatorcl.cpp b/src/query/wasatorcl.cpp
...
...
22
#include <list>
22
#include <list>
23
#include <algorithm>
23
#include <algorithm>
24
using std::string;
24
using std::string;
25
using std::list;
25
using std::list;
26
26
27
#include "rclconfig.h"
27
#include "wasastringtoquery.h"
28
#include "wasastringtoquery.h"
28
#include "rcldb.h"
29
#include "rcldb.h"
29
#include "searchdata.h"
30
#include "searchdata.h"
30
#include "wasatorcl.h"
31
#include "wasatorcl.h"
31
#include "debuglog.h"
32
#include "debuglog.h"
32
#include "smallut.h"
33
#include "smallut.h"
33
#include "rclconfig.h"
34
#include "rclconfig.h"
34
#include "refcntr.h"
35
#include "refcntr.h"
35
#include "textsplit.h"
36
#include "textsplit.h"
36
37
37
Rcl::SearchData *wasaStringToRcl(const string &qs, string &reason, 
38
Rcl::SearchData *wasaStringToRcl(RclConfig *config, 
39
               const string &qs, string &reason, 
38
                                 const string& autosuffs)
40
                                 const string& autosuffs)
39
{
41
{
40
    StringToWasaQuery parser;
42
    StringToWasaQuery parser;
41
    WasaQuery *wq = parser.stringToQuery(qs, reason);
43
    WasaQuery *wq = parser.stringToQuery(qs, reason);
42
    if (wq == 0) 
44
    if (wq == 0) 
43
    return 0;
45
    return 0;
44
    Rcl::SearchData *rq = wasaQueryToRcl(wq, autosuffs);
46
    Rcl::SearchData *rq = wasaQueryToRcl(config, wq, autosuffs);
45
    if (rq == 0) {
47
    if (rq == 0) {
46
    reason = "Failed translating xesam query structure to recoll";
48
    reason = "Failed translating xesam query structure to recoll";
47
    return 0;
49
    return 0;
48
    }
50
    }
49
    return rq;
51
    return rq;
50
}
52
}
51
53
52
Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa, const string& autosuffs)
54
Rcl::SearchData *wasaQueryToRcl(RclConfig *config,
55
              WasaQuery *wasa, const string& autosuffs)
53
{
56
{
54
    if (wasa == 0)
57
    if (wasa == 0)
55
    return 0;
58
    return 0;
56
    if (wasa->m_op != WasaQuery::OP_AND && wasa->m_op != WasaQuery::OP_OR) {
59
    if (wasa->m_op != WasaQuery::OP_AND && wasa->m_op != WasaQuery::OP_OR) {
57
    LOGERR(("wasaQueryToRcl: top query neither AND nor OR!\n"));
60
    LOGERR(("wasaQueryToRcl: top query neither AND nor OR!\n"));
...
...
89
92
90
        // Xesam uses "type", we also support "rclcat", for broad
93
        // Xesam uses "type", we also support "rclcat", for broad
91
        // categories like "audio", "presentation", etc.
94
        // categories like "audio", "presentation", etc.
92
        if (!stringicmp("rclcat", (*it)->m_fieldspec) ||
95
        if (!stringicmp("rclcat", (*it)->m_fieldspec) ||
93
        !stringicmp("type", (*it)->m_fieldspec)) {
96
        !stringicmp("type", (*it)->m_fieldspec)) {
94
      RclConfig *conf = RclConfig::getMainConfig();
95
        list<string> mtypes;
97
        list<string> mtypes;
96
        if (conf && conf->getMimeCatTypes((*it)->m_value, mtypes)) {
98
        if (config && config->getMimeCatTypes((*it)->m_value, mtypes)) {
97
            for (list<string>::iterator mit = mtypes.begin();
99
            for (list<string>::iterator mit = mtypes.begin();
98
             mit != mtypes.end(); mit++) {
100
             mit != mtypes.end(); mit++) {
99
            sdata->addFiletype(*mit);
101
            sdata->addFiletype(*mit);
100
            }
102
            }
101
        }
103
        }
...
...
190
192
191
    case WasaQuery::OP_OR:
193
    case WasaQuery::OP_OR:
192
        LOGDEB2(("wasaQueryToRcl: OR clause [%s]:[%s]\n", 
194
        LOGDEB2(("wasaQueryToRcl: OR clause [%s]:[%s]\n", 
193
             (*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
195
             (*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
194
        // Create a subquery.
196
        // Create a subquery.
195
        Rcl::SearchData *sub = wasaQueryToRcl(*it);
197
        Rcl::SearchData *sub = wasaQueryToRcl(config, *it);
196
        if (sub == 0) {
198
        if (sub == 0) {
197
        continue;
199
        continue;
198
        }
200
        }
199
        nclause = 
201
        nclause = 
200
        new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, 
202
        new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB,