Indent + comments + use c++11 initializers

This commit is contained in:
Jean-Francois Dockes 2018-11-14 10:30:31 +01:00
parent f008457493
commit ea999ed6e5

View File

@ -32,11 +32,10 @@ namespace Rcl {
* indexer prior to adding to the index, and for querying, where * indexer prior to adding to the index, and for querying, where
* fields are filled from data stored in the index. Not all fields are * fields are filled from data stored in the index. Not all fields are
* in use at both index and query times, and not all field data is * in use at both index and query times, and not all field data is
* stored at index time (for example the "text" field is split and * stored at index time.
* indexed, but not stored as such)
*/ */
class Doc { class Doc {
public: public:
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// The following fields are stored into the document data record (so they // The following fields are stored into the document data record (so they
// can be accessed after a query without fetching the actual document). // can be accessed after a query without fetching the actual document).
@ -51,7 +50,7 @@ class Doc {
// save the original path: // save the original path:
std::string idxurl; std::string idxurl;
// And the originating db. 0 is base, 1 first external etc. // And the originating db. 0 is base, 1 first external etc.
int idxi; int idxi{0};
// Internal path for multi-doc files. Ascii // Internal path for multi-doc files. Ascii
// Set by FsIndexer::processone // Set by FsIndexer::processone
@ -85,7 +84,7 @@ class Doc {
// Attribute for the "abstract" entry. true if it is just the top // Attribute for the "abstract" entry. true if it is just the top
// of doc, not a native document attribute. Not stored directly, but // of doc, not a native document attribute. Not stored directly, but
// as an indicative prefix at the beginning of the abstract (ugly hack) // as an indicative prefix at the beginning of the abstract (ugly hack)
bool syntabs; bool syntabs{false};
// File size. This is the size of the compressed file or of the // File size. This is the size of the compressed file or of the
// external containing archive. // external containing archive.
@ -120,94 +119,90 @@ class Doc {
///////////////////////////////////////////////// /////////////////////////////////////////////////
// Misc stuff // Misc stuff
int pc; // relevancy percentage, used by sortseq, convenience int pc{0}; // relevancy percentage, used by sortseq, convenience
unsigned long xdocid; // Opaque: rcldb doc identifier. unsigned long xdocid{0}; // Opaque: rcldb doc identifier.
// Page breaks were stored during indexing. // Page breaks were stored during indexing.
bool haspages; bool haspages{false};
// Has children, either as content of file-level container or // Has children, either as content of file-level container or
// ipath descendants. // ipath descendants.
bool haschildren; bool haschildren{false};
// During indexing: only fields from extended attributes were set, no // During indexing: only fields from extended attributes were set, no
// doc content. Allows for faster reindexing of existing doc // doc content. Allows for faster reindexing of existing doc
bool onlyxattr; bool onlyxattr{false};
/////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////
void erase() { void erase() {
url.erase(); url.erase();
idxurl.erase(); idxurl.erase();
idxi = 0; idxi = 0;
ipath.erase(); ipath.erase();
mimetype.erase(); mimetype.erase();
fmtime.erase(); fmtime.erase();
dmtime.erase(); dmtime.erase();
origcharset.erase(); origcharset.erase();
meta.clear(); meta.clear();
syntabs = false; syntabs = false;
pcbytes.erase(); pcbytes.erase();
fbytes.erase(); fbytes.erase();
dbytes.erase(); dbytes.erase();
sig.erase(); sig.erase();
text.erase(); text.erase();
pc = 0; pc = 0;
xdocid = 0; xdocid = 0;
idxi = 0; haspages = false;
haspages = false; haschildren = false;
haschildren = false; onlyxattr = false;
onlyxattr = false;
} }
// Copy ensuring no shared string data, for threading issues. // Copy ensuring no shared string data, for threading issues.
void copyto(Doc *d) const; void copyto(Doc *d) const;
Doc() Doc() { }
: idxi(0), syntabs(false), pc(0), xdocid(0),
haspages(false), haschildren(false), onlyxattr(false) {
}
/** Get value for named field. If value pointer is 0, just test existence */ /** Get value for named field. If value pointer is 0, just test existence */
bool getmeta(const std::string& nm, std::string *value = 0) const bool getmeta(const std::string& nm, std::string *value = 0) const {
{ const auto it = meta.find(nm);
const auto it = meta.find(nm); if (it != meta.end()) {
if (it != meta.end()) { if (value)
if (value) *value = it->second;
*value = it->second; return true;
return true; } else {
} else { return false;
return false; }
}
} }
/** Nocopy getvalue. sets pointer to entry value if exists */ /** Nocopy getvalue. sets pointer to entry value if exists */
bool peekmeta(const std::string& nm, const std::string **value = 0) const bool peekmeta(const std::string& nm, const std::string **value = 0) const {
{ const auto it = meta.find(nm);
const auto it = meta.find(nm); if (it != meta.end()) {
if (it != meta.end()) { if (value)
if (value) *value = &(it->second);
*value = &(it->second); return true;
return true; } else {
} else { return false;
return false; }
}
} }
// Create entry or append text to existing entry. // Create entry or append text to existing entry.
bool addmeta(const std::string& nm, const std::string& value) bool addmeta(const std::string& nm, const std::string& value) {
{ auto mit = meta.find(nm);
auto mit = meta.find(nm); if (mit == meta.end()) {
if (mit == meta.end()) { meta[nm] = value;
meta[nm] = value; } else if (mit->second.empty()) {
} else if (mit->second.empty()) { mit->second = value;
mit->second = value; } else {
} else { // It may happen that the same attr exists several times
// It may happen that the same attr exists several times // in the internfile stack. Avoid duplicating values.
// in the internfile stack. Avoid duplicating values. if (mit->second != value)
if (mit->second != value) mit->second += std::string(" - ") + value;
mit->second += std::string(" - ") + value; }
} return true;
return true;
} }
/* Is this document stored as a regular filesystem file ? /* Is this document stored as a regular filesystem file ?
@ -224,6 +219,7 @@ class Doc {
void dump(bool dotext=false) const; void dump(bool dotext=false) const;
////////////////////////////////////////////////////////////////
// The official names for recoll native fields when used in a text // The official names for recoll native fields when used in a text
// context (ie: the python interface duplicates some of the fixed // context (ie: the python interface duplicates some of the fixed
// fields in the meta array, these are the names used). Defined in // fields in the meta array, these are the names used). Defined in
@ -254,7 +250,7 @@ class Doc {
static const std::string keydmt; // document mtime static const std::string keydmt; // document mtime
static const std::string keymt; // mtime dmtime if set else fmtime static const std::string keymt; // mtime dmtime if set else fmtime
static const std::string keyoc; // original charset static const std::string keyoc; // original charset
static const std::string keypcs; // document outer container size static const std::string keypcs; // document outer container size
static const std::string keyfs; // document size static const std::string keyfs; // document size
static const std::string keyds; // document text size static const std::string keyds; // document text size
static const std::string keysz; // dbytes if set else fbytes else pcbytes static const std::string keysz; // dbytes if set else fbytes else pcbytes
@ -266,10 +262,10 @@ class Doc {
static const std::string keytt; // title static const std::string keytt; // title
static const std::string keykw; // keywords static const std::string keykw; // keywords
static const std::string keymd5; // file md5 checksum static const std::string keymd5; // file md5 checksum
static const std::string keybcknd; // backend type for data not from the filesys static const std::string keybcknd; // backend type when not from the fs
// udi back from index. Only set by Rcl::Query::getdoc(). // udi back from index. Only set by Rcl::Query::getdoc().
static const std::string keyudi; static const std::string keyudi;
static const std::string keyapptg; // apptag. Set from localfields (fsindexer) static const std::string keyapptg; // apptag. Set from localfields (fs only)
static const std::string keybght; // beagle hit type ("beagleHitType") static const std::string keybght; // beagle hit type ("beagleHitType")
}; };