cosmetics: list -> vector in more places

This commit is contained in:
Jean-Francois Dockes 2012-04-11 19:58:08 +02:00
parent 5462f639d3
commit a17b7523e7
44 changed files with 285 additions and 313 deletions

View file

@ -70,8 +70,8 @@ bool BeagleQueueCache::getFromCache(const string& udi, Rcl::Doc &dotdoc,
cf.get(cstr_fmtime, dotdoc.fmtime, cstr_null);
cf.get(cstr_fbytes, dotdoc.pcbytes, cstr_null);
dotdoc.sig.clear();
list<string> names = cf.getNames(cstr_null);
for (list<string>::const_iterator it = names.begin();
vector<string> names = cf.getNames(cstr_null);
for (vector<string>::const_iterator it = names.begin();
it != names.end(); it++) {
cf.get(*it, dotdoc.meta[*it], cstr_null);
}

View file

@ -395,8 +395,8 @@ 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(cstr_null);
for (list<string>::const_iterator it = nmlst.begin();
vector<string> nmlst = conf.getNames(cstr_null);
for (vector<string>::const_iterator it = nmlst.begin();
it != nmlst.end(); it++) {
conf.get(*it, (*tgt)[*it]);
LOGDEB(("RclConfig::addLocalFields: [%s] => [%s]\n",
@ -414,14 +414,12 @@ bool RclConfig::addLocalFields(map<string, string> *tgt)
//
// This unfortunately means that searches by file names and mime type
// filtering don't work well together.
list<string> RclConfig::getAllMimeTypes()
vector<string> RclConfig::getAllMimeTypes()
{
list<string> lst;
vector<string> lst;
if (mimeconf == 0)
return lst;
lst = mimeconf->getNames("index");
lst.sort();
lst.unique();
return lst;
}
@ -511,9 +509,9 @@ string RclConfig::getMimeTypeFromSuffix(const string& suff)
string RclConfig::getSuffixFromMimeType(const string &mt)
{
string suffix;
list<string>sfs = mimemap->getNames(cstr_null);
vector<string>sfs = mimemap->getNames(cstr_null);
string mt1;
for (list<string>::const_iterator it = sfs.begin();
for (vector<string>::const_iterator it = sfs.begin();
it != sfs.end(); it++) {
if (mimemap->get(*it, mt1, cstr_null))
if (!stringicmp(mt, mt1))
@ -523,7 +521,7 @@ string RclConfig::getSuffixFromMimeType(const string &mt)
}
/** Get list of file categories from mimeconf */
bool RclConfig::getMimeCategories(list<string>& cats)
bool RclConfig::getMimeCategories(vector<string>& cats)
{
if (!mimeconf)
return false;
@ -533,9 +531,9 @@ bool RclConfig::getMimeCategories(list<string>& cats)
bool RclConfig::isMimeCategory(string& cat)
{
list<string>cats;
vector<string>cats;
getMimeCategories(cats);
for (list<string>::iterator it = cats.begin(); it != cats.end(); it++) {
for (vector<string>::iterator it = cats.begin(); it != cats.end(); it++) {
if (!stringicmp(*it,cat))
return true;
}
@ -543,7 +541,7 @@ bool RclConfig::isMimeCategory(string& cat)
}
/** Get list of mime types for category from mimeconf */
bool RclConfig::getMimeCatTypes(const string& cat, list<string>& tps)
bool RclConfig::getMimeCatTypes(const string& cat, vector<string>& tps)
{
tps.clear();
if (!mimeconf)
@ -576,7 +574,7 @@ string RclConfig::getMimeHandlerDef(const string &mtype, bool filtertypes)
return hs;
}
bool RclConfig::getGuiFilterNames(list<string>& cats)
bool RclConfig::getGuiFilterNames(vector<string>& cats)
{
if (!mimeconf)
return false;
@ -652,8 +650,9 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
// Build a direct map avoiding all indirections for field to
// prefix translation
// Add direct prefixes from the [prefixes] section
list<string>tps = m_fields->getNames("prefixes");
for (list<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
vector<string>tps = m_fields->getNames("prefixes");
for (vector<string>::const_iterator it = tps.begin();
it != tps.end(); it++) {
string val;
m_fields->get(*it, val, "prefixes");
ConfSimple attrs;
@ -677,7 +676,7 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
// Having the aliases in the prefix map avoids an additional indirection
// at index time.
tps = m_fields->getNames("aliases");
for (list<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
for (vector<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
string canonic = stringtolower(*it); // canonic name
FieldTraits ft;
map<string, FieldTraits>::const_iterator pit =
@ -687,9 +686,9 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
}
string aliases;
m_fields->get(canonic, aliases, "aliases");
list<string> l;
vector<string> l;
stringToStrings(aliases, l);
for (list<string>::const_iterator ait = l.begin();
for (vector<string>::const_iterator ait = l.begin();
ait != l.end(); ait++) {
if (pit != m_fldtotraits.end())
m_fldtotraits[stringtolower(*ait)] = ft;
@ -706,9 +705,9 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
}
#endif
list<string> sl = m_fields->getNames("stored");
vector<string> sl = m_fields->getNames("stored");
if (!sl.empty()) {
for (list<string>::const_iterator it = sl.begin();
for (vector<string>::const_iterator it = sl.begin();
it != sl.end(); it++) {
string fld = fieldCanon(stringtolower(*it));
m_storedFields.insert(fld);
@ -716,8 +715,8 @@ bool RclConfig::readFieldsConfig(const string& cnferrloc)
}
// Extended file attribute to field translations
list<string>xattrs = m_fields->getNames("xattrtofields");
for (list<string>::const_iterator it = xattrs.begin();
vector<string>xattrs = m_fields->getNames("xattrtofields");
for (vector<string>::const_iterator it = xattrs.begin();
it != xattrs.end(); it++) {
string val;
m_fields->get(*it, val, "xattrtofields");
@ -751,7 +750,7 @@ set<string> RclConfig::getIndexedFields()
if (m_fields == 0)
return flds;
list<string> sl = m_fields->getNames("prefixes");
vector<string> sl = m_fields->getNames("prefixes");
flds.insert(sl.begin(), sl.end());
return flds;
}
@ -769,10 +768,10 @@ string RclConfig::fieldCanon(const string& f)
return fld;
}
list<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn)
vector<string> RclConfig::getFieldSectNames(const string &sk, const char* patrn)
{
if (m_fields == 0)
return list<string>();
return vector<string>();
return m_fields->getNames(sk, patrn);
}
@ -802,8 +801,8 @@ bool RclConfig::getMimeViewerDefs(vector<pair<string, string> >& defs)
{
if (mimeview == 0)
return false;
list<string>tps = mimeview->getNames("view");
for (list<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
vector<string>tps = mimeview->getNames("view");
for (vector<string>::const_iterator it = tps.begin(); it != tps.end();it++) {
defs.push_back(pair<string, string>(*it, getMimeViewerDef(*it, "")));
}
return true;
@ -823,7 +822,7 @@ bool RclConfig::setMimeViewerDef(const string& mt, const string& def)
return false;
}
list<string> cdirs;
vector<string> cdirs;
cdirs.push_back(m_confdir);
cdirs.push_back(path_cat(m_datadir, "examples"));
@ -934,7 +933,7 @@ string RclConfig::getIdxStatusFile()
}
}
list<string>& RclConfig::getSkippedNames()
vector<string>& RclConfig::getSkippedNames()
{
if (m_skpnstate.needrecompute()) {
stringToStrings(m_skpnstate.savedvalue, m_skpnlist);
@ -942,9 +941,9 @@ list<string>& RclConfig::getSkippedNames()
return m_skpnlist;
}
list<string> RclConfig::getSkippedPaths()
vector<string> RclConfig::getSkippedPaths()
{
list<string> skpl;
vector<string> skpl;
getConfParam("skippedPaths", &skpl);
// Always add the dbdir and confdir to the skipped paths. This is
@ -952,30 +951,30 @@ list<string> RclConfig::getSkippedPaths()
// don't do this.
skpl.push_back(getDbDir());
skpl.push_back(getConfDir());
for (list<string>::iterator it = skpl.begin(); it != skpl.end(); it++) {
for (vector<string>::iterator it = skpl.begin(); it != skpl.end(); it++) {
*it = path_tildexpand(*it);
*it = path_canon(*it);
}
skpl.sort();
skpl.unique();
sort(skpl.begin(), skpl.end());
unique(skpl.begin(), skpl.end());
return skpl;
}
list<string> RclConfig::getDaemSkippedPaths()
vector<string> RclConfig::getDaemSkippedPaths()
{
list<string> skpl = getSkippedPaths();
list<string> dskpl;
vector<string> dskpl;
getConfParam("daemSkippedPaths", &dskpl);
for (list<string>::iterator it = dskpl.begin(); it != dskpl.end(); it++) {
for (vector<string>::iterator it = dskpl.begin(); it != dskpl.end(); it++) {
*it = path_tildexpand(*it);
*it = path_canon(*it);
}
dskpl.sort();
sort(dskpl.begin(), dskpl.end());
skpl.merge(dskpl);
skpl.unique();
vector<string> skpl1 = getSkippedPaths();
vector<string> skpl;
merge(dskpl.begin(), dskpl.end(), skpl1.begin(), skpl1.end(), skpl.begin());
unique(skpl.begin(), skpl.end());
return skpl;
}
@ -1024,20 +1023,20 @@ string RclConfig::findFilter(const string &icmd)
/**
* Return decompression command line for given mime type
*/
bool RclConfig::getUncompressor(const string &mtype, list<string>& cmd)
bool RclConfig::getUncompressor(const string &mtype, vector<string>& cmd)
{
string hs;
mimeconf->get(mtype, hs, cstr_null);
if (hs.empty())
return false;
list<string> tokens;
vector<string> tokens;
stringToStrings(hs, tokens);
if (tokens.empty()) {
LOGERR(("getUncompressor: empty spec for mtype %s\n", mtype.c_str()));
return false;
}
list<string>::iterator it = tokens.begin();
vector<string>::iterator it = tokens.begin();
if (tokens.size() < 2)
return false;
if (stringlowercmp("uncompress", *it++))
@ -1148,7 +1147,7 @@ void RclConfig::initFrom(const RclConfig& r)
#include <signal.h>
#include <iostream>
#include <list>
#include <vector>
#include <string>
using namespace std;
@ -1252,20 +1251,20 @@ int main(int argc, char **argv)
} else if (op_flags & OPT_c) {
// Check that all known mime types have an icon and belong to
// some category
list<string> catnames;
vector<string> catnames;
config->getMimeCategories(catnames);
cout << "Categories: ";
set<string> allmtsfromcats;
for (list<string>::const_iterator it = catnames.begin();
for (vector<string>::const_iterator it = catnames.begin();
it != catnames.end(); it++) {
cout << *it << " ";
}
cout << endl;
for (list<string>::const_iterator it = catnames.begin();
for (vector<string>::const_iterator it = catnames.begin();
it != catnames.end(); it++) {
list<string> cts;
vector<string> cts;
config->getMimeCatTypes(*it, cts);
for (list<string>::const_iterator it1 = cts.begin();
for (vector<string>::const_iterator it1 = cts.begin();
it1 != cts.end(); it1++) {
// Already in map -> duplicate
if (allmtsfromcats.find(*it1) != allmtsfromcats.end()) {
@ -1275,8 +1274,8 @@ int main(int argc, char **argv)
}
}
list<string> mtypes = config->getAllMimeTypes();
for (list<string>::const_iterator it = mtypes.begin();
vector<string> mtypes = config->getAllMimeTypes();
for (vector<string>::const_iterator it = mtypes.begin();
it != mtypes.end(); it++) {
if (allmtsfromcats.find(*it) == allmtsfromcats.end()) {
cout << "Not found in catgs: [" << *it << "]" << endl;
@ -1284,10 +1283,8 @@ int main(int argc, char **argv)
}
} else {
config->setKeyDir(cstr_null);
list<string> names = config->getConfNames();
names.sort();
names.unique();
for (list<string>::iterator it = names.begin();
vector<string> names = config->getConfNames();
for (vector<string>::iterator it = names.begin();
it != names.end();it++) {
string value;
config->getConfParam(*it, value);

View file

@ -121,7 +121,7 @@ class RclConfig {
* Get list of config names under current sk, with possible
* wildcard filtering
*/
list<string> getConfNames(const char *pattern = 0) {
vector<string> getConfNames(const char *pattern = 0) {
return m_conf->getNames(m_keydir, pattern);
}
@ -151,13 +151,13 @@ class RclConfig {
string getIdxStatusFile();
/** Get list of skipped file names for current keydir */
list<string>& getSkippedNames();
vector<string>& getSkippedNames();
/** Get list of skipped paths patterns. Doesn't depend on the keydir */
list<string> getSkippedPaths();
vector<string> getSkippedPaths();
/** Get list of skipped paths patterns, daemon version (may add some)
Doesn't depend on the keydir */
list<string> getDaemSkippedPaths();
vector<string> getDaemSkippedPaths();
/** conf: Add local fields to target dic */
bool addLocalFields(map<string, string> *tgt);
@ -177,12 +177,12 @@ class RclConfig {
* The returned command has substitutable places for input file name
* and temp dir name, and will return output name
*/
bool getUncompressor(const string &mtpe, list<string>& cmd);
bool getUncompressor(const string &mtpe, vector<string>& cmd);
/** mimemap: compute mimetype */
string getMimeTypeFromSuffix(const string &suffix);
/** mimemap: get a list of all indexable mime types defined */
list<string> getAllMimeTypes();
vector<string> getAllMimeTypes();
/** mimemap: Get appropriate suffix for mime type. This is inefficient */
string getSuffixFromMimeType(const string &mt);
@ -200,14 +200,14 @@ class RclConfig {
string getMimeIconName(const string &mtype, string *path = 0);
/** mimeconf: get list of file categories */
bool getMimeCategories(list<string>&);
bool getMimeCategories(vector<string>&);
/** mimeconf: is parameter one of the categories ? */
bool isMimeCategory(string&);
/** mimeconf: get list of mime types for category */
bool getMimeCatTypes(const string& cat, list<string>&);
bool getMimeCatTypes(const string& cat, vector<string>&);
/** mimeconf: get list of gui filters (doc cats by default */
bool getGuiFilterNames(list<string>&);
bool getGuiFilterNames(vector<string>&);
/** mimeconf: get query lang frag for named filter */
bool getGuiFilter(const string& filtername, string& frag);
@ -222,7 +222,7 @@ class RclConfig {
/** Get value of a parameter inside the "fields" file. Only some filters
use this (ie: mh_mail). The information specific to a given filter
is typically stored in a separate section(ie: [mail]) */
list<string> getFieldSectNames(const string &sk, const char* = 0);
vector<string> getFieldSectNames(const string &sk, const char* = 0);
bool getFieldConfParam(const string &name, const string &sk, string &value);
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
@ -267,7 +267,7 @@ class RclConfig {
string m_keydir; // Current directory used for parameter fetches.
int m_keydirgen; // To help with knowing when to update computed data.
list<string> m_cdirs; // directory stack for the confstacks
vector<string> m_cdirs; // directory stack for the confstacks
ConfStack<ConfTree> *m_conf; // Parsed configuration files
ConfStack<ConfTree> *mimemap; // The files don't change with keydir,
@ -284,7 +284,7 @@ class RclConfig {
ParamStale m_stpsuffstate;
ParamStale m_skpnstate;
list<string> m_skpnlist;
vector<string> m_skpnlist;
// Parameters auto-fetched on setkeydir
string defcharset;

View file

@ -127,8 +127,8 @@ public:
confstr += line + "\n";
}
ConfSimple fields(confstr, 1);
list<string> names = fields.getNames(cstr_null);
for (list<string>::iterator it = names.begin();
vector<string> names = fields.getNames(cstr_null);
for (vector<string>::iterator it = names.begin();
it != names.end(); it++) {
string value;
fields.get(*it, value, cstr_null);

View file

@ -17,6 +17,9 @@
#ifndef _beaglequeue_h_included_
#define _beaglequeue_h_included_
#include <list>
using std::list;
/**
* Process the Beagle indexing queue.
*

View file

@ -239,13 +239,13 @@ bool ConfIndexer::createStemmingDatabases()
LOGERR(("ConfIndexer::createStemmingDb: could not open db\n"))
return false;
}
list<string> langs;
vector<string> langs;
stringToStrings(slangs, langs);
// Get the list of existing stem dbs from the database (some may have
// been manually created, we just keep those from the config
list<string> dblangs = m_db.getStemLangs();
list<string>::const_iterator it;
vector<string> dblangs = m_db.getStemLangs();
vector<string>::const_iterator it;
for (it = dblangs.begin(); it != dblangs.end(); it++) {
if (find(langs.begin(), langs.end(), *it) == langs.end())
m_db.deleteStemDb(*it);

View file

@ -130,7 +130,7 @@ bool FileInterner::getEnclosing(const string &url, const string &ipath,
// Uncompress input file into a temporary one, by executing the appropriate
// script.
static bool uncompressfile(RclConfig *conf, const string& ifn,
const list<string>& cmdv, TempDir& tdir,
const vector<string>& cmdv, TempDir& tdir,
string& tfile)
{
// Make sure tmp dir is empty. we guarantee this to filters
@ -141,7 +141,7 @@ static bool uncompressfile(RclConfig *conf, const string& ifn,
string cmd = cmdv.front();
// Substitute file name and temp dir in command elements
list<string>::const_iterator it = cmdv.begin();
vector<string>::const_iterator it = cmdv.begin();
++it;
vector<string> args;
map<char, string> subs;
@ -245,7 +245,7 @@ void FileInterner::init(const string &f, const struct stat *stp, RclConfig *cnf,
// Has mime: check for a compressed file. If so, create a
// temporary uncompressed file, and rerun the mime type
// identification, then do the rest with the temp file.
list<string>ucmd;
vector<string>ucmd;
if (m_cfg->getUncompressor(l_mime, ucmd)) {
// Check for compressed size limit
int maxkbs = -1;
@ -541,10 +541,10 @@ bool FileInterner::dataToTempFile(const string& dt, const string& mt,
void FileInterner::checkExternalMissing(const string& msg, const string& mt)
{
if (m_missingdatap && msg.find("RECFILTERROR") == 0) {
list<string> lerr;
vector<string> lerr;
stringToStrings(msg, lerr);
if (lerr.size() > 2) {
list<string>::iterator it = lerr.begin();
vector<string>::iterator it = lerr.begin();
lerr.erase(it++);
if (*it == "HELPERNOTFOUND") {
lerr.erase(it++);
@ -597,8 +597,8 @@ void FileInterner::getMissingFromDescription(FIMissingStore *st, const string& i
return;
// The "missing" file is text. Each line defines a missing filter
// and the list of mime types actually encountered that needed it (see method
// getMissingDescription())
// and the list of mime types actually encountered that needed it
// (see method getMissingDescription())
vector<string> lines;
stringToTokens(in, lines, "\n");
@ -1125,7 +1125,7 @@ bool FileInterner::isCompressed(const string& fn, RclConfig *cnf)
return false;
}
list<string>ucmd;
vector<string> ucmd;
if (cnf->getUncompressor(l_mime, ucmd)) {
return true;
}
@ -1149,7 +1149,7 @@ bool FileInterner::maybeUncompressToTemp(TempFile& temp, const string& fn,
return false;
}
list<string>ucmd;
vector<string>ucmd;
if (!cnf->getUncompressor(l_mime, ucmd)) {
return true;
}

View file

@ -86,8 +86,8 @@ bool MimeHandlerExec::next_document()
// Command name
string cmd = params.front();
// Build parameter list: delete cmd name and add the file name
list<string>::iterator it = params.begin();
// Build parameter vector: delete cmd name and add the file name
vector<string>::iterator it = params.begin();
vector<string>myparams(++it, params.end());
myparams.push_back(m_fn);
if (!m_ipath.empty())

View file

@ -18,8 +18,8 @@
#define _MH_EXEC_H_INCLUDED_
#include <string>
#include <list>
using std::list;
#include <vector>
using std::vector;
using std::string;
#include "mimehandler.h"
@ -43,9 +43,9 @@ class MimeHandlerExec : public RecollFilter {
// (no use to try and execute over and over something that's not
// here).
// Parameter list: this has been built by our creator, from config file
// Parameters: this has been built by our creator, from config file
// data. We always add the file name at the end before actual execution
list<string> params;
vector<string> params;
// Filter output type. The default for ext. filters is to output html,
// but some don't, in which case the type is defined in the config.
string cfgFilterOutputMtype;

View file

@ -51,7 +51,7 @@ bool MimeHandlerExecMultiple::startCmd()
string cmd = params.front();
// Build parameter list: delete cmd name
list<string>::iterator it = params.begin();
vector<string>::iterator it = params.begin();
vector<string>myparams(++it, params.end());
// Start filter

View file

@ -51,11 +51,11 @@ MimeHandlerMail::MimeHandlerMail(RclConfig *cnf, const string &mt)
{
// Look for additional headers to be processed as per config:
list<string> hdrnames =
vector<string> hdrnames =
m_config->getFieldSectNames("mail");
if (hdrnames.empty())
return;
for (list<string>::const_iterator it = hdrnames.begin();
for (vector<string>::const_iterator it = hdrnames.begin();
it != hdrnames.end(); it++) {
(void)m_config->getFieldConfParam(*it, "mail", m_addProcdHdrs[*it]);
}

View file

@ -294,17 +294,17 @@ void AdvSearch::fillFileTypes()
QStringList ql;
if (m_ignByCats == false) {
list<string> types = theconfig->getAllMimeTypes();
for (list<string>::iterator it = types.begin();
vector<string> types = theconfig->getAllMimeTypes();
for (vector<string>::iterator it = types.begin();
it != types.end(); it++) {
QString qs = QString::fromUtf8(it->c_str());
if (m_ignTypes.indexOf(qs) < 0)
ql.append(qs);
}
} else {
list<string> cats;
vector<string> cats;
theconfig->getMimeCategories(cats);
for (list<string>::const_iterator it = cats.begin();
for (vector<string>::const_iterator it = cats.begin();
it != cats.end(); it++) {
map<QString, QString>::const_iterator it1;
QString cat;
@ -321,7 +321,7 @@ void AdvSearch::fillFileTypes()
yesFiltypsLB->insertItems(0, ql);
}
// Save current list of ignored file types to prefs
// Save current set of ignored file types to prefs
void AdvSearch::saveFileTypes()
{
prefs.asearchIgnFilTyps = m_ignTypes;
@ -383,9 +383,9 @@ void AdvSearch::runSearch()
} else {
cat = (const char *)qcat.toUtf8();
}
list<string> types;
vector<string> types;
theconfig->getMimeCatTypes(cat, types);
for (list<string>::const_iterator it = types.begin();
for (vector<string>::const_iterator it = types.begin();
it != types.end(); it++) {
sdata->addFiletype(*it);
}
@ -419,7 +419,7 @@ void AdvSearch::runSearch()
QString current = subtreeCMB->currentText();
sdata->setTopdir((const char*)subtreeCMB->currentText().toUtf8(),
direxclCB->isChecked());
// Keep history list clean and sorted. Maybe there would be a
// Keep history clean and sorted. Maybe there would be a
// simpler way to do this
list<QString> entries;
for (int i = 0; i < subtreeCMB->count(); i++) {
@ -427,7 +427,7 @@ void AdvSearch::runSearch()
}
entries.push_back(subtreeCMB->currentText());
entries.sort();
unique(entries.begin(), entries.end());
entries.unique();
subtreeCMB->clear();
for (list<QString>::iterator it = entries.begin();
it != entries.end(); it++) {

View file

@ -296,10 +296,10 @@ ConfSubPanelW::ConfSubPanelW(QWidget *parent, ConfNull *config)
// customized in the system config like .thunderbird or
// .purple. This doesn't prevent them to add and customize them
// further.
list<string> allkeydirs = config->getSubKeys(true);
vector<string> allkeydirs = config->getSubKeys(true);
QStringList qls;
for (list<string>::const_iterator it = allkeydirs.begin();
for (vector<string>::const_iterator it = allkeydirs.begin();
it != allkeydirs.end(); it++) {
qls.push_back(QString::fromUtf8(it->c_str()));
}

View file

@ -133,7 +133,7 @@ bool maybeOpenDb(string &reason, bool force, bool *maindberror)
return true;
}
bool getStemLangs(list<string>& langs)
bool getStemLangs(vector<string>& langs)
{
string reason;
if (!maybeOpenDb(reason)) {

View file

@ -178,12 +178,12 @@ void RclMain::init()
bgrp->addButton(allRDB, bgrpid++);
connect(bgrp, SIGNAL(buttonClicked(int)), this, SLOT(catgFilter(int)));
allRDB->setChecked(true);
list<string> cats;
vector<string> cats;
theconfig->getGuiFilterNames(cats);
// Text for button 0 is not used. Next statement just avoids unused
// variable compiler warning for catg_strings
m_catgbutvec.push_back(catg_strings[0]);
for (list<string>::const_iterator it = cats.begin();
for (vector<string>::const_iterator it = cats.begin();
it != cats.end(); it++) {
QRadioButton *but = new QRadioButton(catgBGRP);
QString catgnm = QString::fromUtf8(it->c_str(), it->length());
@ -1089,12 +1089,12 @@ void RclMain::showActiveTypes()
}
// All types listed in mimeconf:
list<string> mtypesfromconfig = theconfig->getAllMimeTypes();
vector<string> mtypesfromconfig = theconfig->getAllMimeTypes();
// Intersect file system types with config types (those not in the
// config can be indexed by name, not by content)
set<string> mtypesfromdbconf;
for (list<string>::const_iterator it = mtypesfromconfig.begin();
for (vector<string>::const_iterator it = mtypesfromconfig.begin();
it != mtypesfromconfig.end(); it++) {
if (mtypesfromdb.find(*it) != mtypesfromdb.end())
mtypesfromdbconf.insert(*it);

View file

@ -31,7 +31,7 @@ extern bool maybeOpenDb(std::string &reason, bool force = true,
bool *maindberror = 0);
/** Retrieve configured stemming languages */
bool getStemLangs(list<string>& langs);
bool getStemLangs(vector<string>& langs);
extern RclConfig *theconfig;
extern RclConfig *thestableconfig;

View file

@ -66,12 +66,12 @@ void SpellW::init()
// Stemming language combobox
stemLangCMB->clear();
list<string> langs;
vector<string> langs;
if (!getStemLangs(langs)) {
QMessageBox::warning(0, "Recoll",
tr("error retrieving stemming languages"));
}
for (list<string>::const_iterator it = langs.begin();
for (vector<string>::const_iterator it = langs.begin();
it != langs.end(); it++) {
stemLangCMB->
addItem(QString::fromAscii(it->c_str(), it->length()));

View file

@ -140,13 +140,13 @@ void UIPrefsDialog::setFromPrefs()
stemLangCMB->clear();
stemLangCMB->addItem(g_stringNoStem);
stemLangCMB->addItem(g_stringAllStem);
list<string> langs;
vector<string> langs;
if (!getStemLangs(langs)) {
QMessageBox::warning(0, "Recoll",
tr("error retrieving stemming languages"));
}
int cur = prefs.queryStemLang == "" ? 0 : 1;
for (list<string>::const_iterator it = langs.begin();
for (vector<string>::const_iterator it = langs.begin();
it != langs.end(); it++) {
stemLangCMB->
addItem(QString::fromAscii(it->c_str(), it->length()));

View file

@ -98,7 +98,8 @@ bool DocSequenceDb::getEnclosing(Rcl::Doc& doc, Rcl::Doc& pdoc)
list<string> DocSequenceDb::expand(Rcl::Doc &doc)
{
setQuery();
return m_q->expand(doc);
vector<string> v = m_q->expand(doc);
return list<string>(v.begin(), v.end());
}
string DocSequenceDb::title()

View file

@ -44,10 +44,10 @@ bool RclDHistoryEntry::encode(string& value)
// Current entry format is "U time b64udi"
bool RclDHistoryEntry::decode(const string &value)
{
list<string> vall;
vector<string> vall;
stringToStrings(value, vall);
list<string>::const_iterator it = vall.begin();
vector<string>::const_iterator it = vall.begin();
udi.erase();
string fn, ipath;
switch (vall.size()) {

View file

@ -43,8 +43,8 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
int maxlen)
{
// Is this doc already in list ? If it is we remove the old entry
list<string> names = m_data.getNames(sk);
list<string>::const_iterator it;
vector<string> names = m_data.getNames(sk);
vector<string>::const_iterator it;
bool changed = false;
for (it = names.begin(); it != names.end(); it++) {
string oval;
@ -61,7 +61,7 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
}
}
// Maybe reget list
// Maybe reget things
if (changed)
names = m_data.getNames(sk);
@ -95,8 +95,8 @@ bool RclDynConf::insertNew(const string &sk, DynConfEntry &n, DynConfEntry &s,
bool RclDynConf::eraseAll(const string &sk)
{
list<string> names = m_data.getNames(sk);
list<string>::const_iterator it;
vector<string> names = m_data.getNames(sk);
vector<string>::const_iterator it;
for (it = names.begin(); it != names.end(); it++) {
m_data.erase(*it, sk);
}

View file

@ -98,8 +98,8 @@ template<typename Tp> list<Tp> RclDynConf::getList(const string &sk)
{
list<Tp> mlist;
Tp entry;
list<string> names = m_data.getNames(sk);
for (list<string>::const_iterator it = names.begin();
vector<string> names = m_data.getNames(sk);
for (vector<string>::const_iterator it = names.begin();
it != names.end(); it++) {
string value;
if (m_data.get(*it, value, sk)) {

View file

@ -70,9 +70,9 @@ bool DocSeqFiltered::setFiltSpec(DocSeqFiltSpec &filtspec)
string val = filtspec.values[i];
if (val.find("rclcat:") == 0) {
string catg = val.substr(7);
list<string> tps;
vector<string> tps;
m_config->getMimeCatTypes(catg, tps);
for (list<string>::const_iterator it = tps.begin();
for (vector<string>::const_iterator it = tps.begin();
it != tps.end(); it++) {
LOGDEB2(("Adding mime: [%s]\n", it->c_str()));
m_spec.orCrit(DocSeqFiltSpec::DSFS_MIMETYPE, *it);

View file

@ -82,10 +82,10 @@ static Rcl::SearchData *wasaQueryToRcl(RclConfig *config, WasaQuery *wasa,
"nor excl??";
return 0;
}
list<string> mtypes;
vector<string> mtypes;
if (config && config->getMimeCatTypes((*it)->m_value, mtypes)
&& !mtypes.empty()) {
for (list<string>::iterator mit = mtypes.begin();
for (vector<string>::iterator mit = mtypes.begin();
mit != mtypes.end(); mit++) {
if ((*it)->m_op == WasaQuery::OP_LEAF)
sdata->addFiletype(*mit);

View file

@ -217,8 +217,8 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
doc.xdocid = docid;
// Other, not predefined meta fields:
list<string> keys = parms.getNames(string());
for (list<string>::const_iterator it = keys.begin();
vector<string> keys = parms.getNames(string());
for (vector<string>::const_iterator it = keys.begin();
it != keys.end(); it++) {
if (doc.meta.find(*it) == doc.meta.end())
parms.get(*it, doc.meta[*it]);
@ -228,9 +228,9 @@ bool Db::Native::dbDataToRclDoc(Xapian::docid docid, std::string &data,
}
// Remove prefixes (caps) from a list of terms.
static void noPrefixList(const list<string>& in, list<string>& out)
static void noPrefixList(const vector<string>& in, vector<string>& out)
{
for (list<string>::const_iterator qit = in.begin();
for (vector<string>::const_iterator qit = in.begin();
qit != in.end(); qit++) {
if ('A' <= qit->at(0) && qit->at(0) <= 'Z') {
string term = *qit;
@ -252,10 +252,10 @@ static void noPrefixList(const list<string>& in, list<string>& out)
#define LOGABS LOGDEB2
#endif
#if 0
static void listList(const string& what, const list<string>&l)
static void listList(const string& what, const vector<string>&l)
{
string a;
for (list<string>::const_iterator it = l.begin(); it != l.end(); it++) {
for (vector<string>::const_iterator it = l.begin(); it != l.end(); it++) {
a = a + *it + " ";
}
LOGDEB(("%s: %s\n", what.c_str(), a.c_str()));
@ -273,10 +273,10 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
LOGDEB2(("makeAbstract:%d: maxlen %d wWidth %d\n", chron.ms(),
m_rcldb->m_synthAbsLen, m_rcldb->m_synthAbsWordCtxLen));
list<string> terms;
vector<string> terms;
{
list<string> iterms;
vector<string> iterms;
query->getMatchTerms(docid, iterms);
noPrefixList(iterms, terms);
if (terms.empty()) {
@ -289,13 +289,13 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
// Retrieve db-wide frequencies for the query terms (we do this once per
// query, using all the query terms, not only the document match terms)
if (query->m_nq->termfreqs.empty()) {
list<string> iqterms, qterms;
vector<string> iqterms, qterms;
query->getQueryTerms(iqterms);
noPrefixList(iqterms, qterms);
// listList("Query terms: ", qterms);
double doccnt = xrdb.get_doccount();
if (doccnt == 0) doccnt = 1;
for (list<string>::const_iterator qit = qterms.begin();
for (vector<string>::const_iterator qit = qterms.begin();
qit != qterms.end(); qit++) {
query->m_nq->termfreqs[*qit] = xrdb.get_termfreq(*qit) / doccnt;
LOGABS(("makeAbstract: [%s] db freq %.1e\n", qit->c_str(),
@ -312,7 +312,7 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
double totalweight = 0;
double doclen = xrdb.get_doclength(docid);
if (doclen == 0) doclen = 1;
for (list<string>::const_iterator qit = terms.begin();
for (vector<string>::const_iterator qit = terms.begin();
qit != terms.end(); qit++) {
Xapian::TermIterator term = xrdb.termlist_begin(docid);
term.skip_to(*qit);
@ -338,7 +338,7 @@ vector<string> Db::Native::makeAbstract(Xapian::docid docid, Query *query)
// Build a sorted by quality term list.
multimap<double, string> byQ;
for (list<string>::const_iterator qit = terms.begin();
for (vector<string>::const_iterator qit = terms.begin();
qit != terms.end(); qit++) {
if (termQcoefs.find(*qit) != termQcoefs.end())
byQ.insert(pair<double,string>(termQcoefs[*qit], *qit));
@ -1481,10 +1481,10 @@ bool Db::needUpdate(const string &udi, const string& sig)
// Return list of existing stem db languages
list<string> Db::getStemLangs()
vector<string> Db::getStemLangs()
{
LOGDEB(("Db::getStemLang\n"));
list<string> dirs;
vector<string> dirs;
if (m_ndb == 0 || m_ndb->m_isopen == false)
return dirs;
dirs = StemDb::getLangs(m_basedir);
@ -1724,7 +1724,7 @@ bool Db::stemExpand(const string &lang, const string &term,
list<string> dirs = m_extraDbs;
dirs.push_front(m_basedir);
for (list<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
list<string> more;
vector<string> more;
StemDb::stemExpand(*it, lang, term, more);
LOGDEB1(("Db::stemExpand: Got %d from %s\n",
more.size(), it->c_str()));

View file

@ -140,7 +140,7 @@ class Db {
}
/** List existing stemming databases */
std::list<std::string> getStemLangs();
std::vector<std::string> getStemLangs();
#ifdef TESTING_XAPIAN_SPELL
/** Return spelling suggestion */

View file

@ -19,7 +19,6 @@
#include <string.h>
#include <stdio.h>
#include <list>
#include <vector>
#include "xapian.h"
@ -240,7 +239,7 @@ bool Query::setQuery(RefCntr<SearchData> sdata)
}
bool Query::getQueryTerms(list<string>& terms)
bool Query::getQueryTerms(vector<string>& terms)
{
if (ISNULL(m_nq))
return false;
@ -261,11 +260,11 @@ bool Query::getQueryTerms(list<string>& terms)
return true;
}
bool Query::getMatchTerms(const Doc& doc, list<string>& terms)
bool Query::getMatchTerms(const Doc& doc, vector<string>& terms)
{
return getMatchTerms(doc.xdocid, terms);
}
bool Query::getMatchTerms(unsigned long xdocid, list<string>& terms)
bool Query::getMatchTerms(unsigned long xdocid, vector<string>& terms)
{
if (ISNULL(m_nq) || !m_nq->xenquire) {
LOGERR(("Query::getMatchTerms: no query opened\n"));
@ -421,10 +420,10 @@ bool Query::getDoc(int xapi, Doc &doc)
return m_db->m_ndb->dbDataToRclDoc(docid, data, doc);
}
list<string> Query::expand(const Doc &doc)
vector<string> Query::expand(const Doc &doc)
{
LOGDEB(("Rcl::Query::expand()\n"));
list<string> res;
vector<string> res;
if (ISNULL(m_nq) || !m_nq->xenquire) {
LOGERR(("Query::expand: no query opened\n"));
return res;

View file

@ -17,12 +17,10 @@
#ifndef _rclquery_h_included_
#define _rclquery_h_included_
#include <string>
#include <list>
#include <vector>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::vector;
#endif
@ -72,14 +70,14 @@ class Query {
bool getDoc(int i, Doc &doc);
/** Get possibly expanded list of query terms */
bool getQueryTerms(list<string>& terms);
bool getQueryTerms(vector<string>& terms);
/** Return a list of terms which matched for a specific result document */
bool getMatchTerms(const Doc& doc, list<string>& terms);
bool getMatchTerms(unsigned long xdocid, list<string>& terms);
bool getMatchTerms(const Doc& doc, vector<string>& terms);
bool getMatchTerms(unsigned long xdocid, vector<string>& terms);
/** Expand query to look for documents like the one passed in */
list<string> expand(const Doc &doc);
vector<string> expand(const Doc &doc);
/** Return the Db we're set for */
Db *whatDb();

View file

@ -151,15 +151,15 @@ bool SearchData::expandFileTypes(RclConfig *cfg, vector<string>& tps)
return false;
}
vector<string> exptps;
list<string> alltypes = cfg->getAllMimeTypes();
vector<string> alltypes = cfg->getAllMimeTypes();
for (vector<string>::iterator it = tps.begin(); it != tps.end(); it++) {
if (cfg->isMimeCategory(*it)) {
list<string>tps;
vector<string>tps;
cfg->getMimeCatTypes(*it, tps);
exptps.insert(exptps.end(), tps.begin(), tps.end());
} else {
for (list<string>::const_iterator ait = alltypes.begin();
for (vector<string>::const_iterator ait = alltypes.begin();
ait != alltypes.end(); ait++) {
if (fnmatch(it->c_str(), ait->c_str(), FNM_CASEFOLD)
!= FNM_NOMATCH) {

View file

@ -48,11 +48,11 @@ static string stemdbname(const string& dbdir, const string& lang)
return path_cat(dbdir, cstr_stemdirstem + lang);
}
list<string> getLangs(const string& dbdir)
vector<string> getLangs(const string& dbdir)
{
string pattern = cstr_stemdirstem + "*";
list<string> dirs = path_dirglob(dbdir, pattern);
for (list<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
vector<string> dirs = path_dirglob(dbdir, pattern);
for (vector<string>::iterator it = dirs.begin(); it != dirs.end(); it++) {
*it = path_basename(*it);
*it = it->substr(cstr_stemdirstem.length(), string::npos);
}
@ -262,10 +262,10 @@ bool createDb(Xapian::Database& xdb, const string& dbdir, const string& lang)
return true;
}
static string stringlistdisp(const list<string>& sl)
static string stringlistdisp(const vector<string>& sl)
{
string s;
for (list<string>::const_iterator it = sl.begin(); it!= sl.end(); it++)
for (vector<string>::const_iterator it = sl.begin(); it!= sl.end(); it++)
s += "[" + *it + "] ";
if (!s.empty())
s.erase(s.length()-1);
@ -279,7 +279,7 @@ static string stringlistdisp(const list<string>& sl)
static bool stemExpandOne(const std::string& dbdir,
const std::string& lang,
const std::string& term,
list<string>& result)
vector<string>& result)
{
try {
Xapian::Stem stemmer(lang);
@ -347,19 +347,19 @@ static bool stemExpandOne(const std::string& dbdir,
bool stemExpand(const std::string& dbdir,
const std::string& langs,
const std::string& term,
list<string>& result)
vector<string>& result)
{
list<string> llangs;
stringToStrings(langs, llangs);
for (list<string>::const_iterator it = llangs.begin();
it != llangs.end(); it++) {
list<string> oneexp;
vector<string> oneexp;
stemExpandOne(dbdir, *it, term, oneexp);
result.insert(result.end(), oneexp.begin(), oneexp.end());
}
result.sort();
result.unique();
sort(result.begin(), result.end());
unique(result.begin(), result.end());
return true;
}

View file

@ -24,20 +24,16 @@
/// Stem databases are stored as separate xapian databases (used as an
/// Isam method), in subdirectories of the index.
#include <list>
#include <vector>
#include <string>
#include <xapian.h>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
namespace Rcl {
namespace StemDb {
#endif // NO_NAMESPACES
/// Get languages of existing stem databases
extern std::list<std::string> getLangs(const std::string& dbdir);
extern std::vector<std::string> getLangs(const std::string& dbdir);
/// Delete stem database for given language
extern bool deleteDb(const std::string& dbdir, const std::string& lang);
/// Create stem database for given language
@ -47,10 +43,8 @@ extern bool createDb(Xapian::Database& xdb,
extern bool stemExpand(const std::string& dbdir,
const std::string& langs,
const std::string& term,
list<string>& result);
#ifndef NO_NAMESPACES
std::vector<std::string>& result);
}
}
#endif // NO_NAMESPACES
#endif /* _STEMDB_H_INCLUDED_ */

View file

@ -217,7 +217,7 @@ public:
}
}
// Return list of candidate offsets for udi (possibly several
// Return vector of candidate offsets for udi (possibly several
// because there may be hash collisions, and also multiple
// instances).
bool khFind(const string& udi, vector<off_t>& ofss)
@ -262,10 +262,10 @@ public:
}
return true;
}
// Clear entries for list of udi/offs
bool khClear(const list<pair<string, off_t> >& udis)
// Clear entries for vector of udi/offs
bool khClear(const vector<pair<string, off_t> >& udis)
{
for (list<pair<string, off_t> >::const_iterator it = udis.begin();
for (vector<pair<string, off_t> >::const_iterator it = udis.begin();
it != udis.end(); it++)
khClear(*it);
return true;
@ -754,7 +754,7 @@ bool CirCache::get(const string& udi, string& dic, string& data, int instance)
if (!fudi.compare(udi)) {
// Found one, memorize offset. Done if instance
// matches, else go on. If instance is -1 need to
// go to the end of the list anyway
// go to the end anyway
d_good = d;
o_good = *it;
if (finst == instance) {
@ -849,7 +849,7 @@ class CCScanHookSpacer : public CCScanHook {
public:
UINT sizewanted;
UINT sizeseen;
list<pair<string, off_t> > squashed_udis;
vector<pair<string, off_t> > squashed_udis;
CCScanHookSpacer(int sz)
: sizewanted(sz), sizeseen(0) {assert(sz > 0);}

View file

@ -28,7 +28,7 @@
* an exec (security, pipe control, the possibility that a bug will trigger
* an unwanted write, etc.)
*
* A process has currently no POSIX way to determine the list of open file
* A process has currently no POSIX way to determine the set of open file
* descriptors or at least the highest value. Closing all files (except a few),
* thus implies performing a close() system call on each entry up to the
* maximum, which can be both relatively difficult to determine, and quite
@ -46,7 +46,7 @@
* System interfaces:
* FreeBSD:
* - Has a closefrom() system call as of release 7.x around Sep 2009
* - Has a /dev/fd, directory which lists the current process' open
* - Has a /dev/fd, directory which shows the current process' open
* descriptors. Only descriptors 0, 1, 2 are shown except if
* fdescfs is mounted which it is not by default
*

View file

@ -37,7 +37,6 @@
#ifndef NO_NAMESPACES
using namespace std;
using std::list;
#endif // NO_NAMESPACES
#ifndef MIN
@ -346,7 +345,7 @@ int ConfSimple::i_set(const std::string &nm, const std::string &value,
// at begin() for a null subkey, or just behind the subkey
// entry. End is either the next subkey entry, or the end of
// list. We insert the new entry just before end.
list<ConfLine>::iterator start, fin;
vector<ConfLine>::iterator start, fin;
if (sk.empty()) {
start = m_order.begin();
LOGDEB((stderr,"ConfSimple::i_set: null sk, start at top of order\n"));
@ -367,7 +366,7 @@ int ConfSimple::i_set(const std::string &nm, const std::string &value,
// The null subkey has no entry (maybe it should)
if (!sk.empty())
start++;
for (list<ConfLine>::iterator it = start; it != m_order.end(); it++) {
for (vector<ConfLine>::iterator it = start; it != m_order.end(); it++) {
if (it->m_kind == ConfLine::CFL_SK) {
fin = it;
break;
@ -402,8 +401,8 @@ int ConfSimple::erase(const string &nm, const string &sk)
int ConfSimple::eraseKey(const string &sk)
{
list<string>nms = getNames(sk);
for (list<string>::iterator it = nms.begin(); it != nms.end(); it++) {
vector<string> nms = getNames(sk);
for (vector<string>::iterator it = nms.begin(); it != nms.end(); it++) {
erase(*it, sk);
}
return write();
@ -460,13 +459,13 @@ bool ConfSimple::write()
// Write out the tree in configuration file format:
// This does not check holdWrites, this is done by write(void), which
// lets ie: listall work even when holdWrites is set
// lets ie: showall work even when holdWrites is set
bool ConfSimple::write(ostream& out) const
{
if (!ok())
return false;
string sk;
for (list<ConfLine>::const_iterator it = m_order.begin();
for (vector<ConfLine>::const_iterator it = m_order.begin();
it != m_order.end(); it++) {
switch(it->m_kind) {
case ConfLine::CFL_COMMENT:
@ -509,38 +508,38 @@ bool ConfSimple::write(ostream& out) const
return true;
}
void ConfSimple::listall()
void ConfSimple::showall()
{
if (!ok())
return;
write(std::cout);
}
list<string> ConfSimple::getNames(const string &sk, const char *pattern)
vector<string> ConfSimple::getNames(const string &sk, const char *pattern)
{
std::list<string> mylist;
vector<string> mylist;
if (!ok())
return mylist;
map<string, map<string, string> >::iterator ss;
if ((ss = m_submaps.find(sk)) == m_submaps.end()) {
return mylist;
}
mylist.reserve(ss->second.size());
map<string, string>::const_iterator it;
for (it = ss->second.begin();it != ss->second.end();it++) {
for (it = ss->second.begin(); it != ss->second.end(); it++) {
if (pattern && FNM_NOMATCH == fnmatch(pattern, it->first.c_str(), 0))
continue;
mylist.push_back(it->first);
}
mylist.sort();
mylist.unique();
return mylist;
}
list<string> ConfSimple::getSubKeys()
vector<string> ConfSimple::getSubKeys()
{
std::list<string> mylist;
vector<string> mylist;
if (!ok())
return mylist;
mylist.reserve(m_submaps.size());
map<string, map<string, string> >::iterator ss;
for (ss = m_submaps.begin(); ss != m_submaps.end(); ss++) {
mylist.push_back(ss->first);
@ -550,8 +549,8 @@ list<string> ConfSimple::getSubKeys()
bool ConfSimple::hasNameAnywhere(const string& nm)
{
list<string>keys = getSubKeys();
for (list<string>::const_iterator it = keys.begin();
vector<string>keys = getSubKeys();
for (vector<string>::const_iterator it = keys.begin();
it != keys.end(); it++) {
string val;
if (get(nm, val, *it))
@ -603,7 +602,7 @@ int ConfTree::get(const std::string &name, string &value, const string &sk)
#include <string.h>
#include <sstream>
#include <iostream>
#include <list>
#include <vector>
#include "conftree.h"
#include "smallut.h"
@ -700,7 +699,7 @@ const char *longvalue =
void memtest(ConfSimple &c)
{
cout << "Initial:" << endl;
c.listall();
c.showall();
if (c.set("nom", "avec nl \n 2eme ligne", "")) {
fprintf(stderr, "set with embedded nl succeeded !\n");
exit(1);
@ -719,7 +718,7 @@ void memtest(ConfSimple &c)
}
cout << "Final:" << endl;
c.listall();
c.showall();
}
bool readwrite(ConfNull *conf)
@ -924,7 +923,7 @@ int main(int argc, char **argv)
if (op_flags & OPT_U) {
exit(!complex_updates(argv[0]));
}
list<string> flist;
vector<string> flist;
while (argc--) {
flist.push_back(*argv++);
}
@ -951,8 +950,8 @@ int main(int argc, char **argv)
cerr << "conf init error" << endl;
exit(1);
}
list<string>lst = conf->getSubKeys();
for (list<string>::const_iterator it = lst.begin();
vector<string>lst = conf->getSubKeys();
for (vector<string>::const_iterator it = lst.begin();
it != lst.end(); it++) {
cout << *it << endl;
}
@ -975,13 +974,13 @@ int main(int argc, char **argv)
exit(1);
}
cout << "source: [" << source << "]" << endl;
list<string> strings;
vector<string> strings;
if (!stringToStrings(source, strings)) {
cerr << "parse failed" << endl;
exit(1);
}
for (list<string>::iterator it = strings.begin();
for (vector<string>::iterator it = strings.begin();
it != strings.end(); it++) {
cout << "[" << *it << "]" << endl;
}
@ -992,17 +991,17 @@ int main(int argc, char **argv)
exit(1);
}
printf("LIST\n");
conf->listall();
conf->showall();
//printf("WALK\n");conf->sortwalk(mywalker, 0);
printf("\nNAMES in global space:\n");
list<string> names = conf->getNames("");
for (list<string>::iterator it = names.begin();
vector<string> names = conf->getNames("");
for (vector<string>::iterator it = names.begin();
it!=names.end(); it++)
cout << *it << " ";
cout << endl;
printf("\nNAMES in global space matching t* \n");
names = conf->getNames("", "t*");
for (list<string>::iterator it = names.begin();
for (vector<string>::iterator it = names.begin();
it!=names.end(); it++)
cout << *it << " ";
cout << endl;

View file

@ -51,7 +51,7 @@
#include <string>
#include <map>
#include <list>
#include <vector>
// rh7.3 likes iostream better...
#if defined(__GNUC__) && __GNUC__ < 3
@ -63,7 +63,7 @@
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::vector;
using std::map;
using std::istream;
using std::ostream;
@ -100,12 +100,12 @@ public:
virtual int set(const string &nm, const string &val,
const string &sk = string()) = 0;
virtual bool ok() const = 0;
virtual list<string> getNames(const string &sk, const char* = 0) = 0;
virtual vector<string> getNames(const string &sk, const char* = 0) = 0;
virtual int erase(const string &, const string &) = 0;
virtual int eraseKey(const string &) = 0;
virtual void listall() {};
virtual list<string> getSubKeys() = 0;
virtual list<string> getSubKeys(bool) = 0;
virtual void showall() {};
virtual vector<string> getSubKeys() = 0;
virtual vector<string> getSubKeys(bool) = 0;
virtual bool holdWrites(bool) = 0;
virtual bool sourceChanged() = 0;
};
@ -198,11 +198,11 @@ public:
const string &val),
void *clidata);
/** List all values to stdout */
virtual void listall();
/** Print all values to stdout */
virtual void showall();
/** Return all names in given submap. */
virtual list<string> getNames(const string &sk, const char *pattern = 0);
virtual vector<string> getNames(const string &sk, const char *pattern = 0);
/** Check if name is present in any submap. This is relatively expensive
* but useful for saving further processing sometimes */
@ -211,8 +211,8 @@ public:
/**
* Return all subkeys
*/
virtual list<string> getSubKeys(bool) {return getSubKeys();}
virtual list<string> getSubKeys();
virtual vector<string> getSubKeys(bool) {return getSubKeys();}
virtual vector<string> getSubKeys();
/** Test for subkey existence */
virtual bool hasSubKey(const string& sk)
{
@ -263,7 +263,7 @@ private:
// Presentation data. We keep the comments, empty lines and
// variable and subkey ordering information in there (for
// rewriting the file while keeping hand-edited information)
list<ConfLine> m_order;
vector<ConfLine> m_order;
// Control if we're writing to the backing store
bool m_holdWrites;
@ -323,7 +323,7 @@ public:
* have a central config, with possible overrides from more specific
* (ie personal) ones.
*
* Notes: it's ok for some of the files in the list to not exist, but the last
* Notes: it's ok for some of the files not to exist, but the last
* one must or we generate an error. We open all trees readonly, except the
* topmost one if requested. All writes go to the topmost file. Note that
* erase() won't work except for parameters only defined in the topmost
@ -331,18 +331,18 @@ public:
*/
template <class T> class ConfStack : public ConfNull {
public:
/// Construct from list of configuration file names. The earler
/// Construct from configuration file names. The earler
/// files in have priority when fetching values. Only the first
/// file will be updated if ro is false and set() is used.
ConfStack(const list<string> &fns, bool ro = true)
ConfStack(const vector<string> &fns, bool ro = true)
{
construct(fns, ro);
}
/// Construct out of single file name and list of directories
ConfStack(const string& nm, const list<string>& dirs, bool ro = true)
/// Construct out of single file name and multiple directories
ConfStack(const string& nm, const vector<string>& dirs, bool ro = true)
{
list<string> fns;
for (list<string>::const_iterator it = dirs.begin();
vector<string> fns;
for (vector<string>::const_iterator it = dirs.begin();
it != dirs.end(); it++){
fns.push_back(path_cat(*it, nm));
}
@ -374,7 +374,7 @@ public:
virtual bool sourceChanged()
{
typename list<T*>::const_iterator it;
typename vector<T*>::const_iterator it;
for (it = m_confs.begin();it != m_confs.end();it++) {
if ((*it)->sourceChanged())
return true;
@ -384,7 +384,7 @@ public:
virtual int get(const string &name, string &value, const string &sk) const
{
typename list<T*>::const_iterator it;
typename vector<T*>::const_iterator it;
for (it = m_confs.begin();it != m_confs.end();it++) {
if ((*it)->get(name, value, sk))
return true;
@ -394,7 +394,7 @@ public:
virtual bool hasNameAnywhere(const string& nm)
{
typename list<T*>::iterator it;
typename vector<T*>::iterator it;
for (it = m_confs.begin();it != m_confs.end();it++) {
if ((*it)->hasNameAnywhere(nm))
return true;
@ -411,7 +411,7 @@ public:
// Avoid adding unneeded entries: if the new value matches the
// one out from the deeper configs, erase or dont add it
// from/to the topmost file
typename list<T*>::iterator it = m_confs.begin();
typename vector<T*>::iterator it = m_confs.begin();
it++;
while (it != m_confs.end()) {
string value;
@ -445,49 +445,49 @@ public:
return m_confs.front()->holdWrites(on);
}
virtual list<string> getNames(const string &sk, const char *pattern = 0)
virtual vector<string> getNames(const string &sk, const char *pattern = 0)
{
return getNames1(sk, pattern, false);
}
virtual list<string> getNamesShallow(const string &sk, const char *patt = 0)
virtual vector<string> getNamesShallow(const string &sk, const char *patt = 0)
{
return getNames1(sk, patt, true);
}
virtual list<string> getNames1(const string &sk, const char *pattern,
virtual vector<string> getNames1(const string &sk, const char *pattern,
bool shallow)
{
list<string> nms;
typename list<T*>::iterator it;
vector<string> nms;
typename vector<T*>::iterator it;
bool skfound = false;
for (it = m_confs.begin();it != m_confs.end(); it++) {
if ((*it)->hasSubKey(sk)) {
skfound = true;
list<string> lst = (*it)->getNames(sk, pattern);
vector<string> lst = (*it)->getNames(sk, pattern);
nms.insert(nms.end(), lst.begin(), lst.end());
}
if (shallow && skfound)
break;
}
nms.sort();
nms.unique();
sort(nms.begin(), nms.end());
unique(nms.begin(), nms.end());
return nms;
}
virtual list<string> getSubKeys(){return getSubKeys(false);}
virtual list<string> getSubKeys(bool shallow)
virtual vector<string> getSubKeys(){return getSubKeys(false);}
virtual vector<string> getSubKeys(bool shallow)
{
list<string> sks;
typename list<T*>::iterator it;
vector<string> sks;
typename vector<T*>::iterator it;
for (it = m_confs.begin();it != m_confs.end(); it++) {
list<string> lst;
vector<string> lst;
lst = (*it)->getSubKeys();
sks.insert(sks.end(), lst.begin(), lst.end());
if (shallow)
break;
}
sks.sort();
sks.unique();
sort(sks.begin(), sks.end());
unique(sks.begin(), sks.end());
return sks;
}
@ -495,11 +495,11 @@ public:
private:
bool m_ok;
list<T*> m_confs;
vector<T*> m_confs;
/// Reset to pristine
void clear() {
typename list<T*>::iterator it;
typename vector<T*>::iterator it;
for (it = m_confs.begin();it != m_confs.end();it++) {
delete (*it);
}
@ -509,16 +509,16 @@ private:
/// Common code to initialize from existing object
void init_from(const ConfStack &rhs) {
if ((m_ok = rhs.m_ok)) {
typename list<T*>::const_iterator it;
typename vector<T*>::const_iterator it;
for (it = rhs.m_confs.begin();it != rhs.m_confs.end();it++) {
m_confs.push_back(new T(**it));
}
}
}
/// Common construct from file list code
void construct(const list<string> &fns, bool ro) {
list<string>::const_iterator it;
/// Common construct from file names code
void construct(const vector<string> &fns, bool ro) {
vector<string>::const_iterator it;
bool lastok = false;
for (it = fns.begin(); it != fns.end(); it++) {
T* p = new T(it->c_str(), ro);

View file

@ -28,10 +28,8 @@
#include <string>
#include <set>
#include <list>
using std::set;
using std::string;
using std::list;
#include "debuglog.h"
#include "pathut.h"

View file

@ -28,7 +28,8 @@
#include <algorithm>
#include <sstream>
#include <list>
#include <vector>
#include <deque>
#include <set>
#include "cstr.h"
@ -60,11 +61,11 @@ class FsTreeWalker::Internal {
int options;
int depthswitch;
stringstream reason;
list<string> skippedNames;
list<string> skippedPaths;
vector<string> skippedNames;
vector<string> skippedPaths;
// When doing Breadth or FilesThenDirs traversal, we keep a list
// of directory paths to be processed, and we do not recurse.
list<string> dirs;
deque<string> dirs;
int errors;
set<DirId> donedirs;
void logsyserr(const char *call, const string &param)
@ -119,15 +120,14 @@ bool FsTreeWalker::addSkippedName(const string& pattern)
data->skippedNames.push_back(pattern);
return true;
}
bool FsTreeWalker::setSkippedNames(const list<string> &patterns)
bool FsTreeWalker::setSkippedNames(const vector<string> &patterns)
{
data->skippedNames = patterns;
return true;
}
bool FsTreeWalker::inSkippedNames(const string& name)
{
list<string>::const_iterator it;
for (it = data->skippedNames.begin();
for (vector<string>::const_iterator it = data->skippedNames.begin();
it != data->skippedNames.end(); it++) {
if (fnmatch(it->c_str(), name.c_str(), 0) == 0) {
return true;
@ -144,10 +144,10 @@ bool FsTreeWalker::addSkippedPath(const string& ipath)
data->skippedPaths.push_back(path);
return true;
}
bool FsTreeWalker::setSkippedPaths(const list<string> &paths)
bool FsTreeWalker::setSkippedPaths(const vector<string> &paths)
{
data->skippedPaths = paths;
for (list<string>::iterator it = data->skippedPaths.begin();
for (vector<string>::iterator it = data->skippedPaths.begin();
it != data->skippedPaths.end(); it++)
if (!(data->options & FtwNoCanon))
*it = path_canon(*it);
@ -160,8 +160,8 @@ bool FsTreeWalker::inSkippedPaths(const string& path, bool ckparents)
if (ckparents)
fnmflags |= FNM_LEADING_DIR;
#endif
list<string>::const_iterator it;
for (it = data->skippedPaths.begin();
for (vector<string>::const_iterator it = data->skippedPaths.begin();
it != data->skippedPaths.end(); it++) {
#ifndef FNM_LEADING_DIR
if (ckparents) {
@ -217,8 +217,8 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
}
// Breadth first of filesThenDirs semi-depth first order
// Managing lists of directories to be visited later, in breadth or
// depth order. Null marker are inserted in the list to indicate
// Managing queues of directories to be visited later, in breadth or
// depth order. Null marker are inserted in the queue to indicate
// father directory changes (avoids computing parents all the time).
data->dirs.push_back(top);
Status status;
@ -226,7 +226,7 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
string dir, nfather;
if (data->options & (FtwTravBreadth|FtwTravBreadthThenDepth)) {
// Breadth first, pop and process an older dir at the
// front of the list. This will add any child dirs at the
// front of the queue. This will add any child dirs at the
// back
dir = data->dirs.front();
data->dirs.pop_front();
@ -279,7 +279,7 @@ FsTreeWalker::Status FsTreeWalker::walk(const string& _top,
return errno == ENOENT ? FtwOk : FtwError;
}
// iwalk will not recurse in this case, just process file entries
// and append subdir entries to the list.
// and append subdir entries to the queue.
status = iwalk(dir, &st, cb);
if (status != FtwOk)
return status;
@ -497,8 +497,8 @@ Usage(void)
int main(int argc, const char **argv)
{
list<string> patterns;
list<string> paths;
vector<string> patterns;
vector<string> paths;
thisprog = argv[0];
argc--; argv++;

View file

@ -18,11 +18,10 @@
#define _FSTREEWALK_H_INCLUDED_
#include <string>
#include <list>
#include <vector>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::vector;
#endif
class FsTreeWalkerCB;
@ -92,18 +91,17 @@ class FsTreeWalker {
int getErrCnt();
/**
* Add a pattern to the list of things (file or dir) to be ignored
* (ie: #* , *~)
* Add a pattern (file or dir) to be ignored (ie: #* , *~)
*/
bool addSkippedName(const string &pattern);
/** Set the ignored patterns list */
bool setSkippedNames(const list<string> &patlist);
/** Set the ignored patterns set */
bool setSkippedNames(const vector<string> &patterns);
/** Same for skipped paths: this are paths, not names, under which we
do not descend (ie: /home/me/.recoll) */
bool addSkippedPath(const string &path);
/** Set the ignored paths list */
bool setSkippedPaths(const list<string> &pathlist);
bool setSkippedPaths(const vector<string> &patterns);
/** Test if path/name should be skipped. This can be used independantly of
* an actual tree walk */

View file

@ -37,14 +37,6 @@ using namespace std;
* to separate messages, that we don't recognize currently
*/
std::list<string> idFileAllTypes()
{
std::list<string> lst;
lst.push_back("text/x-mail");
lst.push_back("message/rfc822");
return lst;
}
// Mail headers we compare to:
static const char *mailhs[] = {"From: ", "Received: ", "Message-Id: ", "To: ",
"Date: ", "Subject: ", "Status: ",

View file

@ -18,7 +18,6 @@
#define _IDFILE_H_INCLUDED_
#include <string>
#include <list>
// Look at data inside file or string, and return mime type or empty string.
//
@ -28,7 +27,4 @@
extern std::string idFile(const char *fn);
extern std::string idFileMem(const std::string& data);
// Return all types known to us
extern std::list<std::string> idFileAllTypes();
#endif /* _IDFILE_H_INCLUDED_ */

View file

@ -47,11 +47,9 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <stack>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::stack;
#endif /* NO_NAMESPACES */
@ -363,10 +361,10 @@ extern string path_canon(const string &is)
#include <glob.h>
#include <sys/stat.h>
list<string> path_dirglob(const string &dir,
const string pattern)
vector<string> path_dirglob(const string &dir,
const string pattern)
{
list<string> res;
vector<string> res;
glob_t mglob;
string mypat=path_cat(dir, pattern);
if (glob(mypat.c_str(), 0, 0, &mglob)) {
@ -673,7 +671,7 @@ int main(int argc, const char **argv)
thisprog = *argv++;argc--;
string s;
list<string>::const_iterator it;
vector<string>::const_iterator it;
#if 0
for (unsigned int i = 0;i < sizeof(tstvec) / sizeof(char *); i++) {
cout << tstvec[i] << " Father " << path_getfather(tstvec[i]) << endl;
@ -713,7 +711,7 @@ int main(int argc, const char **argv)
}
string dir = *argv++;argc--;
string pattern = *argv++;argc--;
list<string> matched = path_dirglob(dir, pattern);
vector<string> matched = path_dirglob(dir, pattern);
for (it = matched.begin(); it != matched.end();it++) {
cout << *it << endl;
}

View file

@ -19,12 +19,12 @@
#include <unistd.h>
#include <string>
#include <list>
#include <vector>
#include "refcntr.h"
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::vector;
#endif
/// Add a / at the end if none there yet.
@ -46,9 +46,9 @@ extern string path_tildexpand(const string &s);
extern string path_absolute(const string &s);
/// Clean up path by removing duplicated / and resolving ../ + make it absolute
extern string path_canon(const string &s);
/// Use glob(3) to return a list of file names matching pattern inside dir
extern list<string> path_dirglob(const string &dir,
const string pattern);
/// Use glob(3) to return the file names matching pattern inside dir
extern vector<string> path_dirglob(const string &dir,
const string pattern);
/// Encode according to rfc 1738
extern string url_encode(const string& url,
string::size_type offs = 0);

View file

@ -32,6 +32,7 @@
#include <string>
#include <iostream>
#include <list>
#include "smallut.h"
#include "utf8iter.h"

View file

@ -20,14 +20,12 @@
#include <stdlib.h>
#include <string>
#include <list>
#include <vector>
#include <map>
#include <set>
#ifndef NO_NAMESPACES
using std::string;
using std::list;
using std::vector;
using std::map;
using std::set;