const string cleanup
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
/* Copyright (C) 2011 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.
|
||||
*/
|
||||
|
||||
#include "autoconfig.h"
|
||||
|
||||
#include "cstr.h"
|
||||
#include "beaglequeuecache.h"
|
||||
#include "circache.h"
|
||||
#include "debuglog.h"
|
||||
@@ -42,18 +60,18 @@ bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc,
|
||||
ConfSimple cf(dict, 1);
|
||||
|
||||
if (htt)
|
||||
cf.get(Rcl::Doc::keybght, *htt, "");
|
||||
cf.get(Rcl::Doc::keybght, *htt, cstr_null);
|
||||
|
||||
// Build a doc from saved metadata
|
||||
cf.get("url", dotdoc.url, "");
|
||||
cf.get("mimetype", dotdoc.mimetype, "");
|
||||
cf.get("fmtime", dotdoc.fmtime, "");
|
||||
cf.get("fbytes", dotdoc.fbytes, "");
|
||||
dotdoc.sig = "";
|
||||
list<string> names = cf.getNames("");
|
||||
cf.get(cstr_url, dotdoc.url, cstr_null);
|
||||
cf.get(cstr_mimetype, dotdoc.mimetype, cstr_null);
|
||||
cf.get(cstr_fmtime, dotdoc.fmtime, cstr_null);
|
||||
cf.get(cstr_fbytes, dotdoc.fbytes, cstr_null);
|
||||
dotdoc.sig.clear();
|
||||
list<string> names = cf.getNames(cstr_null);
|
||||
for (list<string>::const_iterator it = names.begin();
|
||||
it != names.end(); it++) {
|
||||
cf.get(*it, dotdoc.meta[*it], "");
|
||||
cf.get(*it, dotdoc.meta[*it], cstr_null);
|
||||
}
|
||||
dotdoc.meta[Rcl::Doc::keyudi] = udi;
|
||||
return true;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
#include "cstr.h"
|
||||
#define RCLIN_CSTR_CPPFILE
|
||||
#undef _CSTR_H_INCLUDED_
|
||||
#include "cstr.h"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/* Copyright (C) 2011 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.
|
||||
*/
|
||||
|
||||
#ifndef _CSTR_H_INCLUDED_
|
||||
#define _CSTR_H_INCLUDED_
|
||||
|
||||
// recoll mostly uses STL strings. In many places we had automatic
|
||||
// conversion from a C string to an STL one. This costs, and can
|
||||
// become significant if used often.
|
||||
//
|
||||
// This file and the associated .cpp file declares/defines constant
|
||||
// strings used in the program. Strings are candidates for a move here
|
||||
// when they are used in a fast loop or are shared.
|
||||
|
||||
#include <string>
|
||||
using std::string;
|
||||
|
||||
// The following slightly hacky preprocessing directives and the
|
||||
// companion code in the cpp file looks complicated, but it just
|
||||
// ensures that we only have to write the strings once to get the
|
||||
// extern declaration and the definition.
|
||||
#ifdef RCLIN_CSTR_CPPFILE
|
||||
#undef DEF_CSTR
|
||||
#define DEF_CSTR(NM, STR) const string cstr_##NM(STR)
|
||||
#else
|
||||
#define DEF_CSTR(NM, STR) extern const string cstr_##NM
|
||||
#endif
|
||||
|
||||
DEF_CSTR(author, "author");
|
||||
DEF_CSTR(caption, "caption");
|
||||
DEF_CSTR(charset, "charset");
|
||||
DEF_CSTR(content, "content");
|
||||
DEF_CSTR(dmtime, "dmtime");
|
||||
DEF_CSTR(dquote, "\"");
|
||||
DEF_CSTR(fbytes, "fbytes");
|
||||
DEF_CSTR(fileu, "file://");
|
||||
DEF_CSTR(fmtime, "fmtime");
|
||||
DEF_CSTR(ipath, "ipath");
|
||||
DEF_CSTR(iso_8859_1, "ISO-8859-1");
|
||||
DEF_CSTR(mimetype, "mimetype");
|
||||
DEF_CSTR(minwilds, "*?[");
|
||||
DEF_CSTR(newline, "\n");
|
||||
DEF_CSTR(null, "");
|
||||
DEF_CSTR(plus, "+");
|
||||
DEF_CSTR(textplain, "text/plain");
|
||||
DEF_CSTR(url, "url");
|
||||
|
||||
#endif /* _CSTR_H_INCLUDED_ */
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
#include "cstr.h"
|
||||
#include "pathut.h"
|
||||
#include "rclconfig.h"
|
||||
#include "conftree.h"
|
||||
@@ -176,7 +177,7 @@ RclConfig::RclConfig(const string *argcnf)
|
||||
return;
|
||||
|
||||
m_ok = true;
|
||||
setKeyDir("");
|
||||
setKeyDir(cstr_null);
|
||||
|
||||
m_stpsuffstate.init(this, mimemap, "recoll_noindex");
|
||||
m_skpnstate.init(this, m_conf, "skippedNames");
|
||||
@@ -199,7 +200,7 @@ bool RclConfig::updateMainConfig()
|
||||
m_rmtstate.init(this, 0, "indexedmimetypes");
|
||||
return false;
|
||||
}
|
||||
setKeyDir("");
|
||||
setKeyDir(cstr_null);
|
||||
bool nocjk = false;
|
||||
if (getConfParam("nocjk", &nocjk) && nocjk == true) {
|
||||
TextSplit::cjkProcessing(false);
|
||||
@@ -348,7 +349,7 @@ const string& RclConfig::getDefCharset(bool filename)
|
||||
} else {
|
||||
// Note: it seems that all versions of iconv will take
|
||||
// iso-8859. Some won't take iso8859
|
||||
localecharset = string("ISO-8859-1");
|
||||
localecharset = string(cstr_iso_8859_1);
|
||||
}
|
||||
LOGDEB1(("RclConfig::getDefCharset: localecharset [%s]\n",
|
||||
localecharset.c_str()));
|
||||
@@ -377,7 +378,7 @@ bool RclConfig::addLocalFields(map<string, string> *tgt)
|
||||
sfields[i] = '\n';
|
||||
// Parse the result with a confsimple and add the results to the metadata
|
||||
ConfSimple conf(sfields, 1, true);
|
||||
list<string> nmlst = conf.getNames("");
|
||||
list<string> nmlst = conf.getNames(cstr_null);
|
||||
for (list<string>::const_iterator it = nmlst.begin();
|
||||
it != nmlst.end(); it++) {
|
||||
conf.get(*it, (*tgt)[*it]);
|
||||
@@ -488,15 +489,15 @@ string RclConfig::getMimeTypeFromSuffix(const string& suff)
|
||||
string RclConfig::getSuffixFromMimeType(const string &mt)
|
||||
{
|
||||
string suffix;
|
||||
list<string>sfs = mimemap->getNames("");
|
||||
list<string>sfs = mimemap->getNames(cstr_null);
|
||||
string mt1;
|
||||
for (list<string>::const_iterator it = sfs.begin();
|
||||
it != sfs.end(); it++) {
|
||||
if (mimemap->get(*it, mt1, ""))
|
||||
if (mimemap->get(*it, mt1, cstr_null))
|
||||
if (!stringicmp(mt, mt1))
|
||||
return *it;
|
||||
}
|
||||
return "";
|
||||
return cstr_null;
|
||||
}
|
||||
|
||||
/** Get list of file categories from mimeconf */
|
||||
@@ -955,7 +956,7 @@ bool RclConfig::getUncompressor(const string &mtype, list<string>& cmd)
|
||||
{
|
||||
string hs;
|
||||
|
||||
mimeconf->get(mtype, hs, "");
|
||||
mimeconf->get(mtype, hs, cstr_null);
|
||||
if (hs.empty())
|
||||
return false;
|
||||
list<string> tokens;
|
||||
@@ -1205,7 +1206,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
config->setKeyDir("");
|
||||
config->setKeyDir(cstr_null);
|
||||
list<string> names = config->getConfNames();
|
||||
names.sort();
|
||||
names.unique();
|
||||
|
||||
Reference in New Issue
Block a user