|
a/src/common/rclconfig.h |
|
b/src/common/rclconfig.h |
|
... |
|
... |
34 |
#include "conftree.h"
|
34 |
#include "conftree.h"
|
35 |
#include "smallut.h"
|
35 |
#include "smallut.h"
|
36 |
|
36 |
|
37 |
class RclConfig;
|
37 |
class RclConfig;
|
38 |
|
38 |
|
39 |
// A small class used for parameters that need to be computed from the
|
39 |
// Cache parameter string values for params which need computation and
|
40 |
// config string, and which can change with the keydir. Minimize work
|
40 |
// which can change with the keydir. Minimize work by using the
|
41 |
// by using the keydirgen and a saved string to avoid unneeded
|
41 |
// keydirgen and a saved string to avoid unneeded recomputations:
|
42 |
// recomputations
|
42 |
// keydirgen is incremented in RclConfig with each setKeyDir(). We
|
|
|
43 |
// compare our saved value with the current one. If it did not change
|
|
|
44 |
// no get() is needed. If it did change, but the resulting param get()
|
|
|
45 |
// string value is identical, no recomputation is needed.
|
43 |
class ParamStale {
|
46 |
class ParamStale {
|
44 |
public:
|
47 |
public:
|
45 |
RclConfig *parent;
|
48 |
ParamStale() {}
|
46 |
ConfNull *conffile;
|
|
|
47 |
string paramname;
|
|
|
48 |
bool active; // Check at init if config defines name at all
|
|
|
49 |
int savedkeydirgen;
|
|
|
50 |
string savedvalue;
|
|
|
51 |
|
|
|
52 |
ParamStale(RclConfig *rconf, const string& nm);
|
49 |
ParamStale(RclConfig *rconf, const string& nm)
|
|
|
50 |
: parent(rconf), paramnames(vector<string>(1, nm)), savedvalues(1) {
|
|
|
51 |
}
|
|
|
52 |
ParamStale(RclConfig *rconf, const vector<string>& nms)
|
|
|
53 |
: parent(rconf), paramnames(nms), savedvalues(nms.size()) {
|
|
|
54 |
}
|
53 |
void init(ConfNull *cnf);
|
55 |
void init(ConfNull *cnf);
|
54 |
bool needrecompute();
|
56 |
bool needrecompute();
|
|
|
57 |
const string& getvalue(unsigned int i = 0) const;
|
|
|
58 |
|
|
|
59 |
private:
|
|
|
60 |
// The config we belong to.
|
|
|
61 |
RclConfig *parent{0};
|
|
|
62 |
// The configuration file we search for values. This is a borrowed
|
|
|
63 |
// pointer belonging to the parent, we do not manage it.
|
|
|
64 |
ConfNull *conffile{0};
|
|
|
65 |
vector<string> paramnames;
|
|
|
66 |
vector<string> savedvalues;
|
|
|
67 |
// Check at init if the configuration defines our vars at all. No
|
|
|
68 |
// further processing is needed if it does not.
|
|
|
69 |
bool active{false};
|
|
|
70 |
int savedkeydirgen{-1};
|
55 |
};
|
71 |
};
|
56 |
|
72 |
|
57 |
// Hold the description for an external metadata-gathering command
|
73 |
// Hold the description for an external metadata-gathering command
|
58 |
struct MDReaper {
|
74 |
struct MDReaper {
|
59 |
string fieldname;
|
75 |
string fieldname;
|
|
... |
|
... |
61 |
};
|
77 |
};
|
62 |
|
78 |
|
63 |
// Data associated to a indexed field name:
|
79 |
// Data associated to a indexed field name:
|
64 |
struct FieldTraits {
|
80 |
struct FieldTraits {
|
65 |
string pfx; // indexing prefix,
|
81 |
string pfx; // indexing prefix,
|
66 |
int wdfinc; // Index time term frequency increment (default 1)
|
82 |
int wdfinc{1}; // Index time term frequency increment (default 1)
|
67 |
double boost; // Query time boost (default 1.0)
|
83 |
double boost{1.0}; // Query time boost (default 1.0)
|
68 |
bool pfxonly; // Suppress prefix-less indexing
|
84 |
bool pfxonly{false}; // Suppress prefix-less indexing
|
69 |
bool noterms; // Don't add term to highlight data (e.g.: rclbes)
|
85 |
bool noterms{false}; // Don't add term to highlight data (e.g.: rclbes)
|
70 |
FieldTraits()
|
|
|
71 |
: wdfinc(1), boost(1.0), pfxonly(false), noterms(false)
|
|
|
72 |
{}
|
|
|
73 |
};
|
86 |
};
|
74 |
|
87 |
|
75 |
class RclConfig {
|
88 |
class RclConfig {
|
76 |
public:
|
89 |
public:
|
77 |
|
90 |
|
78 |
// Constructor: we normally look for a configuration file, except
|
91 |
// Constructor: we normally look for a configuration file, except
|
79 |
// if this was specified on the command line and passed through
|
92 |
// if this was specified on the command line and passed through
|
80 |
// argcnf
|
93 |
// argcnf
|
81 |
RclConfig(const string *argcnf = 0);
|
94 |
RclConfig(const string *argcnf = 0);
|
82 |
|
95 |
|
83 |
RclConfig(const RclConfig &r)
|
96 |
RclConfig(const RclConfig &r);
|
84 |
: m_oldstpsuffstate(this, "recoll_noindex"),
|
|
|
85 |
m_stpsuffstate(this, "noContentSuffixes"),
|
|
|
86 |
m_skpnstate(this, "skippedNames"),
|
|
|
87 |
m_rmtstate(this, "indexedmimetypes"),
|
|
|
88 |
m_xmtstate(this, "excludedmimetypes"),
|
|
|
89 |
m_mdrstate(this, "metadatacmds") {
|
|
|
90 |
initFrom(r);
|
|
|
91 |
}
|
|
|
92 |
|
97 |
|
93 |
~RclConfig() {
|
98 |
~RclConfig() {
|
94 |
freeAll();
|
99 |
freeAll();
|
95 |
}
|
100 |
}
|
96 |
|
101 |
|
|
... |
|
... |
287 |
const;
|
292 |
const;
|
288 |
|
293 |
|
289 |
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
|
294 |
/** mimeview: get/set external viewer exec string(s) for mimetype(s) */
|
290 |
string getMimeViewerDef(const string &mimetype, const string& apptag,
|
295 |
string getMimeViewerDef(const string &mimetype, const string& apptag,
|
291 |
bool useall) const;
|
296 |
bool useall) const;
|
292 |
string getMimeViewerAllEx() const;
|
297 |
set<string> getMimeViewerAllEx() const;
|
293 |
bool setMimeViewerAllEx(const string& allex);
|
298 |
bool setMimeViewerAllEx(const set<string>& allex);
|
294 |
bool getMimeViewerDefs(vector<pair<string, string> >&) const;
|
299 |
bool getMimeViewerDefs(vector<pair<string, string> >&) const;
|
295 |
bool setMimeViewerDef(const string& mimetype, const string& cmd);
|
300 |
bool setMimeViewerDef(const string& mimetype, const string& cmd);
|
296 |
/** Check if mime type is designated as needing no uncompress before view
|
301 |
/** Check if mime type is designated as needing no uncompress before view
|
297 |
* (if a file of this type is found compressed). Default is true,
|
302 |
* (if a file of this type is found compressed). Default is true,
|
298 |
* exceptions are found in the nouncompforviewmts mimeview list */
|
303 |
* exceptions are found in the nouncompforviewmts mimeview list */
|
|
... |
|
... |
353 |
string m_keydir; // Current directory used for parameter fetches.
|
358 |
string m_keydir; // Current directory used for parameter fetches.
|
354 |
int m_keydirgen; // To help with knowing when to update computed data.
|
359 |
int m_keydirgen; // To help with knowing when to update computed data.
|
355 |
|
360 |
|
356 |
vector<string> m_cdirs; // directory stack for the confstacks
|
361 |
vector<string> m_cdirs; // directory stack for the confstacks
|
357 |
|
362 |
|
358 |
ConfStack<ConfTree> *m_conf; // Parsed configuration files
|
|
|
359 |
ConfStack<ConfTree> *mimemap; // The files don't change with keydir,
|
|
|
360 |
ConfStack<ConfSimple> *mimeconf; // but their content may depend on it.
|
|
|
361 |
ConfStack<ConfSimple> *mimeview; //
|
|
|
362 |
ConfStack<ConfSimple> *m_fields;
|
|
|
363 |
ConfSimple *m_ptrans; // Paths translations
|
|
|
364 |
map<string, FieldTraits> m_fldtotraits; // Field to field params
|
363 |
map<string, FieldTraits> m_fldtotraits; // Field to field params
|
365 |
map<string, string> m_aliastocanon;
|
364 |
map<string, string> m_aliastocanon;
|
366 |
map<string, string> m_aliastoqcanon;
|
365 |
map<string, string> m_aliastoqcanon;
|
367 |
set<string> m_storedFields;
|
366 |
set<string> m_storedFields;
|
368 |
map<string, string> m_xattrtofld;
|
367 |
map<string, string> m_xattrtofld;
|
369 |
|
368 |
|
370 |
void *m_stopsuffixes;
|
|
|
371 |
unsigned int m_maxsufflen;
|
369 |
unsigned int m_maxsufflen;
|
372 |
ParamStale m_oldstpsuffstate; // Values from user mimemap, now obsolete
|
370 |
ParamStale m_oldstpsuffstate; // Values from user mimemap, now obsolete
|
373 |
ParamStale m_stpsuffstate;
|
371 |
ParamStale m_stpsuffstate;
|
374 |
|
372 |
|
375 |
ParamStale m_skpnstate;
|
373 |
ParamStale m_skpnstate;
|
|
... |
|
... |
394 |
// Same idea with the metadata-gathering external commands,
|
392 |
// Same idea with the metadata-gathering external commands,
|
395 |
// (e.g. used to reap tagging info: "tmsu tags %f")
|
393 |
// (e.g. used to reap tagging info: "tmsu tags %f")
|
396 |
ParamStale m_mdrstate;
|
394 |
ParamStale m_mdrstate;
|
397 |
vector<MDReaper> m_mdreapers;
|
395 |
vector<MDReaper> m_mdreapers;
|
398 |
|
396 |
|
|
|
397 |
//////////////////
|
|
|
398 |
// Members needing explicit processing when copying
|
|
|
399 |
void *m_stopsuffixes;
|
|
|
400 |
ConfStack<ConfTree> *m_conf; // Parsed configuration files
|
|
|
401 |
ConfStack<ConfTree> *mimemap; // The files don't change with keydir,
|
|
|
402 |
ConfStack<ConfSimple> *mimeconf; // but their content may depend on it.
|
|
|
403 |
ConfStack<ConfSimple> *mimeview; //
|
|
|
404 |
ConfStack<ConfSimple> *m_fields;
|
|
|
405 |
ConfSimple *m_ptrans; // Paths translations
|
|
|
406 |
///////////////////
|
|
|
407 |
|
399 |
/** Create initial user configuration */
|
408 |
/** Create initial user configuration */
|
400 |
bool initUserConfig();
|
409 |
bool initUserConfig();
|
401 |
/** Init all ParamStale members */
|
410 |
/** Init all ParamStale members */
|
402 |
void initParamStale(ConfNull *cnf, ConfNull *mimemap);
|
411 |
void initParamStale(ConfNull *cnf, ConfNull *mimemap);
|
403 |
/** Copy from other */
|
412 |
/** Copy from other */
|
404 |
void initFrom(const RclConfig& r);
|
413 |
void initFrom(const RclConfig& r);
|