use a refcntr for the sub SearchData
This commit is contained in:
parent
34864f159a
commit
bf68c5ff2a
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: wasatorcl.cpp,v 1.14 2008-08-26 13:47:21 dockes Exp $ (C) 2006 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: wasatorcl.cpp,v 1.15 2008-08-28 15:43:57 dockes Exp $ (C) 2006 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
/*
|
/*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -29,6 +29,7 @@ using std::list;
|
|||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
#include "smallut.h"
|
#include "smallut.h"
|
||||||
#include "rclconfig.h"
|
#include "rclconfig.h"
|
||||||
|
#include "refcntr.h"
|
||||||
|
|
||||||
Rcl::SearchData *wasaStringToRcl(const string &qs, string &reason)
|
Rcl::SearchData *wasaStringToRcl(const string &qs, string &reason)
|
||||||
{
|
{
|
||||||
@ -56,6 +57,8 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
|||||||
Rcl::SearchData *sdata = new
|
Rcl::SearchData *sdata = new
|
||||||
Rcl::SearchData(wasa->m_op == WasaQuery::OP_AND ? Rcl::SCLT_AND :
|
Rcl::SearchData(wasa->m_op == WasaQuery::OP_AND ? Rcl::SCLT_AND :
|
||||||
Rcl::SCLT_OR);
|
Rcl::SCLT_OR);
|
||||||
|
LOGDEB2(("wasaQueryToRcl: %s chain\n", wasa->m_op == WasaQuery::OP_AND ?
|
||||||
|
"AND" : "OR"));
|
||||||
|
|
||||||
WasaQuery::subqlist_t::iterator it;
|
WasaQuery::subqlist_t::iterator it;
|
||||||
Rcl::SearchDataClause *nclause;
|
Rcl::SearchDataClause *nclause;
|
||||||
@ -68,6 +71,8 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
|||||||
LOGINFO(("wasaQueryToRcl: found bad NULL or AND q type in list\n"));
|
LOGINFO(("wasaQueryToRcl: found bad NULL or AND q type in list\n"));
|
||||||
continue;
|
continue;
|
||||||
case WasaQuery::OP_LEAF:
|
case WasaQuery::OP_LEAF:
|
||||||
|
LOGDEB2(("wasaQueryToRcl: leaf clause [%s]:[%s]\n",
|
||||||
|
(*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
|
||||||
unsigned int mods = (unsigned int)(*it)->m_modifiers;
|
unsigned int mods = (unsigned int)(*it)->m_modifiers;
|
||||||
// Special cases (mime, category, dir filter ...). Not pretty.
|
// Special cases (mime, category, dir filter ...). Not pretty.
|
||||||
if (!stringicmp("mime", (*it)->m_fieldspec) ||
|
if (!stringicmp("mime", (*it)->m_fieldspec) ||
|
||||||
@ -123,6 +128,8 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WasaQuery::OP_EXCL:
|
case WasaQuery::OP_EXCL:
|
||||||
|
LOGDEB2(("wasaQueryToRcl: excl clause [%s]:[%s]\n",
|
||||||
|
(*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
|
||||||
if (wasa->m_op != WasaQuery::OP_AND) {
|
if (wasa->m_op != WasaQuery::OP_AND) {
|
||||||
LOGERR(("wasaQueryToRcl: negative clause inside OR list!\n"));
|
LOGERR(("wasaQueryToRcl: negative clause inside OR list!\n"));
|
||||||
continue;
|
continue;
|
||||||
@ -147,12 +154,16 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WasaQuery::OP_OR:
|
case WasaQuery::OP_OR:
|
||||||
|
LOGDEB2(("wasaQueryToRcl: OR clause [%s]:[%s]\n",
|
||||||
|
(*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
|
||||||
// Create a subquery.
|
// Create a subquery.
|
||||||
Rcl::SearchData *sub = wasaQueryToRcl(*it);
|
Rcl::SearchData *sub = wasaQueryToRcl(*it);
|
||||||
if (sub == 0) {
|
if (sub == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nclause = new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, sub);
|
nclause =
|
||||||
|
new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB,
|
||||||
|
RefCntr<Rcl::SearchData>(sub));
|
||||||
if (nclause == 0) {
|
if (nclause == 0) {
|
||||||
LOGERR(("wasaQueryToRcl: out of memory\n"));
|
LOGERR(("wasaQueryToRcl: out of memory\n"));
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef _SEARCHDATA_H_INCLUDED_
|
#ifndef _SEARCHDATA_H_INCLUDED_
|
||||||
#define _SEARCHDATA_H_INCLUDED_
|
#define _SEARCHDATA_H_INCLUDED_
|
||||||
/* @(#$Id: searchdata.h,v 1.15 2008-07-01 11:51:51 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: searchdata.h,v 1.16 2008-08-28 15:43:57 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Structures to hold data coming almost directly from the gui
|
* Structures to hold data coming almost directly from the gui
|
||||||
@ -29,6 +29,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "rcldb.h"
|
#include "rcldb.h"
|
||||||
|
#include "refcntr.h"
|
||||||
|
|
||||||
#ifndef NO_NAMESPACES
|
#ifndef NO_NAMESPACES
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@ -151,6 +152,11 @@ protected:
|
|||||||
SearchData *m_parentSearch;
|
SearchData *m_parentSearch;
|
||||||
bool m_haveWildCards;
|
bool m_haveWildCards;
|
||||||
Modifier m_modifiers;
|
Modifier m_modifiers;
|
||||||
|
private:
|
||||||
|
SearchDataClause(const SearchDataClause& r) {}
|
||||||
|
SearchDataClause& operator=(const SearchDataClause& r) {
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,7 +199,18 @@ protected:
|
|||||||
int m_slack;
|
int m_slack;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Filename search clause. */
|
/** Filename search clause. This is special because term expansion is only
|
||||||
|
* performed against the XSFN terms (it's performed against the main index
|
||||||
|
* for all other fields). Else we could just use a "filename:" field
|
||||||
|
* This doesn't really make sense (either). I think we could either expand
|
||||||
|
* filenames against all terms and then select the XSFN ones, or always perform
|
||||||
|
* expansion only against the field's terms ? Anyway this doesn't hurt
|
||||||
|
* much either.
|
||||||
|
*
|
||||||
|
* There is a big advantage though in expanding only against the
|
||||||
|
* field, especially for file names, because this makes searches for
|
||||||
|
* "*xx" much faster (no need to scan the whole main index).
|
||||||
|
*/
|
||||||
class SearchDataClauseFilename : public SearchDataClauseSimple {
|
class SearchDataClauseFilename : public SearchDataClauseSimple {
|
||||||
public:
|
public:
|
||||||
SearchDataClauseFilename(const string& txt)
|
SearchDataClauseFilename(const string& txt)
|
||||||
@ -225,13 +242,13 @@ public:
|
|||||||
class SearchDataClauseSub : public SearchDataClause {
|
class SearchDataClauseSub : public SearchDataClause {
|
||||||
public:
|
public:
|
||||||
// We take charge of the SearchData * and will delete it.
|
// We take charge of the SearchData * and will delete it.
|
||||||
SearchDataClauseSub(SClType tp, SearchData *sub)
|
SearchDataClauseSub(SClType tp, RefCntr<SearchData> sub)
|
||||||
: SearchDataClause(tp), m_sub(sub) {}
|
: SearchDataClause(tp), m_sub(sub) {}
|
||||||
virtual ~SearchDataClauseSub() {delete m_sub; m_sub = 0;}
|
virtual ~SearchDataClauseSub() {}
|
||||||
virtual bool toNativeQuery(Rcl::Db &db, void *, const string& stemlang);
|
virtual bool toNativeQuery(Rcl::Db &db, void *, const string& stemlang);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SearchData *m_sub;
|
RefCntr<SearchData> m_sub;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace Rcl
|
} // Namespace Rcl
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user