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);
|
||||
}
|
||||
|
||||
ConfSimple::StatusCode ConfSimple::getStatus()
|
||||
ConfSimple::StatusCode ConfSimple::getStatus() const
|
||||
{
|
||||
switch (status) {
|
||||
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())
|
||||
return 0;
|
||||
|
||||
// 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())
|
||||
return 0;
|
||||
|
||||
// Find named value
|
||||
map<string, string>::iterator s;
|
||||
map<string, string>::const_iterator s;
|
||||
if ((s = ss->second.find(nm)) == ss->second.end())
|
||||
return 0;
|
||||
value = s->second;
|
||||
@ -442,7 +442,7 @@ bool ConfSimple::write()
|
||||
// Write out the tree in configuration file format:
|
||||
// This does not check holdWrites, this is done by write(void), which
|
||||
// lets ie: listall work even when holdWrites is set
|
||||
bool ConfSimple::write(ostream& out)
|
||||
bool ConfSimple::write(ostream& out) const
|
||||
{
|
||||
if (!ok())
|
||||
return false;
|
||||
@ -546,6 +546,7 @@ bool ConfSimple::hasNameAnywhere(const string& nm)
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int ConfTree::get(const std::string &name, string &value, const string &sk)
|
||||
const
|
||||
{
|
||||
if (sk.empty() || sk[0] != '/') {
|
||||
// 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};
|
||||
virtual ~ConfNull() {};
|
||||
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 int set(const string &nm, const string &val,
|
||||
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 int erase(const string &, const string &) = 0;
|
||||
virtual int eraseKey(const string &) = 0;
|
||||
@ -157,7 +157,8 @@ public:
|
||||
* global space if sk is empty).
|
||||
* @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)
|
||||
@ -175,8 +176,8 @@ public:
|
||||
*/
|
||||
virtual int eraseKey(const string &sk);
|
||||
|
||||
virtual StatusCode getStatus();
|
||||
virtual bool ok() {return getStatus() != STATUS_ERROR;}
|
||||
virtual StatusCode getStatus() const;
|
||||
virtual bool ok() const {return getStatus() != STATUS_ERROR;}
|
||||
|
||||
/**
|
||||
* Walk the configuration values, calling function for each.
|
||||
@ -232,6 +233,11 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write in file format to out
|
||||
*/
|
||||
bool write(ostream& out) const;
|
||||
|
||||
protected:
|
||||
bool dotildexpand;
|
||||
StatusCode status;
|
||||
@ -250,7 +256,6 @@ private:
|
||||
|
||||
void parseinput(istream& input);
|
||||
bool write();
|
||||
bool write(ostream& out);
|
||||
// Internal version of set: no RW checking
|
||||
virtual int i_set(const string &nm, const string &val,
|
||||
const string &sk, bool init = false);
|
||||
@ -296,7 +301,7 @@ public:
|
||||
* parents.
|
||||
* @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;
|
||||
}
|
||||
|
||||
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++) {
|
||||
if ((*it)->get(name, value, sk))
|
||||
return true;
|
||||
@ -373,7 +378,8 @@ public:
|
||||
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)
|
||||
return 0;
|
||||
@ -443,7 +449,7 @@ public:
|
||||
return sks;
|
||||
}
|
||||
|
||||
virtual bool ok() {return m_ok;}
|
||||
virtual bool ok() const {return m_ok;}
|
||||
|
||||
private:
|
||||
bool m_ok;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user