|
a/src/utils/conftree.cpp |
|
b/src/utils/conftree.cpp |
|
... |
|
... |
199 |
case STATUS_RW: return STATUS_RW;
|
199 |
case STATUS_RW: return STATUS_RW;
|
200 |
default: return STATUS_ERROR;
|
200 |
default: return STATUS_ERROR;
|
201 |
}
|
201 |
}
|
202 |
}
|
202 |
}
|
203 |
|
203 |
|
204 |
bool ConfSimple::sourceChanged()
|
204 |
bool ConfSimple::sourceChanged() const
|
205 |
{
|
205 |
{
|
|
|
206 |
if (!m_filename.empty()) {
|
|
|
207 |
struct stat st;
|
|
|
208 |
if (stat(m_filename.c_str(), &st) == 0) {
|
|
|
209 |
if (m_fmtime != st.st_mtime) {
|
|
|
210 |
return true;
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
}
|
206 |
return i_changed(false);
|
214 |
return false;
|
207 |
}
|
215 |
}
|
208 |
|
216 |
|
209 |
bool ConfSimple::i_changed(bool upd)
|
217 |
bool ConfSimple::i_changed(bool upd)
|
210 |
{
|
218 |
{
|
211 |
if (!m_filename.empty()) {
|
219 |
if (!m_filename.empty()) {
|
|
... |
|
... |
406 |
}
|
414 |
}
|
407 |
|
415 |
|
408 |
// Walk the tree, calling user function at each node
|
416 |
// Walk the tree, calling user function at each node
|
409 |
ConfSimple::WalkerCode
|
417 |
ConfSimple::WalkerCode
|
410 |
ConfSimple::sortwalk(WalkerCode (*walker)(void *,const string&,const string&),
|
418 |
ConfSimple::sortwalk(WalkerCode (*walker)(void *,const string&,const string&),
|
411 |
void *clidata)
|
419 |
void *clidata) const
|
412 |
{
|
420 |
{
|
413 |
if (!ok())
|
421 |
if (!ok())
|
414 |
return WALK_STOP;
|
422 |
return WALK_STOP;
|
415 |
// For all submaps:
|
423 |
// For all submaps:
|
416 |
for (map<string, map<string, string> >::iterator sit = m_submaps.begin();
|
424 |
for (map<string, map<string, string> >::const_iterator sit =
|
|
|
425 |
m_submaps.begin();
|
417 |
sit != m_submaps.end(); sit++) {
|
426 |
sit != m_submaps.end(); sit++) {
|
418 |
|
427 |
|
419 |
// Possibly emit submap name:
|
428 |
// Possibly emit submap name:
|
420 |
if (!sit->first.empty() && walker(clidata, string(), sit->first.c_str())
|
429 |
if (!sit->first.empty() && walker(clidata, string(), sit->first.c_str())
|
421 |
== WALK_STOP)
|
430 |
== WALK_STOP)
|
422 |
return WALK_STOP;
|
431 |
return WALK_STOP;
|
423 |
|
432 |
|
424 |
// Walk submap
|
433 |
// Walk submap
|
425 |
map<string, string> &sm = sit->second;
|
434 |
const map<string, string> &sm = sit->second;
|
426 |
for (map<string, string>::iterator it = sm.begin();it != sm.end();
|
435 |
for (map<string, string>::const_iterator it = sm.begin();it != sm.end();
|
427 |
it++) {
|
436 |
it++) {
|
428 |
if (walker(clidata, it->first, it->second) == WALK_STOP)
|
437 |
if (walker(clidata, it->first, it->second) == WALK_STOP)
|
429 |
return WALK_STOP;
|
438 |
return WALK_STOP;
|
430 |
}
|
439 |
}
|
431 |
}
|
440 |
}
|
|
... |
|
... |
503 |
}
|
512 |
}
|
504 |
}
|
513 |
}
|
505 |
return true;
|
514 |
return true;
|
506 |
}
|
515 |
}
|
507 |
|
516 |
|
508 |
void ConfSimple::showall()
|
517 |
void ConfSimple::showall() const
|
509 |
{
|
518 |
{
|
510 |
if (!ok())
|
519 |
if (!ok())
|
511 |
return;
|
520 |
return;
|
512 |
write(std::cout);
|
521 |
write(std::cout);
|
513 |
}
|
522 |
}
|
514 |
|
523 |
|
515 |
vector<string> ConfSimple::getNames(const string &sk, const char *pattern)
|
524 |
vector<string> ConfSimple::getNames(const string &sk, const char *pattern) const
|
516 |
{
|
525 |
{
|
517 |
vector<string> mylist;
|
526 |
vector<string> mylist;
|
518 |
if (!ok())
|
527 |
if (!ok())
|
519 |
return mylist;
|
528 |
return mylist;
|
520 |
map<string, map<string, string> >::iterator ss;
|
529 |
map<string, map<string, string> >::const_iterator ss;
|
521 |
if ((ss = m_submaps.find(sk)) == m_submaps.end()) {
|
530 |
if ((ss = m_submaps.find(sk)) == m_submaps.end()) {
|
522 |
return mylist;
|
531 |
return mylist;
|
523 |
}
|
532 |
}
|
524 |
mylist.reserve(ss->second.size());
|
533 |
mylist.reserve(ss->second.size());
|
525 |
map<string, string>::const_iterator it;
|
534 |
map<string, string>::const_iterator it;
|
|
... |
|
... |
529 |
mylist.push_back(it->first);
|
538 |
mylist.push_back(it->first);
|
530 |
}
|
539 |
}
|
531 |
return mylist;
|
540 |
return mylist;
|
532 |
}
|
541 |
}
|
533 |
|
542 |
|
534 |
vector<string> ConfSimple::getSubKeys()
|
543 |
vector<string> ConfSimple::getSubKeys() const
|
535 |
{
|
544 |
{
|
536 |
vector<string> mylist;
|
545 |
vector<string> mylist;
|
537 |
if (!ok())
|
546 |
if (!ok())
|
538 |
return mylist;
|
547 |
return mylist;
|
539 |
mylist.reserve(m_submaps.size());
|
548 |
mylist.reserve(m_submaps.size());
|
540 |
map<string, map<string, string> >::iterator ss;
|
549 |
map<string, map<string, string> >::const_iterator ss;
|
541 |
for (ss = m_submaps.begin(); ss != m_submaps.end(); ss++) {
|
550 |
for (ss = m_submaps.begin(); ss != m_submaps.end(); ss++) {
|
542 |
mylist.push_back(ss->first);
|
551 |
mylist.push_back(ss->first);
|
543 |
}
|
552 |
}
|
544 |
return mylist;
|
553 |
return mylist;
|
545 |
}
|
554 |
}
|
546 |
|
555 |
|
547 |
bool ConfSimple::hasNameAnywhere(const string& nm)
|
556 |
bool ConfSimple::hasNameAnywhere(const string& nm) const
|
548 |
{
|
557 |
{
|
549 |
vector<string>keys = getSubKeys();
|
558 |
vector<string>keys = getSubKeys();
|
550 |
for (vector<string>::const_iterator it = keys.begin();
|
559 |
for (vector<string>::const_iterator it = keys.begin();
|
551 |
it != keys.end(); it++) {
|
560 |
it != keys.end(); it++) {
|
552 |
string val;
|
561 |
string val;
|