add some constness
This commit is contained in:
parent
96dba3a3ee
commit
f70875d89d
@ -198,7 +198,7 @@ ConfSimple::ConfSimple(const char *fname, int readonly, bool tildexp)
|
|||||||
parseinput(input);
|
parseinput(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfSimple::StatusCode ConfSimple::getStatus()
|
ConfSimple::StatusCode ConfSimple::getStatus() const
|
||||||
{
|
{
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case STATUS_RO: return STATUS_RO;
|
case STATUS_RO: return STATUS_RO;
|
||||||
@ -207,18 +207,18 @@ ConfSimple::StatusCode ConfSimple::getStatus()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfSimple::get(const string &nm, string &value, const string &sk)
|
int ConfSimple::get(const string &nm, string &value, const string &sk) const
|
||||||
{
|
{
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Find submap
|
// Find submap
|
||||||
map<string, map<string, string> >::iterator ss;
|
map<string, map<string, string> >::const_iterator ss;
|
||||||
if ((ss = m_submaps.find(sk)) == m_submaps.end())
|
if ((ss = m_submaps.find(sk)) == m_submaps.end())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Find named value
|
// Find named value
|
||||||
map<string, string>::iterator s;
|
map<string, string>::const_iterator s;
|
||||||
if ((s = ss->second.find(nm)) == ss->second.end())
|
if ((s = ss->second.find(nm)) == ss->second.end())
|
||||||
return 0;
|
return 0;
|
||||||
value = s->second;
|
value = s->second;
|
||||||
@ -442,7 +442,7 @@ bool ConfSimple::write()
|
|||||||
// Write out the tree in configuration file format:
|
// Write out the tree in configuration file format:
|
||||||
// This does not check holdWrites, this is done by write(void), which
|
// This does not check holdWrites, this is done by write(void), which
|
||||||
// lets ie: listall work even when holdWrites is set
|
// lets ie: listall work even when holdWrites is set
|
||||||
bool ConfSimple::write(ostream& out)
|
bool ConfSimple::write(ostream& out) const
|
||||||
{
|
{
|
||||||
if (!ok())
|
if (!ok())
|
||||||
return false;
|
return false;
|
||||||
@ -546,6 +546,7 @@ bool ConfSimple::hasNameAnywhere(const string& nm)
|
|||||||
// //////////////////////////////////////////////////////////////////////////
|
// //////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
int ConfTree::get(const std::string &name, string &value, const string &sk)
|
int ConfTree::get(const std::string &name, string &value, const string &sk)
|
||||||
|
const
|
||||||
{
|
{
|
||||||
if (sk.empty() || sk[0] != '/') {
|
if (sk.empty() || sk[0] != '/') {
|
||||||
// LOGDEB((stderr, "ConfTree::get: looking in global space\n"));
|
// LOGDEB((stderr, "ConfTree::get: looking in global space\n"));
|
||||||
|
|||||||
@ -95,11 +95,11 @@ public:
|
|||||||
enum StatusCode {STATUS_ERROR=0, STATUS_RO=1, STATUS_RW=2};
|
enum StatusCode {STATUS_ERROR=0, STATUS_RO=1, STATUS_RW=2};
|
||||||
virtual ~ConfNull() {};
|
virtual ~ConfNull() {};
|
||||||
virtual int get(const string &name, string &value,
|
virtual int get(const string &name, string &value,
|
||||||
const string &sk = string()) = 0;
|
const string &sk = string()) const = 0;
|
||||||
virtual bool hasNameAnywhere(const string& nm) = 0;
|
virtual bool hasNameAnywhere(const string& nm) = 0;
|
||||||
virtual int set(const string &nm, const string &val,
|
virtual int set(const string &nm, const string &val,
|
||||||
const string &sk = string()) = 0;
|
const string &sk = string()) = 0;
|
||||||
virtual bool ok() = 0;
|
virtual bool ok() const = 0;
|
||||||
virtual list<string> getNames(const string &sk, const char* = 0) = 0;
|
virtual list<string> getNames(const string &sk, const char* = 0) = 0;
|
||||||
virtual int erase(const string &, const string &) = 0;
|
virtual int erase(const string &, const string &) = 0;
|
||||||
virtual int eraseKey(const string &) = 0;
|
virtual int eraseKey(const string &) = 0;
|
||||||
@ -157,7 +157,8 @@ public:
|
|||||||
* global space if sk is empty).
|
* global space if sk is empty).
|
||||||
* @return 0 if name not found, 1 else
|
* @return 0 if name not found, 1 else
|
||||||
*/
|
*/
|
||||||
virtual int get(const string &name, string &value, const string &sk = string());
|
virtual int get(const string &name, string &value,
|
||||||
|
const string &sk = string()) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set value for named parameter in specified subsection (or global)
|
* Set value for named parameter in specified subsection (or global)
|
||||||
@ -175,8 +176,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual int eraseKey(const string &sk);
|
virtual int eraseKey(const string &sk);
|
||||||
|
|
||||||
virtual StatusCode getStatus();
|
virtual StatusCode getStatus() const;
|
||||||
virtual bool ok() {return getStatus() != STATUS_ERROR;}
|
virtual bool ok() const {return getStatus() != STATUS_ERROR;}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Walk the configuration values, calling function for each.
|
* Walk the configuration values, calling function for each.
|
||||||
@ -232,6 +233,11 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write in file format to out
|
||||||
|
*/
|
||||||
|
bool write(ostream& out) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool dotildexpand;
|
bool dotildexpand;
|
||||||
StatusCode status;
|
StatusCode status;
|
||||||
@ -250,7 +256,6 @@ private:
|
|||||||
|
|
||||||
void parseinput(istream& input);
|
void parseinput(istream& input);
|
||||||
bool write();
|
bool write();
|
||||||
bool write(ostream& out);
|
|
||||||
// Internal version of set: no RW checking
|
// Internal version of set: no RW checking
|
||||||
virtual int i_set(const string &nm, const string &val,
|
virtual int i_set(const string &nm, const string &val,
|
||||||
const string &sk, bool init = false);
|
const string &sk, bool init = false);
|
||||||
@ -296,7 +301,7 @@ public:
|
|||||||
* parents.
|
* parents.
|
||||||
* @return 0 if name not found, 1 else
|
* @return 0 if name not found, 1 else
|
||||||
*/
|
*/
|
||||||
virtual int get(const string &name, string &value, const string &sk);
|
virtual int get(const string &name, string &value, const string &sk) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -353,9 +358,9 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int get(const string &name, string &value, const string &sk)
|
virtual int get(const string &name, string &value, const string &sk) const
|
||||||
{
|
{
|
||||||
typename list<T*>::iterator it;
|
typename list<T*>::const_iterator it;
|
||||||
for (it = m_confs.begin();it != m_confs.end();it++) {
|
for (it = m_confs.begin();it != m_confs.end();it++) {
|
||||||
if ((*it)->get(name, value, sk))
|
if ((*it)->get(name, value, sk))
|
||||||
return true;
|
return true;
|
||||||
@ -373,7 +378,8 @@ public:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int set(const string &nm, const string &val, const string &sk = string())
|
virtual int set(const string &nm, const string &val,
|
||||||
|
const string &sk = string())
|
||||||
{
|
{
|
||||||
if (!m_ok)
|
if (!m_ok)
|
||||||
return 0;
|
return 0;
|
||||||
@ -443,7 +449,7 @@ public:
|
|||||||
return sks;
|
return sks;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool ok() {return m_ok;}
|
virtual bool ok() const {return m_ok;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_ok;
|
bool m_ok;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user