#include <params.h>
|
| static bool | ReadParamsFile (const char *file, SetParamConstraint constraint, ParamsVectors *member_params) |
| |
| static bool | ReadParamsFromFp (FILE *fp, inT64 end_offset, SetParamConstraint constraint, ParamsVectors *member_params) |
| |
| static bool | SetParam (const char *name, const char *value, SetParamConstraint constraint, ParamsVectors *member_params) |
| |
| template<class T > |
| static T * | FindParam (const char *name, const GenericVector< T * > &global_vec, const GenericVector< T * > &member_vec) |
| |
| template<class T > |
| static void | RemoveParam (T *param_ptr, GenericVector< T * > *vec) |
| |
| static bool | GetParamAsString (const char *name, const ParamsVectors *member_params, STRING *value) |
| |
| static void | PrintParams (FILE *fp, const ParamsVectors *member_params) |
| |
Definition at line 51 of file params.h.
template<class T >
| static T* tesseract::ParamUtils::FindParam |
( |
const char * |
name, |
|
|
const GenericVector< T * > & |
global_vec, |
|
|
const GenericVector< T * > & |
member_vec |
|
) |
| |
|
inlinestatic |
Definition at line 77 of file params.h.
81 for (i = 0; i < global_vec.
size(); ++i) {
82 if (strcmp(global_vec[i]->name_str(), name) == 0)
return global_vec[i];
84 for (i = 0; i < member_vec.
size(); ++i) {
85 if (strcmp(member_vec[i]->name_str(), name) == 0)
return member_vec[i];
| bool tesseract::ParamUtils::GetParamAsString |
( |
const char * |
name, |
|
|
const ParamsVectors * |
member_params, |
|
|
STRING * |
value |
|
) |
| |
|
static |
Definition at line 150 of file params.cpp.
155 member_params->string_params);
162 member_params->int_params);
165 snprintf(buf,
sizeof(buf),
"%d",
inT32(*ip));
171 member_params->bool_params);
173 *value =
BOOL8(*bp) ?
"1":
"0";
178 member_params->double_params);
181 snprintf(buf,
sizeof(buf),
"%g",
double(*dp));
tesseract::ParamsVectors * GlobalParams()
GenericVector< IntParam * > int_params
GenericVector< DoubleParam * > double_params
const char * string() const
GenericVector< StringParam * > string_params
GenericVector< BoolParam * > bool_params
| void tesseract::ParamUtils::PrintParams |
( |
FILE * |
fp, |
|
|
const ParamsVectors * |
member_params |
|
) |
| |
|
static |
Definition at line 188 of file params.cpp.
190 int num_iterations = (member_params ==
NULL) ? 1 : 2;
191 for (v = 0; v < num_iterations; ++v) {
192 const ParamsVectors *vec = (v == 0) ?
GlobalParams() : member_params;
193 for (i = 0; i < vec->int_params.size(); ++i) {
194 fprintf(fp,
"%s\t%d\n", vec->int_params[i]->name_str(),
195 (
inT32)(*vec->int_params[i]));
197 for (i = 0; i < vec->bool_params.size(); ++i) {
198 fprintf(fp,
"%s\t%d\n", vec->bool_params[i]->name_str(),
199 (
BOOL8)(*vec->bool_params[i]));
201 for (
int i = 0; i < vec->string_params.size(); ++i) {
202 fprintf(fp,
"%s\t%s\n", vec->string_params[i]->name_str(),
203 vec->string_params[i]->string());
205 for (
int i = 0; i < vec->double_params.size(); ++i) {
206 fprintf(fp,
"%s\t%g\n", vec->double_params[i]->name_str(),
207 (double)(*vec->double_params[i]));
tesseract::ParamsVectors * GlobalParams()
Definition at line 43 of file params.cpp.
54 }
else if (*file ==
MINUS) {
62 fp = fopen(file + nameoffset,
"rb");
64 tprintf(
"read_params_file: Can't open %s\n", file + nameoffset);
static bool ReadParamsFromFp(FILE *fp, inT64 end_offset, SetParamConstraint constraint, ParamsVectors *member_params)
DLLSYM void tprintf(const char *format,...)
Definition at line 71 of file params.cpp.
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);
static bool SetParam(const char *name, const char *value, SetParamConstraint constraint, ParamsVectors *member_params)
DLLSYM void tprintf(const char *format,...)
template<class T >
| static void tesseract::ParamUtils::RemoveParam |
( |
T * |
param_ptr, |
|
|
GenericVector< T * > * |
vec |
|
) |
| |
|
inlinestatic |
Definition at line 91 of file params.h.
92 for (
int i = 0; i < vec->
size(); ++i) {
93 if ((*vec)[i] == param_ptr) {
virtual void remove(int index)
Definition at line 106 of file params.cpp.
111 member_params->string_params);
112 if (sp !=
NULL && sp->constraint_ok(constraint)) sp->set_value(value);
113 if (*value ==
'\0')
return (sp !=
NULL);
118 member_params->int_params);
119 if (ip && ip->constraint_ok(constraint) &&
120 sscanf(value,
INT32FORMAT, &intval) == 1) ip->set_value(intval);
124 member_params->bool_params);
125 if (bp !=
NULL && bp->constraint_ok(constraint)) {
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') {
131 bp->set_value(
false);
138 member_params->double_params);
139 if (dp !=
NULL && dp->constraint_ok(constraint)) {
141 doubleval = strtofloat(value);
143 if (sscanf(value,
"%lf", &doubleval) == 1)
145 dp->set_value(doubleval);
147 return (sp || ip || bp || dp);
tesseract::ParamsVectors * GlobalParams()
GenericVector< IntParam * > int_params
GenericVector< DoubleParam * > double_params
GenericVector< StringParam * > string_params
GenericVector< BoolParam * > bool_params
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/tesseract-ocr-3.02.02/ccutil/params.h
- /home/abuild/rpmbuild/BUILD/tesseract-ocr-3.02.02/ccutil/params.cpp