|
a/src/utils/conftree.cpp |
|
b/src/utils/conftree.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid [] = "@(#$Id: conftree.cpp,v 1.7 2006-11-08 06:56:41 dockes Exp $ (C) 2003 J.F.Dockes";
|
2 |
static char rcsid [] = "@(#$Id: conftree.cpp,v 1.8 2006-12-14 13:53:43 dockes Exp $ (C) 2003 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
/*
|
4 |
/*
|
5 |
* This program is free software; you can redistribute it and/or modify
|
5 |
* This program is free software; you can redistribute it and/or modify
|
6 |
* it under the terms of the GNU General Public License as published by
|
6 |
* it under the terms of the GNU General Public License as published by
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
7 |
* the Free Software Foundation; either version 2 of the License, or
|
|
... |
|
... |
26 |
#include <unistd.h> // for access(2)
|
26 |
#include <unistd.h> // for access(2)
|
27 |
#include <ctype.h>
|
27 |
#include <ctype.h>
|
28 |
|
28 |
|
29 |
#include <fstream>
|
29 |
#include <fstream>
|
30 |
#include <sstream>
|
30 |
#include <sstream>
|
|
|
31 |
#include <algorithm>
|
31 |
|
32 |
|
32 |
#include "conftree.h"
|
33 |
#include "conftree.h"
|
33 |
#include "pathut.h"
|
34 |
#include "pathut.h"
|
34 |
#include "smallut.h"
|
35 |
#include "smallut.h"
|
35 |
|
36 |
|
|
... |
|
... |
340 |
}
|
341 |
}
|
341 |
return WALK_CONTINUE;
|
342 |
return WALK_CONTINUE;
|
342 |
}
|
343 |
}
|
343 |
|
344 |
|
344 |
#include <iostream>
|
345 |
#include <iostream>
|
345 |
void ConfSimple::list()
|
346 |
void ConfSimple::listall()
|
346 |
{
|
347 |
{
|
347 |
if (!ok())
|
348 |
if (!ok())
|
348 |
return;
|
349 |
return;
|
349 |
sortwalk(swalker, &std::cout);
|
350 |
sortwalk(swalker, &std::cout);
|
350 |
}
|
351 |
}
|
|
... |
|
... |
360 |
}
|
361 |
}
|
361 |
map<string, string>::const_iterator it;
|
362 |
map<string, string>::const_iterator it;
|
362 |
for (it = ss->second.begin();it != ss->second.end();it++) {
|
363 |
for (it = ss->second.begin();it != ss->second.end();it++) {
|
363 |
mylist.push_back(it->first);
|
364 |
mylist.push_back(it->first);
|
364 |
}
|
365 |
}
|
|
|
366 |
mylist.sort();
|
|
|
367 |
mylist.unique();
|
365 |
return mylist;
|
368 |
return mylist;
|
366 |
}
|
369 |
}
|
367 |
|
370 |
|
368 |
// //////////////////////////////////////////////////////////////////////////
|
371 |
// //////////////////////////////////////////////////////////////////////////
|
369 |
// ConfTree Methods: conftree interpret keys like a hierarchical file tree
|
372 |
// ConfTree Methods: conftree interpret keys like a hierarchical file tree
|
|
... |
|
... |
429 |
;
|
432 |
;
|
430 |
|
433 |
|
431 |
void memtest(ConfSimple &c)
|
434 |
void memtest(ConfSimple &c)
|
432 |
{
|
435 |
{
|
433 |
cout << "Initial:" << endl;
|
436 |
cout << "Initial:" << endl;
|
434 |
c.list();
|
437 |
c.listall();
|
435 |
if (c.set("nom", "avec nl \n 2eme ligne", "")) {
|
438 |
if (c.set("nom", "avec nl \n 2eme ligne", "")) {
|
436 |
fprintf(stderr, "set with embedded nl succeeded !\n");
|
439 |
fprintf(stderr, "set with embedded nl succeeded !\n");
|
437 |
exit(1);
|
440 |
exit(1);
|
438 |
}
|
441 |
}
|
439 |
if (!c.set(string("parm1"), string("1"), string("subkey1"))) {
|
442 |
if (!c.set(string("parm1"), string("1"), string("subkey1"))) {
|
|
... |
|
... |
448 |
fprintf(stderr, "Set error");
|
451 |
fprintf(stderr, "Set error");
|
449 |
exit(1);
|
452 |
exit(1);
|
450 |
}
|
453 |
}
|
451 |
|
454 |
|
452 |
cout << "Final:" << endl;
|
455 |
cout << "Final:" << endl;
|
453 |
c.list();
|
456 |
c.listall();
|
454 |
}
|
457 |
}
|
455 |
|
458 |
|
456 |
static char usage [] =
|
459 |
static char usage [] =
|
457 |
"testconftree [opts] filename\n"
|
460 |
"testconftree [opts] filename\n"
|
458 |
"[-w] : read/write test.\n"
|
461 |
"[-w] : read/write test.\n"
|
|
... |
|
... |
614 |
if (parms.getStatus() == ConfSimple::STATUS_ERROR) {
|
617 |
if (parms.getStatus() == ConfSimple::STATUS_ERROR) {
|
615 |
fprintf(stderr, "Open failed\n");
|
618 |
fprintf(stderr, "Open failed\n");
|
616 |
exit(1);
|
619 |
exit(1);
|
617 |
}
|
620 |
}
|
618 |
printf("LIST\n");
|
621 |
printf("LIST\n");
|
619 |
parms.list();
|
622 |
parms.listall();
|
620 |
//printf("WALK\n");parms.sortwalk(mywalker, 0);
|
623 |
//printf("WALK\n");parms.sortwalk(mywalker, 0);
|
621 |
printf("\nNAMES in global space:\n");
|
624 |
printf("\nNAMES in global space:\n");
|
622 |
list<string> names = parms.getNames("");
|
625 |
list<string> names = parms.getNames("");
|
623 |
for (list<string>::iterator it = names.begin();it!=names.end();
|
626 |
for (list<string>::iterator it = names.begin();it!=names.end();
|
624 |
it++)
|
627 |
it++)
|