|
a/src/utils/conftree.h |
|
b/src/utils/conftree.h |
|
... |
|
... |
63 |
*/
|
63 |
*/
|
64 |
virtual int get(const std::string &name, string &value, const string &sk);
|
64 |
virtual int get(const std::string &name, string &value, const string &sk);
|
65 |
virtual int get(const std::string &name, string &value) {
|
65 |
virtual int get(const std::string &name, string &value) {
|
66 |
return get(name, value, string(""));
|
66 |
return get(name, value, string(""));
|
67 |
}
|
67 |
}
|
68 |
/**
|
68 |
/*
|
69 |
* See comments for std::string variant
|
69 |
* See comments for std::string variant
|
70 |
* @return 0 if name not found, const C string else
|
70 |
* @return 0 if name not found, const C string else
|
71 |
*/
|
71 |
*/
|
72 |
virtual const char *get(const char *name, const char *sk = 0);
|
72 |
virtual const char *get(const char *name, const char *sk = 0);
|
73 |
|
73 |
|
74 |
/**
|
74 |
/**
|
75 |
* Set value for named parameter in specified subsection (or global)
|
75 |
* Set value for named parameter in specified subsection (or global)
|
76 |
* @return 0 for error, 1 else
|
76 |
* @return 0 for error, 1 else
|
77 |
*/
|
77 |
*/
|
78 |
int set(const std::string &nm, const std::string &val, const string &sk);
|
78 |
virtual int set(const std::string &nm, const std::string &val,
|
|
|
79 |
const std::string &sk);
|
79 |
int set(const char *name, const char *value, const char *sk = 0);
|
80 |
virtual int set(const char *name, const char *value, const char *sk = 0);
|
|
|
81 |
|
|
|
82 |
/**
|
|
|
83 |
* Remove name and value from config
|
|
|
84 |
*/
|
|
|
85 |
virtual int erase(const std::string &name, const std::string &sk);
|
80 |
|
86 |
|
81 |
virtual StatusCode getStatus();
|
87 |
virtual StatusCode getStatus();
|
|
|
88 |
virtual bool ok() {return getStatus() != STATUS_ERROR;}
|
82 |
|
89 |
|
83 |
/**
|
90 |
/**
|
84 |
* Walk the configuration values, calling function for each.
|
91 |
* Walk the configuration values, calling function for each.
|
85 |
* The function is called with a null nm when changing subsections (the
|
92 |
* The function is called with a null nm when changing subsections (the
|
86 |
* value is then the new subsection name)
|
93 |
* value is then the new subsection name)
|
87 |
* @return WALK_STOP when/if the callback returns WALK_STOP,
|
94 |
* @return WALK_STOP when/if the callback returns WALK_STOP,
|
88 |
* WALK_CONTINUE else (got to end of config)
|
95 |
* WALK_CONTINUE else (got to end of config)
|
89 |
*/
|
96 |
*/
|
90 |
enum WalkerCode {WALK_STOP, WALK_CONTINUE};
|
97 |
enum WalkerCode {WALK_STOP, WALK_CONTINUE};
|
91 |
virtual WalkerCode sortwalk(WalkerCode
|
98 |
virtual WalkerCode sortwalk(WalkerCode
|
92 |
(*wlkr)(void *cldata, const char *nm,
|
99 |
(*wlkr)(void *cldata, const std::string &nm,
|
93 |
const char *val),
|
100 |
const std::string &val),
|
94 |
void *clidata);
|
101 |
void *clidata);
|
95 |
void list();
|
102 |
virtual void list();
|
|
|
103 |
|
96 |
/**
|
104 |
/**
|
97 |
* Return all key names:
|
105 |
* Return all names in given submap
|
98 |
*/
|
106 |
*/
|
99 |
std::list<string> getKeys();
|
107 |
virtual std::list<string> getNames(const string &sk);
|
|
|
108 |
|
|
|
109 |
virtual std::string getFilename() {return filename;}
|
100 |
|
110 |
|
101 |
protected:
|
111 |
protected:
|
102 |
bool dotildexpand;
|
112 |
bool dotildexpand;
|
103 |
private:
|
113 |
private:
|
104 |
string filename; // set if we're working with a file
|
114 |
string filename; // set if we're working with a file
|
|
... |
|
... |
143 |
virtual int get(const std::string &name, string &value, const string &sk);
|
153 |
virtual int get(const std::string &name, string &value, const string &sk);
|
144 |
|
154 |
|
145 |
virtual int get(const char *name, string &value, const char *sk) {
|
155 |
virtual int get(const char *name, string &value, const char *sk) {
|
146 |
return get(string(name), value, sk ? string(sk) : string(""));
|
156 |
return get(string(name), value, sk ? string(sk) : string(""));
|
147 |
}
|
157 |
}
|
148 |
/**
|
|
|
149 |
* Parse input stream into vector of strings.
|
|
|
150 |
*
|
|
|
151 |
* Token delimiter is " \t" except inside dquotes. dquote inside
|
|
|
152 |
* dquotes can be escaped with \ etc...
|
|
|
153 |
*/
|
|
|
154 |
static bool stringToStrings(const string &s, std::list<string> &tokens);
|
|
|
155 |
static bool stringToBool(const string &s);
|
|
|
156 |
};
|
158 |
};
|
157 |
|
159 |
|
158 |
#endif /*_CONFTREE_H_ */
|
160 |
#endif /*_CONFTREE_H_ */
|