Use std[::tr1]::shared_ptr instead of local RefCntr by default

This commit is contained in:
Jean-Francois Dockes 2015-08-09 13:54:24 +02:00
parent 143b3e92b6
commit b71c399fe7
61 changed files with 313 additions and 288 deletions

View file

@ -16,9 +16,11 @@
*/
#ifndef TEST_SUBTREELIST
#include "autoconfig.h"
#include MEMORY_INCLUDE
#include "cstr.h"
#include "refcntr.h"
#include "rcldb.h"
#include "searchdata.h"
#include "rclquery.h"
@ -37,7 +39,7 @@ bool subtreelist(RclConfig *config, const string& top,
}
Rcl::SearchData *sd = new Rcl::SearchData(Rcl::SCLT_OR, cstr_null);
RefCntr<Rcl::SearchData> rq(sd);
STD_SHARED_PTR<Rcl::SearchData> rq(sd);
sd->addClause(new Rcl::SearchDataClausePath(top, false));

View file

@ -287,7 +287,7 @@ void FileInterner::init(const string &data, RclConfig *cnf,
result = df->set_document_data(m_mimetype, data.c_str(), data.length());
} else if (df->is_data_input_ok(Dijon::Filter::DOCUMENT_FILE_NAME)) {
TempFile temp = dataToTempFile(data, m_mimetype);
if (temp.isNotNull() &&
if (temp &&
(result = df->set_document_file(m_mimetype, temp->filename()))) {
m_tmpflgs[m_handlers.size()] = true;
m_tempfiles.push_back(temp);
@ -701,7 +701,7 @@ int FileInterner::addHandler()
setres = newflt->set_document_data(mimetype,txt->c_str(),txt->length());
} else if (newflt->is_data_input_ok(Dijon::Filter::DOCUMENT_FILE_NAME)) {
TempFile temp = dataToTempFile(*txt, mimetype);
if (temp.isNotNull() &&
if (temp &&
(setres = newflt->set_document_file(mimetype, temp->filename()))) {
m_tmpflgs[m_handlers.size()] = true;
m_tempfiles.push_back(temp);
@ -743,7 +743,7 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, const string& ipath
LOGDEB(("FileInterner::internfile. ipath [%s]\n", ipath.c_str()));
// Get rid of possible image tempfile from older call
m_imgtmp.release();
m_imgtmp.reset();
if (m_handlers.size() < 1) {
// Just means the constructor failed

View file

@ -332,8 +332,8 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
return false;
}
RefCntr<Rcl::SearchData> sdata(sd);
RefCntr<Rcl::Query>query(new Rcl::Query(m_rcldb));
STD_SHARED_PTR<Rcl::SearchData> sdata(sd);
STD_SHARED_PTR<Rcl::Query>query(new Rcl::Query(m_rcldb));
query->setCollapseDuplicates(prefs.collapseDuplicates);
if (!query->setQuery(sdata)) {
m_reason = "Query execute failed. Invalid query or syntax error?";
@ -342,12 +342,12 @@ bool RecollProtocol::doSearch(const QueryDesc& qd)
}
DocSequenceDb *src =
new DocSequenceDb(RefCntr<Rcl::Query>(query), "Query results", sdata);
new DocSequenceDb(STD_SHARED_PTR<Rcl::Query>(query), "Query results", sdata);
if (src == 0) {
error(KIO::ERR_SLAVE_DEFINED, "Can't build result sequence");
return false;
}
m_source = RefCntr<DocSequence>(src);
m_source = STD_SHARED_PTR<DocSequence>(src);
// Reset pager in all cases. Costs nothing, stays at page -1 initially
// htmldosearch will fetch the first page if needed.
m_pager.setDocSource(m_source);

View file

@ -32,7 +32,7 @@ using std::string;
#include "rcldb.h"
#include "reslistpager.h"
#include "docseq.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
class RecollProtocol;
@ -181,7 +181,7 @@ class RecollProtocol : public KIO::SlaveBase {
// (one slave several konqueror windows) would be to have a small
// cache of recent searches kept open.
RecollKioPager m_pager;
RefCntr<DocSequence> m_source;
STD_SHARED_PTR<DocSequence> m_source;
// Note: page here is not used, current page always comes from m_pager.
QueryDesc m_query;
};

View file

@ -131,7 +131,7 @@ PHP_METHOD(Query, query)
RETURN_BOOL(false);
}
RefCntr<Rcl::SearchData> rq(sd);
STD_SHARED_PTR<Rcl::SearchData> rq(sd);
Rcl::Query *pRclQuery = new Rcl::Query(pRclDb);
pRclQuery->setQuery(rq);

View file

@ -55,15 +55,15 @@ static RclConfig *rclconfig;
typedef struct {
PyObject_HEAD
/* Type-specific fields go here. */
RefCntr<Rcl::SearchData> sd;
STD_SHARED_PTR<Rcl::SearchData> sd;
} recoll_SearchDataObject;
static void
SearchData_dealloc(recoll_SearchDataObject *self)
{
LOGDEB(("SearchData_dealloc. Releasing. Count before: %d\n",
self->sd.getcnt()));
self->sd.release();
self->sd.use_count()));
self->sd.reset();
Py_TYPE(self)->tp_free((PyObject*)self);
}
@ -108,7 +108,7 @@ SearchData_init(recoll_SearchDataObject *self, PyObject *args, PyObject *kwargs)
} else {
stemlang = "english";
}
self->sd = RefCntr<Rcl::SearchData>(new Rcl::SearchData(tp, stemlang));
self->sd = STD_SHARED_PTR<Rcl::SearchData>(new Rcl::SearchData(tp, stemlang));
return 0;
}
@ -180,7 +180,7 @@ SearchData_addclause(recoll_SearchDataObject* self, PyObject *args,
PyObject *kwargs)
{
LOGDEB0(("SearchData_addclause\n"));
if (self->sd.isNull()) {
if (!self->sd) {
LOGERR(("SearchData_addclause: not init??\n"));
PyErr_SetString(PyExc_AttributeError, "sd");
return 0;
@ -951,7 +951,7 @@ Query_execute(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
return 0;
}
RefCntr<Rcl::SearchData> rq(sd);
STD_SHARED_PTR<Rcl::SearchData> rq(sd);
self->query->setSortBy(*self->sortfield, self->ascending);
self->query->setQuery(rq);
int cnt = self->query->getResCnt();
@ -1222,8 +1222,8 @@ Query_highlight(recoll_QueryObject* self, PyObject *args, PyObject *kwargs)
return 0;
}
RefCntr<Rcl::SearchData> sd = self->query->getSD();
if (sd.isNull()) {
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
if (!sd) {
PyErr_SetString(PyExc_ValueError, "Query not initialized");
return 0;
}
@ -1273,8 +1273,8 @@ Query_makedocabstract(recoll_QueryObject* self, PyObject *args,PyObject *kwargs)
PyErr_SetString(PyExc_AttributeError, "query");
return 0;
}
RefCntr<Rcl::SearchData> sd = self->query->getSD();
if (sd.isNull()) {
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
if (!sd) {
PyErr_SetString(PyExc_ValueError, "Query not initialized");
return 0;
}
@ -1329,8 +1329,8 @@ Query_getxquery(recoll_QueryObject* self, PyObject *, PyObject *)
PyErr_SetString(PyExc_AttributeError, "query");
return 0;
}
RefCntr<Rcl::SearchData> sd = self->query->getSD();
if (sd.isNull()) {
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
if (!sd) {
PyErr_SetString(PyExc_ValueError, "Query not initialized");
return 0;
}
@ -1357,8 +1357,8 @@ Query_getgroups(recoll_QueryObject* self, PyObject *, PyObject *)
PyErr_SetString(PyExc_AttributeError, "query");
return 0;
}
RefCntr<Rcl::SearchData> sd = self->query->getSD();
if (sd.isNull()) {
STD_SHARED_PTR<Rcl::SearchData> sd = self->query->getSD();
if (!sd) {
PyErr_SetString(PyExc_ValueError, "Query not initialized");
return 0;
}

View file

@ -364,7 +364,7 @@ using namespace Rcl;
void AdvSearch::runSearch()
{
string stemLang = prefs.stemlang();
RefCntr<SearchData> sdata(new SearchData(conjunctCMB->currentIndex() == 0 ?
STD_SHARED_PTR<SearchData> sdata(new SearchData(conjunctCMB->currentIndex() == 0 ?
SCLT_AND : SCLT_OR, stemLang));
bool hasclause = false;
@ -455,7 +455,7 @@ void AdvSearch::runSearch()
// Set up fields from existing search data, which must be compatible
// with what we can do...
void AdvSearch::fromSearch(RefCntr<SearchData> sdata)
void AdvSearch::fromSearch(STD_SHARED_PTR<SearchData> sdata)
{
if (sdata->m_tp == SCLT_OR)
conjunctCMB->setCurrentIndex(1);
@ -553,8 +553,8 @@ void AdvSearch::slotHistoryNext()
{
if (g_advshistory == 0)
return;
RefCntr<Rcl::SearchData> sd = g_advshistory->getnewer();
if (sd.isNull())
STD_SHARED_PTR<Rcl::SearchData> sd = g_advshistory->getnewer();
if (!sd)
return;
fromSearch(sd);
}
@ -563,8 +563,8 @@ void AdvSearch::slotHistoryPrev()
{
if (g_advshistory == 0)
return;
RefCntr<Rcl::SearchData> sd = g_advshistory->getolder();
if (sd.isNull())
STD_SHARED_PTR<Rcl::SearchData> sd = g_advshistory->getolder();
if (!sd)
return;
fromSearch(sd);
}

View file

@ -24,7 +24,7 @@
#include "searchclause_w.h"
#include "recoll.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "searchdata.h"
#include "advshist.h"
@ -56,7 +56,7 @@ public slots:
virtual void restrictFtCB_toggled(bool);
virtual void restrictCtCB_toggled(bool);
virtual void runSearch();
virtual void fromSearch(RefCntr<Rcl::SearchData> sdata);
virtual void fromSearch(STD_SHARED_PTR<Rcl::SearchData> sdata);
virtual void browsePB_clicked();
virtual void saveFileTypes();
virtual void delClause();
@ -67,7 +67,7 @@ public slots:
virtual void slotHistoryPrev();
signals:
void startSearch(RefCntr<Rcl::SearchData>, bool);
void startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool);
private:
virtual void init();

View file

@ -33,38 +33,38 @@ AdvSearchHist::AdvSearchHist()
AdvSearchHist::~AdvSearchHist()
{
for (vector<RefCntr<SearchData> >::iterator it = m_entries.begin();
for (vector<STD_SHARED_PTR<SearchData> >::iterator it = m_entries.begin();
it != m_entries.end(); it++) {
it->release();
it->reset();
}
}
RefCntr<Rcl::SearchData> AdvSearchHist::getnewest()
STD_SHARED_PTR<Rcl::SearchData> AdvSearchHist::getnewest()
{
if (m_entries.empty())
return RefCntr<Rcl::SearchData>();
return STD_SHARED_PTR<Rcl::SearchData>();
return m_entries[0];
}
RefCntr<Rcl::SearchData> AdvSearchHist::getolder()
STD_SHARED_PTR<Rcl::SearchData> AdvSearchHist::getolder()
{
m_current++;
if (m_current >= int(m_entries.size())) {
m_current--;
return RefCntr<Rcl::SearchData>();
return STD_SHARED_PTR<Rcl::SearchData>();
}
return m_entries[m_current];
}
RefCntr<Rcl::SearchData> AdvSearchHist::getnewer()
STD_SHARED_PTR<Rcl::SearchData> AdvSearchHist::getnewer()
{
if (m_current == -1 || m_current == 0 || m_entries.empty())
return RefCntr<Rcl::SearchData>();
return STD_SHARED_PTR<Rcl::SearchData>();
return m_entries[--m_current];
}
bool AdvSearchHist::push(RefCntr<SearchData> sd)
bool AdvSearchHist::push(STD_SHARED_PTR<SearchData> sd)
{
m_entries.insert(m_entries.begin(), sd);
if (m_current != -1)
@ -83,7 +83,7 @@ bool AdvSearchHist::read()
for (list<string>::const_iterator it = lxml.begin(); it != lxml.end();
it++) {
RefCntr<SearchData> sd = xmlToSearchData(*it);
STD_SHARED_PTR<SearchData> sd = xmlToSearchData(*it);
if (sd)
m_entries.push_back(sd);
}

View file

@ -20,7 +20,7 @@
#include <vector>
#include "recoll.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "searchdata.h"
/** Advanced search history.
@ -43,14 +43,14 @@ public:
~AdvSearchHist();
// Add entry
bool push(RefCntr<Rcl::SearchData>);
bool push(STD_SHARED_PTR<Rcl::SearchData>);
// Get latest. does not change state
RefCntr<Rcl::SearchData> getnewest();
STD_SHARED_PTR<Rcl::SearchData> getnewest();
// Cursor
RefCntr<Rcl::SearchData> getolder();
RefCntr<Rcl::SearchData> getnewer();
STD_SHARED_PTR<Rcl::SearchData> getolder();
STD_SHARED_PTR<Rcl::SearchData> getnewer();
void clear();
@ -58,7 +58,7 @@ private:
bool read();
int m_current;
std::vector<RefCntr<Rcl::SearchData> > m_entries;
std::vector<STD_SHARED_PTR<Rcl::SearchData> > m_entries;
};
#endif // _ADVSHIST_H_INCLUDED_

View file

@ -36,6 +36,8 @@
* destroyed and recreated as a copy if Cancel is pressed (you have to
* delete/recreate the widgets in this case as the links are no longer valid).
*/
#include "autoconfig.h"
#include <string>
#include <limits.h>
@ -43,9 +45,7 @@
#include <qstring.h>
#include <qwidget.h>
#include "refcntr.h"
using std::string;
#include MEMORY_INCLUDE
class QHBoxLayout;
class QLineEdit;
@ -61,21 +61,21 @@ namespace confgui {
class ConfLinkRep {
public:
virtual ~ConfLinkRep() {}
virtual bool set(const string& val) = 0;
virtual bool get(string& val) = 0;
virtual bool set(const std::string& val) = 0;
virtual bool get(std::string& val) = 0;
};
typedef RefCntr<ConfLinkRep> ConfLink;
typedef STD_SHARED_PTR<ConfLinkRep> ConfLink;
// Useful to store/manage data which has no direct representation in
// the config, ie list of subkey directories
class ConfLinkNullRep : public ConfLinkRep {
public:
virtual ~ConfLinkNullRep() {}
virtual bool set(const string&)
virtual bool set(const std::string&)
{
return true;
}
virtual bool get(string& val) {val = ""; return true;}
virtual bool get(std::string& val) {val = ""; return true;}
};
// A widget to let the user change one configuration

View file

@ -70,8 +70,8 @@ void forgetTempFile(string &fn)
PTMutexLocker locker(thetempfileslock);
for (vector<TempFile>::iterator it = o_tempfiles.begin();
it != o_tempfiles.end(); it++) {
if ((*it).isNotNull() && !fn.compare((*it)->filename())) {
it->release();
if ((*it) && !fn.compare((*it)->filename())) {
it->reset();
}
}
fn.erase();

View file

@ -1028,13 +1028,13 @@ bool Preview::loadDocInCurrentTab(const Rcl::Doc &idoc, int docnum)
theconfig->setKeyDir(path_getfather(fn));
if (fn.empty() || !idoc.ipath.empty()) {
TempFile temp = lthr.imgtmp;
if (temp.isNotNull()) {
if (temp) {
LOGDEB1(("Preview: load: got temp file from internfile\n"));
} else if (!FileInterner::idocToFile(temp, string(),
theconfig, idoc)) {
temp.release(); // just in case.
temp.reset(); // just in case.
}
if (temp.isNotNull()) {
if (temp) {
rememberTempFile(temp);
fn = temp->filename();
editor->m_tmpfilename = fn;

View file

@ -16,6 +16,7 @@
*/
#ifndef _PREVIEW_W_H_INCLUDED_
#define _PREVIEW_W_H_INCLUDED_
#include "autoconfig.h"
// Always use a qtextbrowser for now, there is no compelling reason to
// switch to webkit here
@ -25,6 +26,8 @@
#include <stdio.h>
#include MEMORY_INCLUDE
#include <QComboBox>
#include <qvariant.h>
#include <qwidget.h>
@ -39,7 +42,6 @@
#include <qimage.h>
#include "rcldb.h"
#include "refcntr.h"
#include "plaintorich.h"
#include "rclmain_w.h"

View file

@ -231,7 +231,7 @@ void RclMain::previewPrevOrNextInTab(Preview * w, int sid, int docnum, bool nxt)
docnum++;
else
docnum--;
if (docnum < 0 || m_source.isNull() || docnum >= m_source->getResCnt()) {
if (docnum < 0 || !m_source || docnum >= m_source->getResCnt()) {
QApplication::beep();
return;
}

View file

@ -59,7 +59,7 @@ void RclMain::saveLastQuery()
xml = sSearch->asXML();
} else {
if (g_advshistory) {
RefCntr<Rcl::SearchData> sd;
STD_SHARED_PTR<Rcl::SearchData> sd;
sd = g_advshistory->getnewest();
if (sd) {
xml = sd->asXML();
@ -118,7 +118,7 @@ void RclMain::loadSavedQuery()
}
// Try to parse as SearchData
RefCntr<SearchData> sd = xmlToSearchData(xml);
STD_SHARED_PTR<SearchData> sd = xmlToSearchData(xml);
if (sd) {
showAdvSearchDialog();
asearchform->fromSearch(sd);

View file

@ -64,9 +64,9 @@ void RclMain::viewUrl()
// StartNativeViewer needs a db source to call getEnclosing() on.
Rcl::Query *query = new Rcl::Query(rcldb);
DocSequenceDb *src =
new DocSequenceDb(RefCntr<Rcl::Query>(query), "",
RefCntr<Rcl::SearchData>(new Rcl::SearchData));
m_source = RefCntr<DocSequence>(src);
new DocSequenceDb(STD_SHARED_PTR<Rcl::Query>(query), "",
STD_SHARED_PTR<Rcl::SearchData>(new Rcl::SearchData));
m_source = STD_SHARED_PTR<DocSequence>(src);
// Start a native viewer if the mimetype has one defined, else a
@ -269,7 +269,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
// We want the path for the parent document. For example to
// open the chm file, not the internal page. Note that we just
// override the other file name in this case.
if (m_source.isNull() || !m_source->getEnclosing(doc, pdoc)) {
if (!m_source || !m_source->getEnclosing(doc, pdoc)) {
QMessageBox::warning(0, "Recoll",
tr("Cannot find parent document"));
return;
@ -330,7 +330,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
return;
}
}
if (!temp.isNull()) {
if (temp) {
rememberTempFile(temp);
fn = temp->filename();
url = string("file://") + fn;
@ -342,7 +342,7 @@ void RclMain::startNativeViewer(Rcl::Doc doc, int pagenum, QString term)
if (pagenum == -1) {
pagenum = 1;
string lterm;
if (m_source.isNotNull())
if (m_source)
pagenum = m_source->getFirstMatchPage(doc, lterm);
if (pagenum == -1)
pagenum = 1;

View file

@ -47,8 +47,8 @@ void RclMain::showAdvSearchDialog()
this, SLOT (fileExit()));
connect(asearchform,
SIGNAL(startSearch(RefCntr<Rcl::SearchData>, bool)),
this, SLOT(startSearch(RefCntr<Rcl::SearchData>, bool)));
SIGNAL(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)),
this, SLOT(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)));
asearchform->show();
} else {
// Close and reopen, in hope that makes us visible...

View file

@ -52,7 +52,7 @@
#include "uiprefs_w.h"
#include "guiutils.h"
#include "reslist.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "ssearch_w.h"
#include "internfile.h"
#include "docseqdb.h"
@ -285,8 +285,8 @@ void RclMain::init()
connect(&m_watcher, SIGNAL(fileChanged(QString)),
this, SLOT(idxStatus()));
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>, bool)),
this, SLOT(startSearch(RefCntr<Rcl::SearchData>, bool)));
connect(sSearch, SIGNAL(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)),
this, SLOT(startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool)));
connect(sSearch, SIGNAL(clearSearch()),
this, SLOT(resetSearch()));
@ -344,8 +344,8 @@ void RclMain::init()
restable->setRclMain(this, true);
connect(actionSaveResultsAsCSV, SIGNAL(triggered()),
restable, SLOT(saveAsCSV()));
connect(this, SIGNAL(docSourceChanged(RefCntr<DocSequence>)),
restable, SLOT(setDocSource(RefCntr<DocSequence>)));
connect(this, SIGNAL(docSourceChanged(STD_SHARED_PTR<DocSequence>)),
restable, SLOT(setDocSource(STD_SHARED_PTR<DocSequence>)));
connect(this, SIGNAL(searchReset()),
restable, SLOT(resetSource()));
connect(this, SIGNAL(resultsReady()),
@ -374,8 +374,8 @@ void RclMain::init()
this, SLOT(showSnippets(Rcl::Doc)));
reslist->setRclMain(this, true);
connect(this, SIGNAL(docSourceChanged(RefCntr<DocSequence>)),
reslist, SLOT(setDocSource(RefCntr<DocSequence>)));
connect(this, SIGNAL(docSourceChanged(STD_SHARED_PTR<DocSequence>)),
reslist, SLOT(setDocSource(STD_SHARED_PTR<DocSequence>)));
connect(firstPageAction, SIGNAL(triggered()),
reslist, SLOT(resultPageFirst()));
connect(prevPageAction, SIGNAL(triggered()),
@ -636,7 +636,7 @@ void RclMain::fileExit()
}
// Start a db query and set the reslist docsource
void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple)
void RclMain::startSearch(STD_SHARED_PTR<Rcl::SearchData> sdata, bool issimple)
{
LOGDEB(("RclMain::startSearch. Indexing %s Active %d\n",
m_idxproc?"on":"off", m_queryActive));
@ -646,7 +646,7 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple)
}
m_queryActive = true;
restable->setEnabled(false);
m_source = RefCntr<DocSequence>();
m_source = STD_SHARED_PTR<DocSequence>();
m_searchIsSimple = issimple;
@ -665,11 +665,11 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple)
curPreview = 0;
DocSequenceDb *src =
new DocSequenceDb(RefCntr<Rcl::Query>(query),
new DocSequenceDb(STD_SHARED_PTR<Rcl::Query>(query),
string(tr("Query results").toUtf8()), sdata);
src->setAbstractParams(prefs.queryBuildAbstract,
prefs.queryReplaceAbstract);
m_source = RefCntr<DocSequence>(src);
m_source = STD_SHARED_PTR<DocSequence>(src);
m_source->setSortSpec(m_sortspec);
m_source->setFiltSpec(m_filtspec);
@ -680,9 +680,9 @@ void RclMain::startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple)
class QueryThread : public QThread {
int loglevel;
RefCntr<DocSequence> m_source;
STD_SHARED_PTR<DocSequence> m_source;
public:
QueryThread(RefCntr<DocSequence> source)
QueryThread(STD_SHARED_PTR<DocSequence> source)
: m_source(source)
{
loglevel = DebugLog::getdbl()->getlevel();
@ -698,7 +698,7 @@ class QueryThread : public QThread {
void RclMain::initiateQuery()
{
if (m_source.isNull())
if (!m_source)
return;
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
@ -778,7 +778,7 @@ void RclMain::onSortCtlChanged()
prefs.sortActive = prefs.sortDesc = false;
prefs.sortField = "";
}
if (m_source.isNotNull())
if (m_source)
m_source->setSortSpec(m_sortspec);
emit sortDataChanged(m_sortspec);
initiateQuery();
@ -796,7 +796,7 @@ void RclMain::onSortDataChanged(DocSeqSortSpec spec)
actionSortByDateAsc->setChecked(!spec.desc);
}
m_sortspecnochange = false;
if (m_source.isNotNull())
if (m_source)
m_source->setSortSpec(spec);
m_sortspec = spec;
@ -896,8 +896,8 @@ void RclMain::showSubDocs(Rcl::Doc doc)
new DocSequenceDocs(rcldb, docs,
qs2utf8s(tr("Sub-documents and attachments")));
src->setDescription(qs2utf8s(tr("Sub-documents and attachments")));
RefCntr<DocSequence>
source(new DocSource(theconfig, RefCntr<DocSequence>(src)));
STD_SHARED_PTR<DocSequence>
source(new DocSource(theconfig, STD_SHARED_PTR<DocSequence>(src)));
ResTable *res = new ResTable();
res->setRclMain(this, false);
@ -938,7 +938,7 @@ void RclMain::showDocHistory()
{
LOGDEB(("RclMain::showDocHistory\n"));
emit searchReset();
m_source = RefCntr<DocSequence>();
m_source = STD_SHARED_PTR<DocSequence>();
curPreview = 0;
string reason;
@ -947,8 +947,8 @@ void RclMain::showDocHistory()
return;
}
// Construct a bogus SearchData structure
RefCntr<Rcl::SearchData>searchdata =
RefCntr<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND, cstr_null));
STD_SHARED_PTR<Rcl::SearchData>searchdata =
STD_SHARED_PTR<Rcl::SearchData>(new Rcl::SearchData(Rcl::SCLT_AND, cstr_null));
searchdata->setDescription((const char *)tr("History data").toUtf8());
@ -957,8 +957,8 @@ void RclMain::showDocHistory()
new DocSequenceHistory(rcldb, g_dynconf,
string(tr("Document history").toUtf8()));
src->setDescription((const char *)tr("History data").toUtf8());
DocSource *source = new DocSource(theconfig, RefCntr<DocSequence>(src));
m_source = RefCntr<DocSequence>(source);
DocSource *source = new DocSource(theconfig, STD_SHARED_PTR<DocSequence>(src));
m_source = STD_SHARED_PTR<DocSequence>(source);
m_source->setSortSpec(m_sortspec);
m_source->setFiltSpec(m_filtspec);
emit docSourceChanged(m_source);
@ -1013,7 +1013,7 @@ void RclMain::enablePrevPage(bool yesno)
QString RclMain::getQueryDescription()
{
if (m_source.isNull())
if (!m_source)
return "";
return QString::fromUtf8(m_source->getDescription().c_str());
}
@ -1073,7 +1073,7 @@ void RclMain::setFiltSpec()
}
}
if (m_source.isNotNull())
if (m_source)
m_source->setFiltSpec(m_filtspec);
initiateQuery();
}

View file

@ -29,7 +29,7 @@
#include "rcldb.h"
#include "searchdata.h"
#include "spell_w.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "pathut.h"
#include "guiutils.h"
@ -114,7 +114,7 @@ public slots:
virtual void periodic100();
virtual void toggleIndexing();
virtual void rebuildIndex();
virtual void startSearch(RefCntr<Rcl::SearchData> sdata, bool issimple);
virtual void startSearch(STD_SHARED_PTR<Rcl::SearchData> sdata, bool issimple);
virtual void previewClosed(Preview *w);
virtual void showAdvSearchDialog();
virtual void showSpellDialog();
@ -172,7 +172,7 @@ public slots:
virtual void showTrayMessage(const QString& text);
signals:
void docSourceChanged(RefCntr<DocSequence>);
void docSourceChanged(STD_SHARED_PTR<DocSequence>);
void stemLangChanged(const QString& lang);
void sortDataChanged(DocSeqSortSpec);
void resultsReady();
@ -212,7 +212,7 @@ private:
DocSeqFiltSpec m_filtspec;
bool m_sortspecnochange;
DocSeqSortSpec m_sortspec;
RefCntr<DocSequence> m_source;
STD_SHARED_PTR<DocSequence> m_source;
IndexerState m_indexerState;
bool m_queryActive;
bool m_firstIndexing;

View file

@ -47,7 +47,7 @@
#include "pathut.h"
#include "mimehandler.h"
#include "plaintorich.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "internfile.h"
#include "indexer.h"
#include "snippets_w.h"
@ -423,10 +423,10 @@ int ResList::newListId()
extern "C" int XFlush(void *);
void ResList::setDocSource(RefCntr<DocSequence> nsource)
void ResList::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
{
LOGDEB(("ResList::setDocSource()\n"));
m_source = RefCntr<DocSequence>(new DocSource(theconfig, nsource));
m_source = STD_SHARED_PTR<DocSequence>(new DocSource(theconfig, nsource));
}
// A query was executed, or the filtering/sorting parameters changed,
@ -435,7 +435,7 @@ void ResList::readDocSource()
{
LOGDEB(("ResList::readDocSource()\n"));
resetView();
if (m_source.isNull())
if (!m_source)
return;
m_listId = newListId();
@ -449,7 +449,7 @@ void ResList::readDocSource()
void ResList::resetList()
{
LOGDEB(("ResList::resetList()\n"));
setDocSource(RefCntr<DocSequence>());
setDocSource(STD_SHARED_PTR<DocSequence>());
resetView();
}
@ -481,7 +481,7 @@ bool ResList::displayingHistory()
// We want to reset the displayed history if it is currently
// shown. Using the title value is an ugly hack
string htstring = string((const char *)tr("Document history").toUtf8());
if (m_source.isNull() || m_source->title().empty())
if (!m_source || m_source->title().empty())
return false;
return m_source->title().find(htstring) == 0;
}
@ -850,7 +850,7 @@ void ResList::mouseDoubleClickEvent(QMouseEvent *event)
void ResList::showQueryDetails()
{
if (m_source.isNull())
if (!m_source)
return;
string oq = breakIntoLines(m_source->getDescription(), 100, 50);
QString str;
@ -871,7 +871,7 @@ void ResList::linkWasClicked(const QUrl &url)
// Open abstract/snippets window
case 'A':
{
if (m_source.isNull())
if (!m_source)
return;
int i = atoi(ascurl.c_str()+1) - 1;
Rcl::Doc doc;
@ -886,7 +886,7 @@ void ResList::linkWasClicked(const QUrl &url)
// Show duplicates
case 'D':
{
if (m_source.isNull())
if (!m_source)
return;
int i = atoi(ascurl.c_str()+1) - 1;
Rcl::Doc doc;
@ -910,7 +910,7 @@ void ResList::linkWasClicked(const QUrl &url)
LOGERR(("ResList::linkWasClicked: can't get doc for %d\n", i));
return;
}
emit editRequested(ResultPopup::getParent(RefCntr<DocSequence>(),
emit editRequested(ResultPopup::getParent(STD_SHARED_PTR<DocSequence>(),
doc));
}
break;
@ -1050,7 +1050,7 @@ void ResList::menuSaveToFile()
void ResList::menuPreviewParent()
{
Rcl::Doc doc;
if (getDoc(m_popDoc, doc) && !m_source.isNull()) {
if (getDoc(m_popDoc, doc) && m_source) {
Rcl::Doc pdoc = ResultPopup::getParent(m_source, doc);
if (pdoc.mimetype == "inode/directory") {
emit editRequested(pdoc);
@ -1063,7 +1063,7 @@ void ResList::menuPreviewParent()
void ResList::menuOpenParent()
{
Rcl::Doc doc;
if (getDoc(m_popDoc, doc) && m_source.isNotNull())
if (getDoc(m_popDoc, doc) && m_source)
emit editRequested(ResultPopup::getParent(m_source, doc));
}

View file

@ -37,7 +37,7 @@ using std::pair;
#include "docseq.h"
#include "sortseq.h"
#include "filtseq.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "rcldoc.h"
#include "reslistpager.h"
@ -70,7 +70,7 @@ class ResList : public RESLIST_PARENTCLASS
void setRclMain(RclMain *m, bool ismain);
public slots:
virtual void setDocSource(RefCntr<DocSequence> nsource);
virtual void setDocSource(STD_SHARED_PTR<DocSequence> nsource);
virtual void resetList(); // Erase current list
virtual void resPageUpOrBack(); // Page up pressed
virtual void resPageDownOrNext(); // Page down pressed
@ -122,7 +122,7 @@ class ResList : public RESLIST_PARENTCLASS
private:
QtGuiResListPager *m_pager;
RefCntr<DocSequence> m_source;
STD_SHARED_PTR<DocSequence> m_source;
int m_popDoc; // Docnum for the popup menu.
int m_curPvDoc;// Docnum for current preview
int m_lstClckMod; // Last click modifier.

View file

@ -29,15 +29,14 @@
namespace ResultPopup {
QMenu *create(QWidget *me, int opts, RefCntr<DocSequence> source, Rcl::Doc& doc)
QMenu *create(QWidget *me, int opts, STD_SHARED_PTR<DocSequence> source, Rcl::Doc& doc)
{
QMenu *popup = new QMenu(me);
LOGDEB(("ResultPopup::create: opts %x haspages %d %s %s\n", opts,
doc.haspages, source.isNull() ?
"Source is Null" : "Source not null",
source.isNull() ? "" : source->snippetsCapable() ?
"snippetsCapable" : "not snippetsCapable"));
doc.haspages, source ? "Source not null" : "Source is Null",
source ? (source->snippetsCapable() ?
"snippetsCapable" : "not snippetsCapable") : ""));
string apptag;
doc.getmeta(Rcl::Doc::keyapptg, &apptag);
@ -112,7 +111,7 @@ QMenu *create(QWidget *me, int opts, RefCntr<DocSequence> source, Rcl::Doc& doc)
me, SLOT(menuSaveSelection()));
Rcl::Doc pdoc;
if (source.isNotNull() && source->getEnclosing(doc, pdoc)) {
if (source && source->getEnclosing(doc, pdoc)) {
popup->addAction(QWidget::tr("Preview P&arent document/folder"),
me, SLOT(menuPreviewParent()));
}
@ -126,7 +125,7 @@ QMenu *create(QWidget *me, int opts, RefCntr<DocSequence> source, Rcl::Doc& doc)
popup->addAction(QWidget::tr("Find &similar documents"),
me, SLOT(menuExpand()));
if (doc.haspages && source.isNotNull() && source->snippetsCapable())
if (doc.haspages && source && source->snippetsCapable())
popup->addAction(QWidget::tr("Open &Snippets window"),
me, SLOT(menuShowSnippets()));
@ -137,10 +136,10 @@ QMenu *create(QWidget *me, int opts, RefCntr<DocSequence> source, Rcl::Doc& doc)
return popup;
}
Rcl::Doc getParent(RefCntr<DocSequence> source, Rcl::Doc& doc)
Rcl::Doc getParent(STD_SHARED_PTR<DocSequence> source, Rcl::Doc& doc)
{
Rcl::Doc pdoc;
if (source.isNull() || !source->getEnclosing(doc, pdoc)) {
if (!source || !source->getEnclosing(doc, pdoc)) {
// No parent doc: show enclosing folder with app configured for
// directories
pdoc.url = url_parentfolder(doc.url);

View file

@ -21,9 +21,9 @@ namespace ResultPopup {
enum Options {showExpand = 0x1, showSubs = 0x2, isMain = 0x3,
showSaveOne = 0x4, showSaveSel = 0x8};
extern QMenu *create(QWidget *me, int opts,
RefCntr<DocSequence> source,
STD_SHARED_PTR<DocSequence> source,
Rcl::Doc& doc);
extern Rcl::Doc getParent(RefCntr<DocSequence> source,
extern Rcl::Doc getParent(STD_SHARED_PTR<DocSequence> source,
Rcl::Doc& doc);
extern void copyFN(const Rcl::Doc &doc);
extern void copyURL(const Rcl::Doc &doc);

View file

@ -35,7 +35,7 @@
#include <QMessageBox>
#include "recoll.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "docseq.h"
#include "debuglog.h"
#include "restable.h"
@ -272,7 +272,7 @@ RecollModel::RecollModel(const QStringList fields, QObject *parent)
int RecollModel::rowCount(const QModelIndex&) const
{
LOGDEB2(("RecollModel::rowCount\n"));
if (m_source.isNull())
if (!m_source)
return 0;
return m_source->getResCnt();
}
@ -290,13 +290,13 @@ void RecollModel::readDocSource()
endResetModel();
}
void RecollModel::setDocSource(RefCntr<DocSequence> nsource)
void RecollModel::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
{
LOGDEB(("RecollModel::setDocSource\n"));
if (nsource.isNull()) {
m_source = RefCntr<DocSequence>();
if (!nsource) {
m_source = STD_SHARED_PTR<DocSequence>();
} else {
m_source = RefCntr<DocSequence>(new DocSource(theconfig, nsource));
m_source = STD_SHARED_PTR<DocSequence>(new DocSource(theconfig, nsource));
m_hdata.clear();
m_source->getTerms(m_hdata);
}
@ -356,7 +356,7 @@ QVariant RecollModel::data(const QModelIndex& index, int role) const
{
LOGDEB2(("RecollModel::data: row %d col %d role %d\n", index.row(),
index.column(), role));
if (m_source.isNull() || role != Qt::DisplayRole || !index.isValid() ||
if (!m_source || role != Qt::DisplayRole || !index.isValid() ||
index.column() >= int(m_fields.size())) {
return QVariant();
}
@ -375,7 +375,7 @@ QVariant RecollModel::data(const QModelIndex& index, int role) const
void RecollModel::saveAsCSV(FILE *fp)
{
if (m_source.isNull())
if (!m_source)
return;
int cols = columnCount();
@ -637,7 +637,7 @@ void ResTable::onTableView_currentChanged(const QModelIndex& index)
LOGDEB2(("ResTable::onTableView_currentChanged(%d, %d)\n",
index.row(), index.column()));
if (!m_model || m_model->getDocSource().isNull())
if (!m_model || !m_model->getDocSource())
return;
Rcl::Doc doc;
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
@ -665,7 +665,7 @@ void ResTable::takeFocus()
tableView->setFocus(Qt::ShortcutFocusReason);
}
void ResTable::setDocSource(RefCntr<DocSequence> nsource)
void ResTable::setDocSource(STD_SHARED_PTR<DocSequence> nsource)
{
LOGDEB(("ResTable::setDocSource\n"));
if (m_model)
@ -680,7 +680,7 @@ void ResTable::setDocSource(RefCntr<DocSequence> nsource)
void ResTable::resetSource()
{
LOGDEB(("ResTable::resetSource\n"));
setDocSource(RefCntr<DocSequence>());
setDocSource(STD_SHARED_PTR<DocSequence>());
}
void ResTable::saveAsCSV()
@ -782,7 +782,7 @@ void ResTable::linkWasClicked(const QUrl &url)
// Open parent folder
case 'F':
{
emit editRequested(ResultPopup::getParent(RefCntr<DocSequence>(),
emit editRequested(ResultPopup::getParent(STD_SHARED_PTR<DocSequence>(),
m_detaildoc));
}
break;
@ -823,7 +823,7 @@ void ResTable::linkWasClicked(const QUrl &url)
void ResTable::onDoubleClick(const QModelIndex& index)
{
if (!m_model || m_model->getDocSource().isNull())
if (!m_model || !m_model->getDocSource())
return;
Rcl::Doc doc;
if (m_model->getDocSource()->getDoc(index.row(), doc)) {
@ -877,7 +877,7 @@ void ResTable::menuSaveToFile()
void ResTable::menuSaveSelection()
{
if (m_model == 0 || m_model->getDocSource().isNull())
if (m_model == 0 || !m_model->getDocSource())
return;
QModelIndexList indexl = tableView->selectionModel()->selectedRows();
@ -899,7 +899,7 @@ void ResTable::menuSaveSelection()
void ResTable::menuPreviewParent()
{
if (m_detaildocnum >= 0 && m_model &&
m_model->getDocSource().isNotNull()) {
m_model->getDocSource()) {
Rcl::Doc pdoc = ResultPopup::getParent(m_model->getDocSource(),
m_detaildoc);
if (pdoc.mimetype == "inode/directory") {
@ -912,7 +912,7 @@ void ResTable::menuPreviewParent()
void ResTable::menuOpenParent()
{
if (m_detaildocnum >= 0 && m_model && m_model->getDocSource().isNotNull())
if (m_detaildocnum >= 0 && m_model && m_model->getDocSource())
emit editRequested(
ResultPopup::getParent(m_model->getDocSource(), m_detaildoc));
}

View file

@ -16,15 +16,16 @@
*/
#ifndef _RESTABLE_H_INCLUDED_
#define _RESTABLE_H_INCLUDED_
#include "autoconfig.h"
#include <Qt>
#include <string>
#include <map>
#include <vector>
#include MEMORY_INCLUDE
#include "ui_restable.h"
#include "refcntr.h"
#include "docseq.h"
#include "plaintorich.h"
@ -50,8 +51,8 @@ public:
virtual void sort(int column, Qt::SortOrder order = Qt::AscendingOrder);
// Specific methods
virtual void readDocSource();
virtual void setDocSource(RefCntr<DocSequence> nsource);
virtual RefCntr<DocSequence> getDocSource() {return m_source;}
virtual void setDocSource(STD_SHARED_PTR<DocSequence> nsource);
virtual STD_SHARED_PTR<DocSequence> getDocSource() {return m_source;}
virtual void deleteColumn(int);
virtual const std::vector<std::string>& getFields() {return m_fields;}
virtual const std::map<std::string, QString>& getAllFields()
@ -72,7 +73,7 @@ signals:
void sortDataChanged(DocSeqSortSpec);
private:
mutable RefCntr<DocSequence> m_source;
mutable STD_SHARED_PTR<DocSequence> m_source;
std::vector<std::string> m_fields;
std::vector<FieldGetter*> m_getters;
static std::map<std::string, QString> o_displayableFields;
@ -126,7 +127,7 @@ public:
public slots:
virtual void onTableView_currentChanged(const QModelIndex&);
virtual void on_tableView_entered(const QModelIndex& index);
virtual void setDocSource(RefCntr<DocSequence> nsource);
virtual void setDocSource(STD_SHARED_PTR<DocSequence> nsource);
virtual void saveColState();
virtual void resetSource();
virtual void readDocSource(bool resetPos = true);

View file

@ -65,7 +65,7 @@ static PlainToRichQtSnippets g_hiliter;
void SnippetsW::init()
{
if (m_source.isNull())
if (!m_source)
return;
QPushButton *searchButton = new QPushButton(tr("Search"));

View file

@ -16,10 +16,14 @@
*/
#ifndef _SNIPPETS_W_H_INCLUDED_
#define _SNIPPETS_W_H_INCLUDED_
#include "autoconfig.h"
#include MEMORY_INCLUDE
#include <QString>
#include "rcldoc.h"
#include "refcntr.h"
#include "docseq.h"
#include "rclmain_w.h"
@ -29,7 +33,7 @@ class SnippetsW : public QWidget, public Ui::Snippets
{
Q_OBJECT
public:
SnippetsW(Rcl::Doc doc, RefCntr<DocSequence> source, QWidget* parent = 0)
SnippetsW(Rcl::Doc doc, STD_SHARED_PTR<DocSequence> source, QWidget* parent = 0)
: QWidget(parent), m_doc(doc), m_source(source)
{
setupUi((QDialog*)this);
@ -48,7 +52,7 @@ signals:
private:
void init();
Rcl::Doc m_doc;
RefCntr<DocSequence> m_source;
STD_SHARED_PTR<DocSequence> m_source;
};
#endif /* _SNIPPETS_W_H_INCLUDED_ */

View file

@ -332,7 +332,7 @@ void SpellW::showStats()
string reason;
string q = string("mime:") + *it;
Rcl::SearchData *sd = wasaStringToRcl(theconfig, "", q, reason);
RefCntr<Rcl::SearchData> rq(sd);
STD_SHARED_PTR<Rcl::SearchData> rq(sd);
Rcl::Query query(rcldb);
if (!query.setQuery(rq)) {
LOGERR(("Query setup failed: %s",query.getReason().c_str()));

View file

@ -34,7 +34,7 @@
#include "guiutils.h"
#include "searchdata.h"
#include "ssearch_w.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "textsplit.h"
#include "wasatorcl.h"
#include "rclhelp.h"
@ -309,7 +309,7 @@ bool SSearch::startSimpleSearch(const string& u8, int maxexp)
m_xml = xml.str();
LOGDEB(("SSearch::startSimpleSearch:xml:[%s]\n", m_xml.c_str()));
RefCntr<Rcl::SearchData> rsdata(sdata);
STD_SHARED_PTR<Rcl::SearchData> rsdata(sdata);
emit startSearch(rsdata, true);
return true;
}

View file

@ -26,7 +26,7 @@ class QTimer;
#include "recoll.h"
#include "searchdata.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "ui_ssearchb.h"
@ -72,7 +72,7 @@ public slots:
virtual void takeFocus();
signals:
void startSearch(RefCntr<Rcl::SearchData>, bool);
void startSearch(STD_SHARED_PTR<Rcl::SearchData>, bool);
void clearSearch();
private:
bool m_escape;

View file

@ -51,7 +51,7 @@ public:
}
// The object we set up
RefCntr<SearchData> sd;
STD_SHARED_PTR<SearchData> sd;
bool isvalid;
private:
@ -94,8 +94,8 @@ bool SDHXMLHandler::startElement(const QString & /* namespaceURI */,
}
resetTemps();
// A new search descriptor. Allocate data structure
sd = RefCntr<SearchData>(new SearchData);
if (sd.isNull()) {
sd = STD_SHARED_PTR<SearchData>(new SearchData);
if (!sd) {
LOGERR(("SDHXMLHandler::startElement: out of memory\n"));
return false;
}
@ -208,7 +208,7 @@ bool SDHXMLHandler::endElement(const QString & /* namespaceURI */,
}
RefCntr<Rcl::SearchData> xmlToSearchData(const string& xml)
STD_SHARED_PTR<Rcl::SearchData> xmlToSearchData(const string& xml)
{
SDHXMLHandler handler;
QXmlSimpleReader reader;
@ -221,7 +221,7 @@ RefCntr<Rcl::SearchData> xmlToSearchData(const string& xml)
if (!reader.parse(xmlInputSource) || !handler.isvalid) {
LOGERR(("xmlToSearchData: parse failed for [%s]\n",
xml.c_str()));
return RefCntr<SearchData>();
return STD_SHARED_PTR<SearchData>();
}
return handler.sd;
}

View file

@ -57,12 +57,12 @@
* </SD>
*/
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "searchdata.h"
// Parsing XML from advanced search history or saved advanced search to to
// SearchData structure:
RefCntr<Rcl::SearchData> xmlToSearchData(const string& xml);
STD_SHARED_PTR<Rcl::SearchData> xmlToSearchData(const string& xml);
// Parsing XML from saved simple search to ssearch parameters
struct SSearchDef {

View file

@ -56,9 +56,9 @@ bool DocSequence::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
// Remove stacked modifying sources (sort, filter) until we get to a real one
void DocSource::stripStack()
{
if (m_seq.isNull())
if (!m_seq)
return;
while (m_seq->getSourceSeq().isNotNull()) {
while (m_seq->getSourceSeq()) {
m_seq = m_seq->getSourceSeq();
}
}
@ -68,7 +68,7 @@ bool DocSource::buildStack()
LOGDEB2(("DocSource::buildStack()\n"));
stripStack();
if (m_seq.isNull())
if (!m_seq)
return false;
// Filtering must be done before sorting, (which may
@ -80,7 +80,7 @@ bool DocSource::buildStack()
} else {
if (m_fspec.isNotNull()) {
m_seq =
RefCntr<DocSequence>(new DocSeqFiltered(m_config, m_seq, m_fspec));
STD_SHARED_PTR<DocSequence>(new DocSeqFiltered(m_config, m_seq, m_fspec));
}
}
@ -90,7 +90,7 @@ bool DocSource::buildStack()
}
} else {
if (m_sspec.isNotNull()) {
m_seq = RefCntr<DocSequence>(new DocSeqSorted(m_seq, m_sspec));
m_seq = STD_SHARED_PTR<DocSequence>(new DocSeqSorted(m_seq, m_sspec));
}
}
return true;
@ -98,7 +98,7 @@ bool DocSource::buildStack()
string DocSource::title()
{
if (m_seq.isNull())
if (!m_seq)
return string();
string qual;
if (m_fspec.isNotNull() && !m_sspec.isNotNull())

View file

@ -16,13 +16,15 @@
*/
#ifndef _DOCSEQ_H_INCLUDED_
#define _DOCSEQ_H_INCLUDED_
#include "autoconfig.h"
#include <string>
#include <list>
#include <vector>
#include MEMORY_INCLUDE
#include "rcldoc.h"
#include "refcntr.h"
#include "hldata.h"
#include "ptmutex.h"
@ -153,7 +155,7 @@ class DocSequence {
virtual bool canSort() {return false;}
virtual bool setFiltSpec(const DocSeqFiltSpec &) {return false;}
virtual bool setSortSpec(const DocSeqSortSpec &) {return false;}
virtual RefCntr<DocSequence> getSourceSeq() {return RefCntr<DocSequence>();}
virtual STD_SHARED_PTR<DocSequence> getSourceSeq() {return STD_SHARED_PTR<DocSequence>();}
static void set_translations(const std::string& sort, const std::string& filt)
{
@ -179,59 +181,59 @@ protected:
*/
class DocSeqModifier : public DocSequence {
public:
DocSeqModifier(RefCntr<DocSequence> iseq)
DocSeqModifier(STD_SHARED_PTR<DocSequence> iseq)
: DocSequence(""), m_seq(iseq)
{}
virtual ~DocSeqModifier() {}
virtual bool getAbstract(Rcl::Doc& doc, std::vector<std::string>& abs)
{
if (m_seq.isNull())
if (!m_seq)
return false;
return m_seq->getAbstract(doc, abs);
}
virtual bool getAbstract(Rcl::Doc& doc,
std::vector<Rcl::Snippet>& abs)
{
if (m_seq.isNull())
if (!m_seq)
return false;
return m_seq->getAbstract(doc, abs);
}
/** Get duplicates. */
virtual bool docDups(const Rcl::Doc& doc, std::vector<Rcl::Doc>& dups)
{
if (m_seq.isNull())
if (!m_seq)
return false;
return m_seq->docDups(doc, dups);
}
virtual bool snippetsCapable()
{
if (m_seq.isNull())
if (!m_seq)
return false;
return m_seq->snippetsCapable();
}
virtual std::string getDescription()
{
if (m_seq.isNull())
if (!m_seq)
return "";
return m_seq->getDescription();
}
virtual void getTerms(HighlightData& hld)
{
if (m_seq.isNull())
if (!m_seq)
return;
m_seq->getTerms(hld);
}
virtual bool getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
{
if (m_seq.isNull())
if (!m_seq)
return false;
return m_seq->getEnclosing(doc, pdoc);
}
virtual std::string getReason()
{
if (m_seq.isNull())
if (!m_seq)
return string();
return m_seq->getReason();
}
@ -239,7 +241,7 @@ public:
{
return m_seq->title();
}
virtual RefCntr<DocSequence> getSourceSeq()
virtual STD_SHARED_PTR<DocSequence> getSourceSeq()
{
return m_seq;
}
@ -247,12 +249,12 @@ public:
protected:
virtual Rcl::Db *getDb()
{
if (m_seq.isNull())
if (!m_seq)
return 0;
return m_seq->getDb();
}
RefCntr<DocSequence> m_seq;
STD_SHARED_PTR<DocSequence> m_seq;
};
class RclConfig;
@ -261,7 +263,7 @@ class RclConfig;
// sorting and filtering in ways depending on the base seqs capabilities
class DocSource : public DocSeqModifier {
public:
DocSource(RclConfig *config, RefCntr<DocSequence> iseq)
DocSource(RclConfig *config, STD_SHARED_PTR<DocSequence> iseq)
: DocSeqModifier(iseq), m_config(config)
{}
virtual bool canFilter() {return true;}
@ -270,13 +272,13 @@ public:
virtual bool setSortSpec(const DocSeqSortSpec &);
virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0)
{
if (m_seq.isNull())
if (!m_seq)
return false;
return m_seq->getDoc(num, doc, sh);
}
virtual int getResCnt()
{
if (m_seq.isNull())
if (!m_seq)
return 0;
return m_seq->getResCnt();
}

View file

@ -25,8 +25,8 @@ using std::list;
#include "debuglog.h"
#include "wasatorcl.h"
DocSequenceDb::DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
RefCntr<Rcl::SearchData> sdata)
DocSequenceDb::DocSequenceDb(STD_SHARED_PTR<Rcl::Query> q, const string &t,
STD_SHARED_PTR<Rcl::SearchData> sdata)
: DocSequence(t), m_q(q), m_sdata(sdata), m_fsdata(sdata),
m_rescnt(-1),
m_queryBuildAbstract(true),
@ -131,7 +131,7 @@ int DocSequenceDb::getFirstMatchPage(Rcl::Doc &doc, string& term)
Rcl::Db *DocSequenceDb::getDb()
{
return m_q.isNotNull() ? m_q->whatDb() : 0;
return m_q ? m_q->whatDb() : 0;
}
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
@ -162,7 +162,7 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
PTMutexLocker locker(o_dblock);
if (fs.isNotNull()) {
// We build a search spec by adding a filtering layer to the base one.
m_fsdata = RefCntr<Rcl::SearchData>(
m_fsdata = STD_SHARED_PTR<Rcl::SearchData>(
new Rcl::SearchData(Rcl::SCLT_AND, m_sdata->getStemLang()));
Rcl::SearchDataClauseSub *cl =
new Rcl::SearchDataClauseSub(m_sdata);
@ -175,7 +175,7 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
break;
case DocSeqFiltSpec::DSFS_QLANG:
{
if (m_q.isNull())
if (!m_q)
break;
string reason;
@ -186,7 +186,7 @@ bool DocSequenceDb::setFiltSpec(const DocSeqFiltSpec &fs)
if (sd) {
Rcl::SearchDataClauseSub *cl1 =
new Rcl::SearchDataClauseSub(
RefCntr<Rcl::SearchData>(sd));
STD_SHARED_PTR<Rcl::SearchData>(sd));
m_fsdata->addClause(cl1);
}
}

View file

@ -17,7 +17,7 @@
#ifndef _DOCSEQDB_H_INCLUDED_
#define _DOCSEQDB_H_INCLUDED_
#include "docseq.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "searchdata.h"
#include "rclquery.h"
@ -25,8 +25,8 @@
/** A DocSequence from a Db query */
class DocSequenceDb : public DocSequence {
public:
DocSequenceDb(RefCntr<Rcl::Query> q, const string &t,
RefCntr<Rcl::SearchData> sdata);
DocSequenceDb(STD_SHARED_PTR<Rcl::Query> q, const string &t,
STD_SHARED_PTR<Rcl::SearchData> sdata);
virtual ~DocSequenceDb() {}
virtual bool getDoc(int num, Rcl::Doc &doc, string * = 0);
virtual int getResCnt();
@ -60,9 +60,9 @@ class DocSequenceDb : public DocSequence {
protected:
virtual Rcl::Db *getDb();
private:
RefCntr<Rcl::Query> m_q;
RefCntr<Rcl::SearchData> m_sdata;
RefCntr<Rcl::SearchData> m_fsdata; // Filtered
STD_SHARED_PTR<Rcl::Query> m_q;
STD_SHARED_PTR<Rcl::SearchData> m_sdata;
STD_SHARED_PTR<Rcl::SearchData> m_fsdata; // Filtered
int m_rescnt;
bool m_queryBuildAbstract;
bool m_queryReplaceAbstract;

View file

@ -47,7 +47,7 @@ static bool filter(const DocSeqFiltSpec& fs, const Rcl::Doc *x)
return false;
}
DocSeqFiltered::DocSeqFiltered(RclConfig *conf, RefCntr<DocSequence> iseq,
DocSeqFiltered::DocSeqFiltered(RclConfig *conf, STD_SHARED_PTR<DocSequence> iseq,
DocSeqFiltSpec &filtspec)
: DocSeqModifier(iseq), m_config(conf)
{

View file

@ -16,13 +16,12 @@
*/
#ifndef _FILTSEQ_H_INCLUDED_
#define _FILTSEQ_H_INCLUDED_
#include "autoconfig.h"
#include <vector>
#include <string>
using std::string;
using std::vector;
#include MEMORY_INCLUDE
#include "refcntr.h"
#include "docseq.h"
class RclConfig;
@ -33,17 +32,17 @@ class RclConfig;
*/
class DocSeqFiltered : public DocSeqModifier {
public:
DocSeqFiltered(RclConfig *conf, RefCntr<DocSequence> iseq,
DocSeqFiltered(RclConfig *conf, STD_SHARED_PTR<DocSequence> iseq,
DocSeqFiltSpec &filtspec);
virtual ~DocSeqFiltered() {}
virtual bool canFilter() {return true;}
virtual bool setFiltSpec(const DocSeqFiltSpec &filtspec);
virtual bool getDoc(int num, Rcl::Doc &doc, string *sh = 0);
virtual bool getDoc(int num, Rcl::Doc &doc, std::string *sh = 0);
virtual int getResCnt() {return m_seq->getResCnt();}
private:
RclConfig *m_config;
DocSeqFiltSpec m_spec;
vector<int> m_dbindices;
std::vector<int> m_dbindices;
};
#endif /* _FILTSEQ_H_INCLUDED_ */

View file

@ -330,7 +330,7 @@ endopts:
return 1;
}
RefCntr<Rcl::SearchData> rq(sd);
STD_SHARED_PTR<Rcl::SearchData> rq(sd);
Rcl::Query query(&rcldb);
if (op_flags & OPT_S) {
query.setSortBy(sortfield, (op_flags & OPT_D) ? false : true);

View file

@ -65,7 +65,7 @@ ResListPager::ResListPager(int pagesize)
void ResListPager::resultPageNext()
{
if (m_docSource.isNull()) {
if (!m_docSource) {
LOGDEB(("ResListPager::resultPageNext: null source\n"));
return;
}
@ -123,7 +123,7 @@ static string maybeEscapeHtml(const string& fld)
void ResListPager::resultPageFor(int docnum)
{
if (m_docSource.isNull()) {
if (!m_docSource) {
LOGDEB(("ResListPager::resultPageFor: null source\n"));
return;
}
@ -227,7 +227,7 @@ void ResListPager::displayDoc(RclConfig *config, int i, Rcl::Doc& doc,
string richabst;
bool needabstract = parFormat().find("%A") != string::npos;
if (needabstract && m_docSource.isNotNull()) {
if (needabstract && m_docSource) {
vector<string> vabs;
m_docSource->getAbstract(doc, vabs);
m_hiliter->set_inputhtml(false);
@ -344,7 +344,7 @@ bool ResListPager::getDoc(int num, Rcl::Doc& doc)
void ResListPager::displayPage(RclConfig *config)
{
LOGDEB(("ResListPager::displayPage\n"));
if (m_docSource.isNull()) {
if (!m_docSource) {
LOGDEB(("ResListPager::displayPage: null source\n"));
return;
}

View file

@ -17,10 +17,11 @@
#ifndef _reslistpager_h_included_
#define _reslistpager_h_included_
#include "autoconfig.h"
#include <vector>
#include MEMORY_INCLUDE
#include "refcntr.h"
#include "docseq.h"
#include "hldata.h"
@ -39,7 +40,7 @@ public:
{
m_hiliter = ptr;
}
void setDocSource(RefCntr<DocSequence> src, int winfirst = -1)
void setDocSource(STD_SHARED_PTR<DocSequence> src, int winfirst = -1)
{
m_pagesize = m_newpagesize;
m_winfirst = winfirst;
@ -87,8 +88,9 @@ public:
const HighlightData& hdata, const string& sh = "");
bool pageEmpty() {return m_respage.size() == 0;}
string queryDescription() {return m_docSource.isNull() ? "" :
m_docSource->getDescription();}
string queryDescription() {
return m_docSource ? m_docSource->getDescription() : "";
}
bool getDoc(int num, Rcl::Doc &doc);
@ -127,7 +129,7 @@ private:
int m_winfirst;
bool m_hasNext;
PlainToRich *m_hiliter;
RefCntr<DocSequence> m_docSource;
STD_SHARED_PTR<DocSequence> m_docSource;
std::vector<ResListEntry> m_respage;
};

View file

@ -16,11 +16,12 @@
*/
#ifndef _SORTSEQ_H_INCLUDED_
#define _SORTSEQ_H_INCLUDED_
#include "autoconfig.h"
#include <vector>
#include <string>
#include MEMORY_INCLUDE
#include "refcntr.h"
#include "docseq.h"
/**
@ -29,7 +30,7 @@
*/
class DocSeqSorted : public DocSeqModifier {
public:
DocSeqSorted(RefCntr<DocSequence> iseq, DocSeqSortSpec &sortspec)
DocSeqSorted(STD_SHARED_PTR<DocSequence> iseq, DocSeqSortSpec &sortspec)
: DocSeqModifier(iseq)
{
setSortSpec(sortspec);

View file

@ -21,7 +21,7 @@
#include "debuglog.h"
#include "utf8iter.h"
#include "smallut.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "textsplit.h"
#include "xmacros.h"
#include "rcldb.h"
@ -56,13 +56,13 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
vector<XapWritableComputableSynFamMember> stemdbs;
// Note: tried to make this to work with stack-allocated objects, couldn't.
// Looks like a bug in copy constructors somewhere, can't guess where
vector<RefCntr<SynTermTransStem> > stemmers;
vector<STD_SHARED_PTR<SynTermTransStem> > stemmers;
for (unsigned int i = 0; i < langs.size(); i++) {
stemmers.push_back(RefCntr<SynTermTransStem>
stemmers.push_back(STD_SHARED_PTR<SynTermTransStem>
(new SynTermTransStem(langs[i])));
stemdbs.push_back(
XapWritableComputableSynFamMember(wdb, synFamStem, langs[i],
stemmers.back().getptr()));
stemmers.back().get()));
stemdbs.back().recreate();
}
@ -73,7 +73,7 @@ bool createExpansionDbs(Xapian::WritableDatabase& wdb,
for (unsigned int i = 0; i < langs.size(); i++) {
unacstemdbs.push_back(
XapWritableComputableSynFamMember(wdb, synFamStemUnac, langs[i],
stemmers.back().getptr()));
stemmers.back().get()));
unacstemdbs.back().recreate();
}
}

View file

@ -157,7 +157,7 @@ double Query::Native::qualityTerms(Xapian::docid docid,
if (doclen == 0)
doclen = 1;
HighlightData hld;
if (!m_q->m_sd.isNull()) {
if (m_q->m_sd) {
m_q->m_sd->getTerms(hld);
}

View file

@ -570,7 +570,7 @@ bool Db::Native::addOrUpdateWrite(const string& udi, const string& uniterm,
Chrono chron;
PTMutexLocker lock(m_mutex);
#endif
RefCntr<Xapian::Document> doc_cleaner(newdocument_ptr);
STD_SHARED_PTR<Xapian::Document> doc_cleaner(newdocument_ptr);
// Check file system full every mbyte of indexed text. It's a bit wasteful
// to do this after having prepared the document, but it needs to be in

View file

@ -21,9 +21,9 @@
#include <string>
#include <vector>
#include MEMORY_INCLUDE
#include "cstr.h"
#include "refcntr.h"
#include "rcldoc.h"
#include "stoplist.h"
#include "rclconfig.h"

View file

@ -70,7 +70,7 @@ bool Db::docDups(const Doc& idoc, vector<Doc>& odocs)
MD5HexPrint(digest, md5);
SearchData *sdp = new SearchData();
RefCntr<SearchData> sd(sdp);
STD_SHARED_PTR<SearchData> sd(sdp);
SearchDataClauseSimple *sdc =
new SearchDataClauseSimple(SCLT_AND, md5, "rclmd5");
sdc->addModifier(SearchDataClause::SDCM_CASESENS);

View file

@ -173,7 +173,7 @@ void Query::setSortBy(const string& fld, bool ascending) {
#define ISNULL(X) !(X)
// Prepare query out of user search data
bool Query::setQuery(RefCntr<SearchData> sdata)
bool Query::setQuery(STD_SHARED_PTR<SearchData> sdata)
{
LOGDEB(("Query::setQuery:\n"));

View file

@ -19,7 +19,7 @@
#include <string>
#include <vector>
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "searchdata.h"
#ifndef NO_NAMESPACES
@ -92,7 +92,7 @@ class Query {
* be called repeatedly on the same object which gets reinitialized each
* time.
*/
bool setQuery(RefCntr<SearchData> q);
bool setQuery(STD_SHARED_PTR<SearchData> q);
/** Get results count for current query */
int getResCnt();
@ -117,7 +117,7 @@ class Query {
int getFirstMatchPage(const Doc &doc, std::string& term);
/** Retrieve a reference to the searchData we are using */
RefCntr<SearchData> getSD()
STD_SHARED_PTR<SearchData> getSD()
{
return m_sd;
}
@ -143,7 +143,7 @@ private:
bool m_sortAscending;
bool m_collapseDuplicates;
int m_resCnt;
RefCntr<SearchData> m_sd;
STD_SHARED_PTR<SearchData> m_sd;
int m_snipMaxPosWalk;
/* Copyconst and assignement private and forbidden */

View file

@ -198,11 +198,11 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
XapComputableSynFamMember synac(xrdb, synFamDiCa, "all", &unacfoldtrans);
if (matchtyp == ET_WILD || matchtyp == ET_REGEXP) {
RefCntr<StrMatcher> matcher;
STD_SHARED_PTR<StrMatcher> matcher;
if (matchtyp == ET_WILD) {
matcher = RefCntr<StrMatcher>(new StrWildMatcher(term));
matcher = STD_SHARED_PTR<StrMatcher>(new StrWildMatcher(term));
} else {
matcher = RefCntr<StrMatcher>(new StrRegexpMatcher(term));
matcher = STD_SHARED_PTR<StrMatcher>(new StrRegexpMatcher(term));
}
if (!diac_sensitive || !case_sensitive) {
// Perform case/diac expansion on the exp as appropriate and
@ -211,14 +211,14 @@ bool Db::termMatch(int typ_sens, const string &lang, const string &_term,
if (diac_sensitive) {
// Expand for diacritics and case, filtering for same diacritics
SynTermTransUnac foldtrans(UNACOP_FOLD);
synac.synKeyExpand(matcher.getptr(), exp, &foldtrans);
synac.synKeyExpand(matcher.get(), exp, &foldtrans);
} else if (case_sensitive) {
// Expand for diacritics and case, filtering for same case
SynTermTransUnac unactrans(UNACOP_UNAC);
synac.synKeyExpand(matcher.getptr(), exp, &unactrans);
synac.synKeyExpand(matcher.get(), exp, &unactrans);
} else {
// Expand for diacritics and case, no filtering
synac.synKeyExpand(matcher.getptr(), exp);
synac.synKeyExpand(matcher.get(), exp);
}
// Retrieve additional info and filter against the index itself
for (vector<string>::const_iterator it = exp.begin();
@ -337,21 +337,21 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
}
res.prefix = prefix;
RefCntr<StrMatcher> matcher;
STD_SHARED_PTR<StrMatcher> matcher;
if (typ == ET_REGEXP) {
matcher = RefCntr<StrMatcher>(new StrRegexpMatcher(root));
matcher = STD_SHARED_PTR<StrMatcher>(new StrRegexpMatcher(root));
if (!matcher->ok()) {
LOGERR(("termMatch: regcomp failed: %s\n",
matcher->getreason().c_str()))
return false;
}
} else if (typ == ET_WILD) {
matcher = RefCntr<StrMatcher>(new StrWildMatcher(root));
matcher = STD_SHARED_PTR<StrMatcher>(new StrWildMatcher(root));
}
// Find the initial section before any special char
string::size_type es = string::npos;
if (matcher.isNotNull()) {
if (matcher) {
es = matcher->baseprefixlen();
}
@ -391,7 +391,7 @@ bool Db::idxTermMatch(int typ_sens, const string &lang, const string &root,
term = *it;
}
if (matcher.isNotNull() && !matcher->match(term))
if (matcher && !matcher->match(term))
continue;
res.entries.push_back(

View file

@ -162,7 +162,7 @@ bool SearchData::maybeAddAutoPhrase(Rcl::Db& db, double freqThreshold)
// an actual user-entered phrase
slack += 1 + nwords / 3;
m_autophrase = RefCntr<SearchDataClauseDist>(
m_autophrase = STD_SHARED_PTR<SearchDataClauseDist>(
new SearchDataClauseDist(SCLT_PHRASE, swords, slack, field));
return true;
}
@ -341,7 +341,7 @@ void SearchDataClauseDist::dump(ostream& o) const
void SearchDataClauseSub::dump(ostream& o) const
{
o << "ClauseSub {\n";
m_sub.getconstptr()->dump(o);
m_sub->dump(o);
o << "}";
}

View file

@ -29,7 +29,7 @@
#include <ostream>
#include "rcldb.h"
#include "refcntr.h"
#include MEMORY_INCLUDE
#include "smallut.h"
#include "cstr.h"
#include "hldata.h"
@ -174,7 +174,7 @@ private:
std::vector<std::string> m_nfiletypes;
// Autophrase if set. Can't be part of the normal chain because
// it uses OP_AND_MAYBE
RefCntr<SearchDataClauseDist> m_autophrase;
STD_SHARED_PTR<SearchDataClauseDist> m_autophrase;
// Special stuff produced by input which looks like a clause but means
// something else (date and size specs)
@ -487,7 +487,7 @@ private:
/** Subquery */
class SearchDataClauseSub : public SearchDataClause {
public:
SearchDataClauseSub(RefCntr<SearchData> sub)
SearchDataClauseSub(STD_SHARED_PTR<SearchData> sub)
: SearchDataClause(SCLT_SUB), m_sub(sub)
{
}
@ -501,15 +501,15 @@ public:
virtual void getTerms(HighlightData& hldata) const
{
m_sub.getconstptr()->getTerms(hldata);
m_sub.get()->getTerms(hldata);
}
virtual RefCntr<SearchData> getSub() {
virtual STD_SHARED_PTR<SearchData> getSub() {
return m_sub;
}
virtual void dump(ostream& o) const;
protected:
RefCntr<SearchData> m_sub;
STD_SHARED_PTR<SearchData> m_sub;
};
} // Namespace Rcl

View file

@ -250,7 +250,7 @@ bool SearchData::toNativeQuery(Rcl::Db &db, void *d)
}
// Add the autophrase if any
if (m_autophrase.isNotNull()) {
if (m_autophrase) {
Xapian::Query apq;
if (m_autophrase->toNativeQuery(db, &apq)) {
xq = xq.empty() ? apq :

View file

@ -20,13 +20,13 @@
#include <iostream>
#include <algorithm>
#include MEMORY_INCLUDE
#include "debuglog.h"
#include "cstr.h"
#include "xmacros.h"
#include "synfamily.h"
#include "smallut.h"
#include "refcntr.h"
using namespace std;
@ -188,9 +188,9 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp,
LOGDEB(("XapCompSynFam::synKeyExpand: [%s]\n", inexp->exp().c_str()));
// If set, compute filtering term (e.g.: only case-folded)
RefCntr<StrMatcher> filter_exp;
STD_SHARED_PTR<StrMatcher> filter_exp;
if (filtertrans) {
filter_exp = RefCntr<StrMatcher>(inexp->clone());
filter_exp = STD_SHARED_PTR<StrMatcher>(inexp->clone());
filter_exp->setExp((*filtertrans)(inexp->exp()));
}
@ -217,7 +217,7 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp,
m_family.getdb().synonyms_begin(*xit);
xit1 != m_family.getdb().synonyms_end(*xit); xit1++) {
string term = *xit1;
if (filter_exp.isNotNull()) {
if (filter_exp) {
string term1 = (*filtertrans)(term);
LOGDEB2((" Testing [%s] against [%s]\n",
term1.c_str(), filter_exp->exp().c_str()));
@ -231,7 +231,7 @@ bool XapComputableSynFamMember::synKeyExpand(StrMatcher* inexp,
}
// Same with key itself
string term = (*xit).substr(preflen);
if (filter_exp.isNotNull()) {
if (filter_exp) {
string term1 = (*filtertrans)(term);
LOGDEB2((" Testing [%s] against [%s]\n",
term1.c_str(), filter_exp->exp().c_str()));

View file

@ -1330,7 +1330,7 @@ using namespace std;
bool resizecc(const string& dir, int newmbs)
{
RefCntr<CirCache> occ(new CirCache(dir));
STD_SHARED_PTR<CirCache> occ(new CirCache(dir));
string ofn = occ->getpath();
string backupfn = ofn + ".orig";
@ -1353,7 +1353,7 @@ bool resizecc(const string& dir, int newmbs)
}
}
RefCntr<CirCache> ncc(new CirCache(tmpdir));
STD_SHARED_PTR<CirCache> ncc(new CirCache(tmpdir));
string nfn = ncc->getpath();
if (!ncc->create(off_t(newmbs) * 1000 * 1024,
CirCache::CC_CRUNIQUE | CirCache::CC_CRTRUNCATE)) {

View file

@ -690,7 +690,7 @@ int ExecCmd::doexec(const string &cmd, const vector<string>& args,
LOGERR(("ExecCmd::doexec: no connection from command\n"));
return -1;
}
oclicon->setcallback(RefCntr<NetconWorker>
oclicon->setcallback(STD_SHARED_PTR<NetconWorker>
(new ExecReader(output, m_advise)));
myloop.addselcon(m_fromcmd, Netcon::NETCONPOLL_READ);
// Give up ownership
@ -703,7 +703,7 @@ int ExecCmd::doexec(const string &cmd, const vector<string>& args,
LOGERR(("ExecCmd::doexec: no connection from command\n"));
return -1;
}
iclicon->setcallback(RefCntr<NetconWorker>
iclicon->setcallback(STD_SHARED_PTR<NetconWorker>
(new ExecWriter(input, m_provide)));
myloop.addselcon(m_tocmd, Netcon::NETCONPOLL_WRITE);
// Give up ownership

View file

@ -19,6 +19,8 @@
#ifndef TEST_NETCON
#include "autoconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -1230,8 +1232,8 @@ int trycli(char *host, char *serv)
}
}
#else
RefCntr<NetconWorker> worker =
RefCntr<NetconWorker>(new CliNetconWorker());
STD_SHARED_PTR<NetconWorker> worker =
STD_SHARED_PTR<NetconWorker>(new CliNetconWorker());
clicon->setcallback(worker);
SelectLoop myloop;
myloop.addselcon(con, Netcon::NETCONPOLL_WRITE);
@ -1296,8 +1298,8 @@ protected:
if (con == 0) {
return -1;
}
RefCntr<NetconWorker> worker =
RefCntr<NetconWorker>(new ServNetconWorker());
STD_SHARED_PTR<NetconWorker> worker =
STD_SHARED_PTR<NetconWorker>(new ServNetconWorker());
con->setcallback(worker);
m_loop.addselcon(NetconP(con), NETCONPOLL_READ);
return 1;

View file

@ -16,11 +16,13 @@
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "autoconfig.h"
#include <sys/time.h>
#include <map>
#include <string>
#include "refcntr.h"
#include MEMORY_INCLUDE
/// A set of classes to manage client-server communication over a
/// connection-oriented network, or a pipe.
@ -37,7 +39,7 @@
/// Base class for all network endpoints:
class Netcon;
typedef RefCntr<Netcon> NetconP;
typedef STD_SHARED_PTR<Netcon> NetconP;
class SelectLoop;
class Netcon {
@ -240,7 +242,7 @@ public:
virtual int getline(char *buf, int cnt, int timeo = -1);
/// Set handler to be called when the connection is placed in the
/// selectloop and an event occurs.
virtual void setcallback(RefCntr<NetconWorker> user) {
virtual void setcallback(STD_SHARED_PTR<NetconWorker> user) {
m_user = user;
}
@ -249,7 +251,7 @@ private:
char *m_bufbase; // Pointer to current 1st byte of useful data
int m_bufbytes; // Bytes of data.
int m_bufsize; // Total buffer size
RefCntr<NetconWorker> m_user;
STD_SHARED_PTR<NetconWorker> m_user;
virtual int cando(Netcon::Event reason); // Selectloop slot
};

View file

@ -16,13 +16,15 @@
*/
#ifndef _PATHUT_H_INCLUDED_
#define _PATHUT_H_INCLUDED_
#include "autoconfig.h"
#include <unistd.h>
#include <string>
#include <vector>
#include <set>
#include "refcntr.h"
#include MEMORY_INCLUDE
/// Add a / at the end if none there yet.
extern void path_catslash(std::string &s);
@ -116,7 +118,7 @@ private:
bool m_noremove;
};
typedef RefCntr<TempFileInternal> TempFile;
typedef STD_SHARED_PTR<TempFileInternal> TempFile;
/// Temporary directory class. Recursively deleted by destructor.
class TempDir {

View file

@ -1,5 +1,21 @@
#ifndef _REFCNTR_H_
#define _REFCNTR_H_
/* Copyright (C) 2014 J.F.Dockes
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// See Stroustrup C++ 3rd ed, p. 783
// This is only used if std::shared_ptr is not available
@ -33,8 +49,7 @@ public:
(*pcount)++;
return *this;
}
void release()
{
void reset() {
if (pcount && --(*pcount) == 0) {
delete rep;
delete pcount;
@ -42,22 +57,14 @@ public:
rep = 0;
pcount = 0;
}
void reset() {
release();
}
~RefCntr()
{
release();
reset();
}
X *operator->() {return rep;}
X *getptr() const {return rep;}
X *get() const {return rep;}
const X *getconstptr() const {return rep;}
int getcnt() const {return pcount ? *pcount : 0;}
bool isNull() const {return rep == 0;}
bool isNotNull() const {return rep != 0;}
int use_count() const {return pcount ? *pcount : 0;}
operator bool() const {return rep != 0;}
};
#endif /*_REFCNTR_H_ */