28 #define PLUS '+' //flag states 34 return &global_params;
46 }
else if (*file ==
MINUS) {
53 if (!fp.
Open(file + nameoffset,
nullptr)) {
54 tprintf(
"read_params_file: Can't open %s\n", file + nameoffset);
68 if (line[0] !=
'\r' && line[0] !=
'\n' && line[0] !=
'#') {
70 for (valptr = line; *valptr && *valptr !=
' ' && *valptr !=
'\t';
76 while (*valptr ==
' ' || *valptr ==
'\t');
78 foundit =
SetParam(line, valptr, constraint, member_params);
82 tprintf(
"Warning: Parameter not found: %s\n", line);
96 if (*value ==
'\0')
return (sp !=
nullptr);
102 if (ip && ip->
constraint_ok(constraint) && sscanf(value,
"%d", &intval) == 1)
109 if (*value ==
'T' || *value ==
't' ||
110 *value ==
'Y' || *value ==
'y' || *value ==
'1') {
112 }
else if (*value ==
'F' || *value ==
'f' ||
113 *value ==
'N' || *value ==
'n' || *value ==
'0') {
124 doubleval = strtofloat(value);
126 if (sscanf(value,
"%lf", &doubleval) == 1)
130 return (sp || ip || bp || dp);
148 snprintf(buf,
sizeof(buf),
"%d", int32_t(*ip));
156 *value =
BOOL8(*bp) ?
"1":
"0";
164 snprintf(buf,
sizeof(buf),
"%g",
double(*dp));
173 int num_iterations = (member_params ==
nullptr) ? 1 : 2;
174 for (v = 0; v < num_iterations; ++v) {
176 for (i = 0; i < vec->
int_params.size(); ++i) {
177 fprintf(fp,
"%s\t%d\t%s\n", vec->
int_params[i]->name_str(),
181 fprintf(fp,
"%s\t%d\t%s\n", vec->
bool_params[i]->name_str(),
185 fprintf(fp,
"%s\t%s\t%s\n", vec->
string_params[i]->name_str(),
189 fprintf(fp,
"%s\t%g\t%s\n", vec->
double_params[i]->name_str(),
198 int num_iterations = (member_params ==
nullptr) ? 1 : 2;
199 for (v = 0; v < num_iterations; ++v) {
201 for (i = 0; i < vec->
int_params.size(); ++i) {
GenericVector< IntParam * > int_params
GenericVector< BoolParam * > bool_params
static void PrintParams(FILE *fp, const ParamsVectors *member_params)
bool constraint_ok(SetParamConstraint constraint) const
static bool SetParam(const char *name, const char *value, SetParamConstraint constraint, ParamsVectors *member_params)
void set_value(const STRING &value)
static void ResetToDefaults(ParamsVectors *member_params)
GenericVector< StringParam * > string_params
char * FGets(char *buffer, int buffer_size)
const char * string() const
static bool GetParamAsString(const char *name, const ParamsVectors *member_params, STRING *value)
tesseract::ParamsVectors * GlobalParams()
void chomp_string(char *str)
static bool ReadParamsFile(const char *file, SetParamConstraint constraint, ParamsVectors *member_params)
DLLSYM void tprintf(const char *format,...)
static bool ReadParamsFromFp(SetParamConstraint constraint, TFile *fp, ParamsVectors *member_params)
bool Open(const STRING &filename, FileReader reader)
GenericVector< DoubleParam * > double_params
void set_value(int32_t value)
void set_value(BOOL8 value)
void set_value(double value)