tesseract v5.3.3.20231005
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) const
 
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 232 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 234 of file params.h.

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

◆ ~StringParam()

tesseract::StringParam::~StringParam ( )
inline

Definition at line 242 of file params.h.

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

Member Function Documentation

◆ c_str()

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

Definition at line 248 of file params.h.

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

◆ contains()

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

Definition at line 251 of file params.h.

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

◆ empty()

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

Definition at line 254 of file params.h.

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

◆ operator std::string &()

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

Definition at line 245 of file params.h.

245 {
246 return value_;
247 }

◆ operator=()

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

Definition at line 260 of file params.h.

260 {
261 value_ = value;
262 }

◆ operator==()

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

Definition at line 257 of file params.h.

257 {
258 return value_ == other;
259 }

◆ ResetFrom()

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

Definition at line 269 of file params.h.

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

◆ ResetToDefault()

void tesseract::StringParam::ResetToDefault ( )
inline

Definition at line 266 of file params.h.

266 {
267 value_ = default_;
268 }

◆ set_value()

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

Definition at line 263 of file params.h.

263 {
264 value_ = value;
265 }

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