~ubuntu-branches/ubuntu/trusty/recoll/trusty

« back to all changes in this revision

Viewing changes to query/wasatorcl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kartik Mistry
  • Date: 2008-11-13 21:18:15 UTC
  • mfrom: (1.1.7 upstream) (4.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20081113211815-2hxp996xj5hyjh08
Tags: 1.11.0-1
* New upstream release:
  + Remebers missing filters in first run (Closes: #500690)
* debian/control:
  + Added libimage-exiftool-perl as Suggests (Closes: #502427)
  + Added Python as recommaded due to filters/rclpython script
    although, its not necessary as it will be installed only
    when Python is present
* debian/patches:
  + Refreshed patch for gcc 4.4 FTBFS (Closes: #505376)
* debian/copyright:
  + Updated for newly added filter and image files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#ifndef lint
2
 
static char rcsid[] = "@(#$Id: wasatorcl.cpp,v 1.13 2008/01/16 11:14:38 dockes Exp $ (C) 2006 J.F.Dockes";
 
2
static char rcsid[] = "@(#$Id: wasatorcl.cpp,v 1.16 2008/10/07 06:52:57 dockes Exp $ (C) 2006 J.F.Dockes";
3
3
#endif
4
4
/*
5
5
 *   This program is free software; you can redistribute it and/or modify
29
29
#include "debuglog.h"
30
30
#include "smallut.h"
31
31
#include "rclconfig.h"
 
32
#include "refcntr.h"
32
33
 
33
34
Rcl::SearchData *wasaStringToRcl(const string &qs, string &reason)
34
35
{
56
57
    Rcl::SearchData *sdata = new 
57
58
        Rcl::SearchData(wasa->m_op == WasaQuery::OP_AND ? Rcl::SCLT_AND : 
58
59
                        Rcl::SCLT_OR);
 
60
    LOGDEB2(("wasaQueryToRcl: %s chain\n", wasa->m_op == WasaQuery::OP_AND ? 
 
61
             "AND" : "OR"));
59
62
 
60
63
    WasaQuery::subqlist_t::iterator it;
61
64
    Rcl::SearchDataClause *nclause;
67
70
        default:
68
71
            LOGINFO(("wasaQueryToRcl: found bad NULL or AND q type in list\n"));
69
72
            continue;
70
 
        case WasaQuery::OP_LEAF:
71
 
 
 
73
        case WasaQuery::OP_LEAF: {
 
74
            LOGDEB2(("wasaQueryToRcl: leaf clause [%s]:[%s]\n", 
 
75
                     (*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
 
76
            unsigned int mods = (unsigned int)(*it)->m_modifiers;
72
77
            // Special cases (mime, category, dir filter ...). Not pretty.
73
 
            if (!stringicmp("mime", (*it)->m_fieldspec)) {
 
78
            if (!stringicmp("mime", (*it)->m_fieldspec) ||
 
79
                !stringicmp("format", (*it)->m_fieldspec)
 
80
                ) {
74
81
                sdata->addFiletype((*it)->m_value);
75
82
                break;
76
83
            } 
95
102
            } 
96
103
 
97
104
            if ((*it)->m_value.find_first_of(" \t\n\r") != string::npos) {
98
 
                nclause = new Rcl::SearchDataClauseDist(Rcl::SCLT_PHRASE, 
99
 
                                                        (*it)->m_value, 0, 
 
105
                int slack = (mods & WasaQuery::WQM_PHRASESLACK) ? 10 : 0;
 
106
                Rcl::SClType tp = Rcl::SCLT_PHRASE;
 
107
                if (mods & WasaQuery::WQM_PROX) {
 
108
                    tp = Rcl::SCLT_NEAR;
 
109
                    slack = 10;
 
110
                }
 
111
                nclause = new Rcl::SearchDataClauseDist(tp, (*it)->m_value,
 
112
                                                        slack,
100
113
                                                        (*it)->m_fieldspec);
101
114
            } else {
102
115
                nclause = new Rcl::SearchDataClauseSimple(Rcl::SCLT_AND, 
112
125
                nclause->setModifiers(Rcl::SearchDataClause::SDCM_NOSTEMMING);
113
126
            }
114
127
            sdata->addClause(nclause);
 
128
        }
115
129
            break;
116
 
 
 
130
            
117
131
        case WasaQuery::OP_EXCL:
 
132
            LOGDEB2(("wasaQueryToRcl: excl clause [%s]:[%s]\n", 
 
133
                     (*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
118
134
            if (wasa->m_op != WasaQuery::OP_AND) {
119
135
                LOGERR(("wasaQueryToRcl: negative clause inside OR list!\n"));
120
136
                continue;
139
155
            break;
140
156
 
141
157
        case WasaQuery::OP_OR:
 
158
            LOGDEB2(("wasaQueryToRcl: OR clause [%s]:[%s]\n", 
 
159
                     (*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
142
160
            // Create a subquery.
143
161
            Rcl::SearchData *sub = wasaQueryToRcl(*it);
144
162
            if (sub == 0) {
145
163
                continue;
146
164
            }
147
 
            nclause = new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, sub);
 
165
            nclause = 
 
166
                new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, 
 
167
                                             RefCntr<Rcl::SearchData>(sub));
148
168
            if (nclause == 0) {
149
169
                LOGERR(("wasaQueryToRcl: out of memory\n"));
150
170
                return 0;