1 #ifndef _INCLUDED_CONFIG_READER_H_
2 #define _INCLUDED_CONFIG_READER_H_
8 #include "watch_files.h"
28 {
return(config->errors - errors_at_init);}
31 const char *getFullExp(
const char *exp);
33 const char *getStr(
const char *exp,
const char *default_val=NULL);
34 bool getBool(
const char *exp,
bool &val);
35 bool getInt (
const char *exp,
int &val);
36 bool getUInt (
const char *exp,
unsigned int &val);
37 bool getReal(
const char *exp,
float &val);
38 bool getReal(
const char *exp,
double &val);
39 bool getPosReal(
const char *exp,
float &val);
40 bool getPosReal(
const char *exp,
double &val);
41 bool getInt (
const char *exp,
int &val,
int _min,
int _max);
42 bool getReal(
const char *exp,
float &val,
float _min,
float _max);
43 bool getReal(
const char *exp,
double &val,
double _min,
double _max);
45 template <
class vec_t>
46 bool getVec2f(
const char *exp,vec_t &val);
47 template <
class vec_t>
48 bool getVec3f(
const char *exp,vec_t &val);
49 template <
class quaternion_t>
50 bool getQuat4f(
const char *exp,quaternion_t &val);
51 template <
class range_t>
52 bool getRangeInt(
const char *exp,range_t &val);
53 template <
class range_t>
54 bool getRangeReal(
const char *exp,range_t &val);
68 std::vector<FileHeader> files;
71 int num_readfiles_calls;
89 {closeLua(); errors = 0;}
95 {watch_files=NULL; addStandard();}
97 {watch_files=&_watch_files; addStandard();}
98 void addFile(
const char *filename,
unsigned flags=0);
101 void showError(
int err_code,
const char *filename);
102 bool readFile(
const char *filename,
unsigned flags);
107 bool isFileModified();
111 {
return(num_readfiles_calls);}
116 bool needUpdate(
int &client_generation)
const;
122 void eval(
const char *exp);
123 void eval(
const char *exp_base,
const char *exp_ext);
125 const char *getStr(
const char *exp,
const char *default_val=NULL);
126 bool getBool(
const char *exp,
bool &val);
127 bool getInt (
const char *exp,
int &val);
128 bool getUInt (
const char *exp,
unsigned int &val);
129 bool getReal(
const char *exp,
float &val);
130 bool getReal(
const char *exp,
double &val);
131 bool getPosReal(
const char *exp,
float &val);
132 bool getPosReal(
const char *exp,
double &val);
133 bool getInt (
const char *exp,
int &val,
int _min,
int _max);
134 bool getReal(
const char *exp,
float &val,
float _min,
float _max);
135 bool getReal(
const char *exp,
double &val,
double _min,
double _max);
137 bool set(
const char *name,
int val);
138 bool set(
const char *name,
double val);
144 template <
class vec_t>
145 bool ConfigReader::SubTree::getVec2f(
const char *exp,vec_t &val)
149 fexp.printf(
"%s.x",exp);
150 if(!getReal(fexp(),val.x))
return(
false);
152 fexp.printf(
"%s.y",exp);
153 if(!getReal(fexp(),val.y))
return(
false);
158 template <
class vec_t>
159 bool ConfigReader::SubTree::getVec3f(
const char *exp,vec_t &val)
163 fexp.printf(
"%s.x",exp);
164 if(!getReal(fexp(),val.x))
return(
false);
166 fexp.printf(
"%s.y",exp);
167 if(!getReal(fexp(),val.y))
return(
false);
169 fexp.printf(
"%s.z",exp);
170 if(!getReal(fexp(),val.z))
return(
false);
175 template <
class quaternion_t>
176 bool ConfigReader::SubTree::getQuat4f(
const char* exp, quaternion_t& val)
180 fexp.printf(
"%s.w",exp);
181 if(!getReal(fexp(),val.w()))
return(
false);
183 fexp.printf(
"%s.x",exp);
184 if(!getReal(fexp(),val.x()))
return(
false);
186 fexp.printf(
"%s.y",exp);
187 if(!getReal(fexp(),val.y()))
return(
false);
189 fexp.printf(
"%s.z",exp);
190 if(!getReal(fexp(),val.z()))
return(
false);
195 template <
class range_t>
196 bool ConfigReader::SubTree::getRangeInt(
const char *exp,range_t &val)
200 fexp.printf(
"%s.min",exp);
201 if(!getInt(fexp(),val.min))
return(
false);
203 fexp.printf(
"%s.max",exp);
204 if(!getInt(fexp(),val.max))
return(
false);
209 template <
class range_t>
210 bool ConfigReader::SubTree::getRangeReal(
const char *exp,range_t &val)
214 fexp.printf(
"%s.min",exp);
215 if(!getReal(fexp(),val.min))
return(
false);
217 fexp.printf(
"%s.max",exp);
218 if(!getReal(fexp(),val.max))
return(
false);
bool needUpdate(int &client_generation) const
int getGeneration() const
get generation count in terms of # of readFiles() updates