cosmetic: add m_ prefix to private vars

This commit is contained in:
dockes 2006-04-04 09:34:11 +00:00
parent dbd3f570ba
commit f76d235b6d
2 changed files with 51 additions and 50 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: indexer.cpp,v 1.27 2006-03-29 11:18:14 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: indexer.cpp,v 1.28 2006-04-04 09:34:10 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -52,14 +52,14 @@ using namespace std;
DbIndexer::~DbIndexer() { DbIndexer::~DbIndexer() {
// Maybe clean up temporary directory // Maybe clean up temporary directory
if (tmpdir.length()) { if (m_tmpdir.length()) {
wipedir(tmpdir); wipedir(m_tmpdir);
if (rmdir(tmpdir.c_str()) < 0) { if (rmdir(m_tmpdir.c_str()) < 0) {
LOGERR(("DbIndexer::~DbIndexer: cannot clear temp dir %s\n", LOGERR(("DbIndexer::~DbIndexer: cannot clear temp dir %s\n",
tmpdir.c_str())); m_tmpdir.c_str()));
} }
} }
db.close(); m_db.close();
} }
// Index each directory in the topdirs for a given db // Index each directory in the topdirs for a given db
@ -71,24 +71,24 @@ bool DbIndexer::indexDb(bool resetbefore, list<string> *topdirs)
for (list<string>::const_iterator it = topdirs->begin(); for (list<string>::const_iterator it = topdirs->begin();
it != topdirs->end(); it++) { it != topdirs->end(); it++) {
LOGDEB(("DbIndexer::index: Indexing %s into %s\n", it->c_str(), LOGDEB(("DbIndexer::index: Indexing %s into %s\n", it->c_str(),
dbdir.c_str())); m_dbdir.c_str()));
// Set the current directory in config so that subsequent // Set the current directory in config so that subsequent
// getConfParams() will get local values // getConfParams() will get local values
config->setKeyDir(*it); m_config->setKeyDir(*it);
// Set up skipped patterns for this subtree. This probably should be // Set up skipped patterns for this subtree. This probably should be
// done in the directory change code in processone() instead. // done in the directory change code in processone() instead.
walker.clearSkippedNames(); m_walker.clearSkippedNames();
string skipped; string skipped;
if (config->getConfParam("skippedNames", skipped)) { if (m_config->getConfParam("skippedNames", skipped)) {
list<string> skpl; list<string> skpl;
stringToStrings(skipped, skpl); stringToStrings(skipped, skpl);
walker.setSkippedNames(skpl); m_walker.setSkippedNames(skpl);
} }
// Walk the directory tree // Walk the directory tree
if (walker.walk(*it, *this) != FsTreeWalker::FtwOk) { if (m_walker.walk(*it, *this) != FsTreeWalker::FtwOk) {
LOGERR(("DbIndexer::index: error while indexing %s\n", LOGERR(("DbIndexer::index: error while indexing %s\n",
it->c_str())); it->c_str()));
return false; return false;
@ -97,32 +97,32 @@ bool DbIndexer::indexDb(bool resetbefore, list<string> *topdirs)
// Get rid of all database entries that don't exist in the // Get rid of all database entries that don't exist in the
// filesystem anymore. // filesystem anymore.
db.purge(); m_db.purge();
// Create stemming databases. We also remove those which are not // Create stemming databases. We also remove those which are not
// configured. // configured.
string slangs; string slangs;
if (config->getConfParam("indexstemminglanguages", slangs)) { if (m_config->getConfParam("indexstemminglanguages", slangs)) {
list<string> langs; list<string> langs;
stringToStrings(slangs, langs); stringToStrings(slangs, langs);
// Get the list of existing stem dbs from the database (some may have // Get the list of existing stem dbs from the database (some may have
// been manually created, we just keep those from the config // been manually created, we just keep those from the config
list<string> dblangs = db.getStemLangs(); list<string> dblangs = m_db.getStemLangs();
list<string>::const_iterator it; list<string>::const_iterator it;
for (it = dblangs.begin(); it != dblangs.end(); it++) { for (it = dblangs.begin(); it != dblangs.end(); it++) {
if (find(langs.begin(), langs.end(), *it) == langs.end()) if (find(langs.begin(), langs.end(), *it) == langs.end())
db.deleteStemDb(*it); m_db.deleteStemDb(*it);
} }
for (it = langs.begin(); it != langs.end(); it++) { for (it = langs.begin(); it != langs.end(); it++) {
db.createStemDb(*it); m_db.createStemDb(*it);
} }
} }
// The close would be done in our destructor, but we want status here // The close would be done in our destructor, but we want status here
if (!db.close()) { if (!m_db.close()) {
LOGERR(("DbIndexer::index: error closing database in %s\n", LOGERR(("DbIndexer::index: error closing database in %s\n",
dbdir.c_str())); m_dbdir.c_str()));
return false; return false;
} }
return true; return true;
@ -130,12 +130,12 @@ bool DbIndexer::indexDb(bool resetbefore, list<string> *topdirs)
bool DbIndexer::init(bool resetbefore) bool DbIndexer::init(bool resetbefore)
{ {
if (!maketmpdir(tmpdir)) { if (!maketmpdir(m_tmpdir)) {
LOGERR(("DbIndexer: cannot create temporary directory\n")); LOGERR(("DbIndexer: cannot create temporary directory\n"));
return false; return false;
} }
if (!db.open(dbdir, resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd)) { if (!m_db.open(m_dbdir, resetbefore ? Rcl::Db::DbTrunc : Rcl::Db::DbUpd)) {
LOGERR(("DbIndexer: error opening database in %s\n", dbdir.c_str())); LOGERR(("DbIndexer: error opening database in %s\n", m_dbdir.c_str()));
return false; return false;
} }
return true; return true;
@ -145,7 +145,7 @@ bool DbIndexer::createStemDb(const string &lang)
{ {
if (!init()) if (!init())
return false; return false;
return db.createStemDb(lang); return m_db.createStemDb(lang);
} }
/** /**
@ -158,7 +158,7 @@ bool DbIndexer::indexFiles(const list<string> &filenames)
list<string>::const_iterator it; list<string>::const_iterator it;
for (it = filenames.begin(); it != filenames.end();it++) { for (it = filenames.begin(); it != filenames.end();it++) {
config->setKeyDir(path_getfather(*it)); m_config->setKeyDir(path_getfather(*it));
struct stat stb; struct stat stb;
if (stat(it->c_str(), &stb) != 0) { if (stat(it->c_str(), &stb) != 0) {
LOGERR(("DbIndexer::indexFiles: stat(%s): %s", it->c_str(), LOGERR(("DbIndexer::indexFiles: stat(%s): %s", it->c_str(),
@ -177,9 +177,9 @@ bool DbIndexer::indexFiles(const list<string> &filenames)
} }
} }
// The close would be done in our destructor, but we want status here // The close would be done in our destructor, but we want status here
if (!db.close()) { if (!m_db.close()) {
LOGERR(("DbIndexer::indexfiles: error closing database in %s\n", LOGERR(("DbIndexer::indexfiles: error closing database in %s\n",
dbdir.c_str())); m_dbdir.c_str()));
return false; return false;
} }
return true; return true;
@ -206,7 +206,7 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
// the current directory in configuration object) // the current directory in configuration object)
if (flg == FsTreeWalker::FtwDirEnter || if (flg == FsTreeWalker::FtwDirEnter ||
flg == FsTreeWalker::FtwDirReturn) { flg == FsTreeWalker::FtwDirReturn) {
config->setKeyDir(fn); m_config->setKeyDir(fn);
return FsTreeWalker::FtwOk; return FsTreeWalker::FtwOk;
} }
@ -215,12 +215,12 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
// from on to off it may happen that some files which are now // from on to off it may happen that some files which are now
// without mime type will not be purged from the db, resulting // without mime type will not be purged from the db, resulting
// into possible 'cannot intern file' messages at query time... // into possible 'cannot intern file' messages at query time...
if (!db.needUpdate(fn, stp)) { if (!m_db.needUpdate(fn, stp)) {
LOGDEB(("indexfile: up to date: %s\n", fn.c_str())); LOGDEB(("indexfile: up to date: %s\n", fn.c_str()));
return FsTreeWalker::FtwOk; return FsTreeWalker::FtwOk;
} }
FileInterner interner(fn, config, tmpdir); FileInterner interner(fn, m_config, m_tmpdir);
FileInterner::Status fis = FileInterner::FIAgain; FileInterner::Status fis = FileInterner::FIAgain;
while (fis == FileInterner::FIAgain) { while (fis == FileInterner::FIAgain) {
Rcl::Doc doc; Rcl::Doc doc;
@ -239,13 +239,13 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
doc.ipath = ipath; doc.ipath = ipath;
// File name transcoded to utf8 for indexation. // File name transcoded to utf8 for indexation.
string charset = config->getDefCharset(true); string charset = m_config->getDefCharset(true);
// If this fails, the file name won't be indexed, no big deal // If this fails, the file name won't be indexed, no big deal
// Note that we used to do the full path here, but I ended up believing // Note that we used to do the full path here, but I ended up believing
// that it made more sense to use only the file name // that it made more sense to use only the file name
transcode(path_getsimple(fn), doc.utf8fn, charset, "UTF-8"); transcode(path_getsimple(fn), doc.utf8fn, charset, "UTF-8");
// Do database-specific work to update document data // Do database-specific work to update document data
if (!db.add(fn, doc, stp)) if (!m_db.add(fn, doc, stp))
return FsTreeWalker::FtwError; return FsTreeWalker::FtwError;
} }
@ -258,14 +258,14 @@ DbIndexer::processone(const std::string &fn, const struct stat *stp,
ConfIndexer::~ConfIndexer() ConfIndexer::~ConfIndexer()
{ {
deleteZ(dbindexer); deleteZ(m_dbindexer);
} }
bool ConfIndexer::index(bool resetbefore) bool ConfIndexer::index(bool resetbefore)
{ {
// Retrieve the list of directories to be indexed. // Retrieve the list of directories to be indexed.
string topdirs; string topdirs;
if (!config->getConfParam("topdirs", topdirs)) { if (!m_config->getConfParam("topdirs", topdirs)) {
LOGERR(("ConfIndexer::index: no top directories in configuration\n")); LOGERR(("ConfIndexer::index: no top directories in configuration\n"));
return false; return false;
} }
@ -285,8 +285,8 @@ bool ConfIndexer::index(bool resetbefore)
for (dirit = tdl.begin(); dirit != tdl.end(); dirit++) { for (dirit = tdl.begin(); dirit != tdl.end(); dirit++) {
string dbdir; string dbdir;
string doctopdir = path_tildexpand(*dirit); string doctopdir = path_tildexpand(*dirit);
config->setKeyDir(doctopdir); m_config->setKeyDir(doctopdir);
if (!config->getConfParam("dbdir", dbdir)) { if (!m_config->getConfParam("dbdir", dbdir)) {
LOGERR(("ConfIndexer::index: no database directory in " LOGERR(("ConfIndexer::index: no database directory in "
"configuration for %s\n", doctopdir.c_str())); "configuration for %s\n", doctopdir.c_str()));
return false; return false;
@ -301,7 +301,7 @@ bool ConfIndexer::index(bool resetbefore)
dbit->second.push_back(doctopdir); dbit->second.push_back(doctopdir);
} }
} }
config->setKeyDir(""); m_config->setKeyDir("");
// The dbmap now has dbdir as key and directory lists as values. // The dbmap now has dbdir as key and directory lists as values.
// Index each directory group in turn // Index each directory group in turn
@ -312,12 +312,12 @@ bool ConfIndexer::index(bool resetbefore)
// cout << *dit << " "; // cout << *dit << " ";
//} //}
//cout << endl; //cout << endl;
dbindexer = new DbIndexer(config, dbit->first, m_updfunc); m_dbindexer = new DbIndexer(m_config, dbit->first, m_updfunc);
if (!dbindexer->indexDb(resetbefore, &dbit->second)) { if (!m_dbindexer->indexDb(resetbefore, &dbit->second)) {
deleteZ(dbindexer); deleteZ(m_dbindexer);
return false; return false;
} }
deleteZ(dbindexer); deleteZ(m_dbindexer);
} }
return true; return true;
} }

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _INDEXER_H_INCLUDED_ #ifndef _INDEXER_H_INCLUDED_
#define _INDEXER_H_INCLUDED_ #define _INDEXER_H_INCLUDED_
/* @(#$Id: indexer.h,v 1.11 2006-03-22 16:24:41 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: indexer.h,v 1.12 2006-04-04 09:34:11 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string> #include <string>
#include <list> #include <list>
@ -48,14 +48,14 @@ class ConfIndexer {
public: public:
enum runStatus {IndexerOk, IndexerError}; enum runStatus {IndexerOk, IndexerError};
ConfIndexer(RclConfig *cnf, DbIxStatusUpdater *updfunc = 0) ConfIndexer(RclConfig *cnf, DbIxStatusUpdater *updfunc = 0)
: config(cnf), dbindexer(0), m_updfunc(updfunc) : m_config(cnf), m_dbindexer(0), m_updfunc(updfunc)
{} {}
virtual ~ConfIndexer(); virtual ~ConfIndexer();
/** Worker function: doe the actual indexing */ /** Worker function: doe the actual indexing */
bool index(bool resetbefore = false); bool index(bool resetbefore = false);
private: private:
RclConfig *config; RclConfig *m_config;
DbIndexer *dbindexer; // Object to process directories for a given db DbIndexer *m_dbindexer; // Object to process directories for a given db
DbIxStatusUpdater *m_updfunc; DbIxStatusUpdater *m_updfunc;
}; };
@ -76,7 +76,7 @@ class DbIndexer : public FsTreeWalkerCB {
const std::string &dbd, // Place where the db lives const std::string &dbd, // Place where the db lives
DbIxStatusUpdater *updfunc = 0 // status updater callback DbIxStatusUpdater *updfunc = 0 // status updater callback
) )
: config(cnf), dbdir(dbd), m_updfunc(updfunc) { : m_config(cnf), m_dbdir(dbd), m_updfunc(updfunc) {
} }
virtual ~DbIndexer(); virtual ~DbIndexer();
@ -105,12 +105,13 @@ class DbIndexer : public FsTreeWalkerCB {
FsTreeWalker::CbFlag); FsTreeWalker::CbFlag);
private: private:
FsTreeWalker walker; FsTreeWalker m_walker;
RclConfig *config; RclConfig *m_config;
std::string dbdir; std::string m_dbdir;
Rcl::Db db; Rcl::Db m_db;
std::string tmpdir; std::string m_tmpdir;
DbIxStatusUpdater *m_updfunc; DbIxStatusUpdater *m_updfunc;
bool init(bool rst = false); bool init(bool rst = false);
}; };