add getConfParam->std::set

This commit is contained in:
Jean-Francois Dockes 2017-02-02 17:58:05 +01:00
parent 90bae886c2
commit 148e7eec0d
2 changed files with 21 additions and 5 deletions

View File

@ -395,7 +395,7 @@ bool RclConfig::getConfParam(const string &name, bool *bvp, bool shallow) const
} }
bool RclConfig::getConfParam(const string &name, vector<string> *svvp, bool RclConfig::getConfParam(const string &name, vector<string> *svvp,
bool shallow) const bool shallow) const
{ {
if (!svvp) if (!svvp)
return false; return false;
@ -406,8 +406,20 @@ bool RclConfig::getConfParam(const string &name, vector<string> *svvp,
return stringToStrings(s, *svvp); return stringToStrings(s, *svvp);
} }
bool RclConfig::getConfParam(const string &name, unordered_set<string> *out,
bool shallow) const
{
vector<string> v;
if (!out || !getConfParam(name, &v, shallow)) {
return false;
}
out->clear();
out->insert(v.begin(), v.end());
return true;
}
bool RclConfig::getConfParam(const string &name, vector<int> *vip, bool RclConfig::getConfParam(const string &name, vector<int> *vip,
bool shallow) const bool shallow) const
{ {
if (!vip) if (!vip)
return false; return false;
@ -420,7 +432,8 @@ bool RclConfig::getConfParam(const string &name, vector<int> *vip,
char *ep; char *ep;
vip->push_back(strtol(vs[i].c_str(), &ep, 0)); vip->push_back(strtol(vs[i].c_str(), &ep, 0));
if (ep == vs[i].c_str()) { if (ep == vs[i].c_str()) {
LOGDEB("RclConfig::getConfParam: bad int value in [" << (name) << "]\n" ); LOGDEB("RclConfig::getConfParam: bad int value in [" << name <<
"]\n");
return false; return false;
} }
} }

View File

@ -140,6 +140,10 @@ class RclConfig {
* (stringToStrings). Can fail if the string is malformed. */ * (stringToStrings). Can fail if the string is malformed. */
bool getConfParam(const string &name, vector<string> *value, bool getConfParam(const string &name, vector<string> *value,
bool shallow=false) const; bool shallow=false) const;
/** Variant with conversion to unordered_set<string>
* (stringToStrings). Can fail if the string is malformed. */
bool getConfParam(const string &name, std::unordered_set<std::string> *v,
bool shallow=false) const;
/** Variant with conversion to vector<int> */ /** Variant with conversion to vector<int> */
bool getConfParam(const string &name, vector<int> *value, bool getConfParam(const string &name, vector<int> *value,
bool shallow=false) const; bool shallow=false) const;
@ -189,8 +193,7 @@ class RclConfig {
string getIdxStatusFile() const; string getIdxStatusFile() const;
/** Do path translation according to the ptrans table */ /** Do path translation according to the ptrans table */
void urlrewrite(const string& dbdir, string& url) const; void urlrewrite(const string& dbdir, string& url) const;
ConfSimple *getPTrans() ConfSimple *getPTrans() {
{
return m_ptrans; return m_ptrans;
} }
/** Get Web Queue directory name */ /** Get Web Queue directory name */