tesseract 5.2.0
Loading...
Searching...
No Matches
tesseract::StringParam Class Reference

#include <params.h>

Inheritance diagram for tesseract::StringParam:
tesseract::Param

Public Member Functions

 StringParam (const char *value, const char *name, const char *comment, bool init, ParamsVectors *vec)
 
 ~StringParam ()
 
 operator std::string & ()
 
const char * c_str () const
 
bool contains (char c) const
 
bool empty () const
 
bool operator== (const std::string &other)
 
void operator= (const std::string &value)
 
void set_value (const std::string &value)
 
void ResetToDefault ()
 
void ResetFrom (const ParamsVectors *vec)
 
- Public Member Functions inherited from tesseract::Param
 ~Param ()=default
 
const char * name_str () const
 
const char * info_str () const
 
bool is_init () const
 
bool is_debug () const
 
bool constraint_ok (SetParamConstraint constraint) const
 

Additional Inherited Members

- Protected Member Functions inherited from tesseract::Param
 Param (const char *name, const char *comment, bool init)
 
- Protected Attributes inherited from tesseract::Param
const char * name_
 
const char * info_
 
bool init_
 
bool debug_
 

Detailed Description

Definition at line 231 of file params.h.

Constructor & Destructor Documentation

◆ StringParam()

tesseract::StringParam::StringParam ( const char *  value,
const char *  name,
const char *  comment,
bool  init,
ParamsVectors vec 
)
inline

Definition at line 233 of file params.h.

235 : Param(name, comment, init) {
236 value_ = value;
237 default_ = value;
238 params_vec_ = &(vec->string_params);
239 vec->string_params.push_back(this);
240 }
Param(const char *name, const char *comment, bool init)
Definition: params.h:136

◆ ~StringParam()

tesseract::StringParam::~StringParam ( )
inline

Definition at line 241 of file params.h.

241 {
242 ParamUtils::RemoveParam<StringParam>(this, params_vec_);
243 }

Member Function Documentation

◆ c_str()

const char * tesseract::StringParam::c_str ( ) const
inline

Definition at line 247 of file params.h.

247 {
248 return value_.c_str();
249 }

◆ contains()

bool tesseract::StringParam::contains ( char  c) const
inline

Definition at line 250 of file params.h.

250 {
251 return value_.find(c) != std::string::npos;
252 }

◆ empty()

bool tesseract::StringParam::empty ( ) const
inline

Definition at line 253 of file params.h.

253 {
254 return value_.empty();
255 }

◆ operator std::string &()

tesseract::StringParam::operator std::string & ( )
inline

Definition at line 244 of file params.h.

244 {
245 return value_;
246 }

◆ operator=()

void tesseract::StringParam::operator= ( const std::string &  value)
inline

Definition at line 259 of file params.h.

259 {
260 value_ = value;
261 }

◆ operator==()

bool tesseract::StringParam::operator== ( const std::string &  other)
inline

Definition at line 256 of file params.h.

256 {
257 return value_ == other;
258 }

◆ ResetFrom()

void tesseract::StringParam::ResetFrom ( const ParamsVectors vec)
inline

Definition at line 268 of file params.h.

268 {
269 for (auto *param : vec->string_params) {
270 if (strcmp(param->name_str(), name_) == 0) {
271 // printf("overriding param %s=%s by =%s\n", name_, value_,
272 // param->c_str());
273 value_ = *param;
274 break;
275 }
276 }
277 }
const char * name_
Definition: params.h:141

◆ ResetToDefault()

void tesseract::StringParam::ResetToDefault ( )
inline

Definition at line 265 of file params.h.

265 {
266 value_ = default_;
267 }

◆ set_value()

void tesseract::StringParam::set_value ( const std::string &  value)
inline

Definition at line 262 of file params.h.

262 {
263 value_ = value;
264 }

The documentation for this class was generated from the following file: