use a refcntr for the sub SearchData
This commit is contained in:
parent
34864f159a
commit
bf68c5ff2a
@ -1,5 +1,5 @@
|
||||
#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
|
||||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@ -29,6 +29,7 @@ using std::list;
|
||||
#include "debuglog.h"
|
||||
#include "smallut.h"
|
||||
#include "rclconfig.h"
|
||||
#include "refcntr.h"
|
||||
|
||||
Rcl::SearchData *wasaStringToRcl(const string &qs, string &reason)
|
||||
{
|
||||
@ -56,6 +57,8 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
||||
Rcl::SearchData *sdata = new
|
||||
Rcl::SearchData(wasa->m_op == WasaQuery::OP_AND ? Rcl::SCLT_AND :
|
||||
Rcl::SCLT_OR);
|
||||
LOGDEB2(("wasaQueryToRcl: %s chain\n", wasa->m_op == WasaQuery::OP_AND ?
|
||||
"AND" : "OR"));
|
||||
|
||||
WasaQuery::subqlist_t::iterator it;
|
||||
Rcl::SearchDataClause *nclause;
|
||||
@ -68,6 +71,8 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
||||
LOGINFO(("wasaQueryToRcl: found bad NULL or AND q type in list\n"));
|
||||
continue;
|
||||
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;
|
||||
// Special cases (mime, category, dir filter ...). Not pretty.
|
||||
if (!stringicmp("mime", (*it)->m_fieldspec) ||
|
||||
@ -123,6 +128,8 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
||||
break;
|
||||
|
||||
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) {
|
||||
LOGERR(("wasaQueryToRcl: negative clause inside OR list!\n"));
|
||||
continue;
|
||||
@ -147,12 +154,16 @@ Rcl::SearchData *wasaQueryToRcl(WasaQuery *wasa)
|
||||
break;
|
||||
|
||||
case WasaQuery::OP_OR:
|
||||
LOGDEB2(("wasaQueryToRcl: OR clause [%s]:[%s]\n",
|
||||
(*it)->m_fieldspec.c_str(), (*it)->m_value.c_str()));
|
||||
// Create a subquery.
|
||||
Rcl::SearchData *sub = wasaQueryToRcl(*it);
|
||||
if (sub == 0) {
|
||||
continue;
|
||||
}
|
||||
nclause = new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB, sub);
|
||||
nclause =
|
||||
new Rcl::SearchDataClauseSub(Rcl::SCLT_SUB,
|
||||
RefCntr<Rcl::SearchData>(sub));
|
||||
if (nclause == 0) {
|
||||
LOGERR(("wasaQueryToRcl: out of memory\n"));
|
||||
return 0;
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
*/
|
||||
#ifndef _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
|
||||
@ -29,6 +29,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "rcldb.h"
|
||||
#include "refcntr.h"
|
||||
|
||||
#ifndef NO_NAMESPACES
|
||||
using std::vector;
|
||||
@ -151,6 +152,11 @@ protected:
|
||||
SearchData *m_parentSearch;
|
||||
bool m_haveWildCards;
|
||||
Modifier m_modifiers;
|
||||
private:
|
||||
SearchDataClause(const SearchDataClause& r) {}
|
||||
SearchDataClause& operator=(const SearchDataClause& r) {
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -193,7 +199,18 @@ protected:
|
||||
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 {
|
||||
public:
|
||||
SearchDataClauseFilename(const string& txt)
|
||||
@ -225,13 +242,13 @@ public:
|
||||
class SearchDataClauseSub : public SearchDataClause {
|
||||
public:
|
||||
// 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) {}
|
||||
virtual ~SearchDataClauseSub() {delete m_sub; m_sub = 0;}
|
||||
virtual ~SearchDataClauseSub() {}
|
||||
virtual bool toNativeQuery(Rcl::Db &db, void *, const string& stemlang);
|
||||
|
||||
protected:
|
||||
SearchData *m_sub;
|
||||
RefCntr<SearchData> m_sub;
|
||||
};
|
||||
|
||||
} // Namespace Rcl
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user