31 #define PLUS '+' //flag states
54 }
else if (*file ==
MINUS) {
62 fp = fopen(file + nameoffset,
"rb");
64 tprintf(
"read_params_file: Can't open %s\n", file + nameoffset);
80 while ((end_offset < 0 || ftell(fp) < end_offset) &&
82 if (line[0] !=
'\n' && line[0] !=
'#') {
83 length = strlen (line);
84 if (line[length - 1] ==
'\n')
85 line[length - 1] =
'\0';
86 for (valptr = line; *valptr && *valptr !=
' ' && *valptr !=
'\t';
92 while (*valptr ==
' ' || *valptr ==
'\t');
94 foundit =
SetParam(line, valptr, constraint, member_params);
98 tprintf(
"read_params_file: parameter not found: %s\n", line);
113 if (*value ==
'\0')
return (sp !=
NULL);
126 if (*value ==
'T' || *value ==
't' ||
127 *value ==
'Y' || *value ==
'y' || *value ==
'1') {
129 }
else if (*value ==
'F' || *value ==
'f' ||
130 *value ==
'N' || *value ==
'n' || *value ==
'0') {
141 doubleval = strtofloat(value);
143 if (sscanf(value,
"%lf", &doubleval) == 1)
147 return (sp || ip || bp || dp);
165 snprintf(buf,
sizeof(buf),
"%d",
inT32(*ip));
173 *value =
BOOL8(*bp) ?
"1":
"0";
181 snprintf(buf,
sizeof(buf),
"%g",
double(*dp));
190 int num_iterations = (member_params ==
NULL) ? 1 : 2;
191 for (v = 0; v < num_iterations; ++v) {
193 for (i = 0; i < vec->
int_params.size(); ++i) {
194 fprintf(fp,
"%s\t%d\n", vec->
int_params[i]->name_str(),
198 fprintf(fp,
"%s\t%d\n", vec->
bool_params[i]->name_str(),
static bool GetParamAsString(const char *name, const ParamsVectors *member_params, STRING *value)
tesseract::ParamsVectors * GlobalParams()
void set_value(const STRING &value)
bool constraint_ok(SetParamConstraint constraint) const
static bool ReadParamsFile(const char *file, SetParamConstraint constraint, ParamsVectors *member_params)
static bool ReadParamsFromFp(FILE *fp, inT64 end_offset, SetParamConstraint constraint, ParamsVectors *member_params)
GenericVector< IntParam * > int_params
GenericVector< DoubleParam * > double_params
void set_value(BOOL8 value)
void set_value(inT32 value)
const char * string() const
static bool SetParam(const char *name, const char *value, SetParamConstraint constraint, ParamsVectors *member_params)
GenericVector< StringParam * > string_params
void set_value(double value)
DLLSYM void tprintf(const char *format,...)
GenericVector< BoolParam * > bool_params
static void PrintParams(FILE *fp, const ParamsVectors *member_params)