42 struct ParamsVectors {
66 static bool SetParam(
const char* name,
const char* value,
77 for (i = 0; i < global_vec.
size(); ++i) {
78 if (strcmp(global_vec[i]->name_str(), name) == 0)
return global_vec[i];
80 for (i = 0; i < member_vec.
size(); ++i) {
81 if (strcmp(member_vec[i]->name_str(), name) == 0)
return member_vec[i];
88 for (
int i = 0; i < vec->
size(); ++i) {
89 if ((*vec)[i] == param_ptr) {
98 const ParamsVectors* member_params,
127 Param(
const char* name,
const char* comment,
bool init)
129 debug_ = (strstr(name,
"debug") !=
nullptr) || (strstr(name,
"display"));
140 IntParam(int32_t value,
const char* name,
const char* comment,
bool init,
142 :
Param(name, comment, init) {
145 params_vec_ = &(vec->int_params);
146 vec->int_params.push_back(
this);
148 ~IntParam() { ParamUtils::RemoveParam<IntParam>(
this, params_vec_); }
149 operator int32_t()
const {
return value_; }
150 void operator=(int32_t value) { value_ = value; }
151 void set_value(int32_t value) { value_ = value; }
154 for (
int i = 0; i < vec->int_params.size(); ++i) {
155 if (strcmp(vec->int_params[i]->name_str(),
name_) == 0) {
158 value_ = *vec->int_params[i];
173 BoolParam(
bool value,
const char* name,
const char* comment,
bool init,
175 :
Param(name, comment, init) {
178 params_vec_ = &(vec->bool_params);
179 vec->bool_params.push_back(
this);
181 ~BoolParam() { ParamUtils::RemoveParam<BoolParam>(
this, params_vec_); }
182 operator bool()
const {
return value_; }
183 void operator=(
bool value) { value_ = value; }
184 void set_value(
bool value) { value_ = value; }
187 for (
int i = 0; i < vec->bool_params.size(); ++i) {
188 if (strcmp(vec->bool_params[i]->name_str(),
name_) == 0) {
191 value_ = *vec->bool_params[i];
206 StringParam(
const char* value,
const char* name,
const char* comment,
208 :
Param(name, comment, init) {
211 params_vec_ = &(vec->string_params);
212 vec->string_params.push_back(
this);
214 ~StringParam() { ParamUtils::RemoveParam<StringParam>(
this, params_vec_); }
215 operator STRING&() {
return value_; }
216 const char*
c_str()
const {
return value_.
c_str(); }
222 void ResetFrom(
const ParamsVectors* vec) {
223 for (
int i = 0; i < vec->string_params.size(); ++i) {
224 if (strcmp(vec->string_params[i]->name_str(),
name_) == 0) {
227 value_ = *vec->string_params[i];
242 DoubleParam(
double value,
const char* name,
const char* comment,
bool init,
244 :
Param(name, comment, init) {
247 params_vec_ = &(vec->double_params);
248 vec->double_params.push_back(
this);
250 ~DoubleParam() { ParamUtils::RemoveParam<DoubleParam>(
this, params_vec_); }
251 operator double()
const {
return value_; }
252 void operator=(
double value) { value_ = value; }
253 void set_value(
double value) { value_ = value; }
256 for (
int i = 0; i < vec->double_params.size(); ++i) {
257 if (strcmp(vec->double_params[i]->name_str(),
name_) == 0) {
260 value_ = *vec->double_params[i];
294 #define INT_VAR_H(name, val, comment) tesseract::IntParam name
296 #define BOOL_VAR_H(name, val, comment) tesseract::BoolParam name
298 #define STRING_VAR_H(name, val, comment) tesseract::StringParam name
300 #define double_VAR_H(name, val, comment) tesseract::DoubleParam name
302 #define INT_VAR(name, val, comment) \
303 tesseract::IntParam name(val, #name, comment, false, GlobalParams())
305 #define BOOL_VAR(name, val, comment) \
306 tesseract::BoolParam name(val, #name, comment, false, GlobalParams())
308 #define STRING_VAR(name, val, comment) \
309 tesseract::StringParam name(val, #name, comment, false, GlobalParams())
311 #define double_VAR(name, val, comment) \
312 tesseract::DoubleParam name(val, #name, comment, false, GlobalParams())
314 #define INT_MEMBER(name, val, comment, vec) \
315 name(val, #name, comment, false, vec)
317 #define BOOL_MEMBER(name, val, comment, vec) \
318 name(val, #name, comment, false, vec)
320 #define STRING_MEMBER(name, val, comment, vec) \
321 name(val, #name, comment, false, vec)
323 #define double_MEMBER(name, val, comment, vec) \
324 name(val, #name, comment, false, vec)
326 #define INT_INIT_MEMBER(name, val, comment, vec) \
327 name(val, #name, comment, true, vec)
329 #define BOOL_INIT_MEMBER(name, val, comment, vec) \
330 name(val, #name, comment, true, vec)
332 #define STRING_INIT_MEMBER(name, val, comment, vec) \
333 name(val, #name, comment, true, vec)
335 #define double_INIT_MEMBER(name, val, comment, vec) \
336 name(val, #name, comment, true, vec)