Have the query parser directly return a shared_ptr and consequent simplifications
This commit is contained in:
+7
-10
@@ -161,10 +161,9 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
||||
std::unique_lock<std::mutex> locker(o_dblock);
|
||||
if (fs.isNotNull()) {
|
||||
// We build a search spec by adding a filtering layer to the base one.
|
||||
m_fsdata = std::shared_ptr<Rcl::SearchData>(
|
||||
new Rcl::SearchData(Rcl::SCLT_AND, m_sdata->getStemLang()));
|
||||
Rcl::SearchDataClauseSub *cl =
|
||||
new Rcl::SearchDataClauseSub(m_sdata);
|
||||
m_fsdata = std::make_shared<Rcl::SearchData>(
|
||||
Rcl::SCLT_AND, m_sdata->getStemLang());
|
||||
Rcl::SearchDataClauseSub *cl = new Rcl::SearchDataClauseSub(m_sdata);
|
||||
m_fsdata->addClause(cl);
|
||||
|
||||
for (unsigned int i = 0; i < fs.crits.size(); i++) {
|
||||
@@ -178,14 +177,12 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
|
||||
break;
|
||||
|
||||
string reason;
|
||||
Rcl::SearchData *sd =
|
||||
wasaStringToRcl(m_q->whatDb()->getConf(),
|
||||
m_sdata->getStemLang(),
|
||||
fs.values[i], reason);
|
||||
auto sd = wasaStringToRcl(m_q->whatDb()->getConf(),
|
||||
m_sdata->getStemLang(),
|
||||
fs.values[i], reason);
|
||||
if (sd) {
|
||||
Rcl::SearchDataClauseSub *cl1 =
|
||||
new Rcl::SearchDataClauseSub(
|
||||
std::shared_ptr<Rcl::SearchData>(sd));
|
||||
new Rcl::SearchDataClauseSub(sd);
|
||||
m_fsdata->addClause(cl1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,10 +371,10 @@ endopts:
|
||||
qs = uq;
|
||||
}
|
||||
|
||||
Rcl::SearchData *sd = 0;
|
||||
std::shared_ptr<Rcl::SearchData> sd;
|
||||
|
||||
if (op_flags & (OPT_a|OPT_o|OPT_f)) {
|
||||
sd = new Rcl::SearchData(Rcl::SCLT_OR, stemlang);
|
||||
sd = std::make_shared<Rcl::SearchData>(Rcl::SCLT_OR, stemlang);
|
||||
Rcl::SearchDataClause *clp = 0;
|
||||
if (op_flags & OPT_f) {
|
||||
clp = new Rcl::SearchDataClauseFilename(qs);
|
||||
|
||||
@@ -39,13 +39,12 @@ yy::parser::error (const location_type&, const std::string& m)
|
||||
}
|
||||
|
||||
|
||||
SearchData *wasaStringToRcl(const RclConfig *config,
|
||||
const std::string& stemlang,
|
||||
const std::string& query, string &reason,
|
||||
const std::string& autosuffs)
|
||||
std::shared_ptr<SearchData> wasaStringToRcl(
|
||||
const RclConfig *config, const std::string& stemlang,
|
||||
const std::string& query, string &reason, const std::string& autosuffs)
|
||||
{
|
||||
WasaParserDriver d(config, stemlang, autosuffs);
|
||||
SearchData *sd = d.parse(query);
|
||||
auto sd = std::shared_ptr<Rcl::SearchData>(d.parse(query));
|
||||
if (!sd)
|
||||
reason = d.getreason();
|
||||
return sd;
|
||||
|
||||
@@ -19,16 +19,16 @@
|
||||
#define _WASATORCL_H_INCLUDED_
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
namespace Rcl {
|
||||
class SearchData;
|
||||
}
|
||||
class RclConfig;
|
||||
|
||||
extern Rcl::SearchData *wasaStringToRcl(const RclConfig *,
|
||||
const std::string& stemlang,
|
||||
const std::string& query,
|
||||
std::string &reason,
|
||||
const std::string& autosuffs = "");
|
||||
extern std::shared_ptr<Rcl::SearchData>wasaStringToRcl(
|
||||
const RclConfig *, const std::string& stemlang,
|
||||
const std::string& query, std::string &reason,
|
||||
const std::string& autosuffs = "");
|
||||
|
||||
#endif /* _WASATORCL_H_INCLUDED_ */
|
||||
|
||||
Reference in New Issue
Block a user