The class SimpleOptions is an implementation of OptionsItf that allows setting and getting option values programmatically, i.e., via getter and setter methods. More...
#include <simple-options.h>
Classes | |
struct | OptionInfo |
Public Types | |
enum | OptionType { kBool, kInt32, kUint32, kFloat, kDouble, kString } |
Public Member Functions | |
SimpleOptions () | |
virtual | ~SimpleOptions () |
void | Register (const std::string &name, bool *ptr, const std::string &doc) |
void | Register (const std::string &name, int32 *ptr, const std::string &doc) |
void | Register (const std::string &name, uint32 *ptr, const std::string &doc) |
void | Register (const std::string &name, float *ptr, const std::string &doc) |
void | Register (const std::string &name, double *ptr, const std::string &doc) |
void | Register (const std::string &name, std::string *ptr, const std::string &doc) |
bool | SetOption (const std::string &key, const bool &value) |
bool | SetOption (const std::string &key, const int32 &value) |
bool | SetOption (const std::string &key, const uint32 &value) |
bool | SetOption (const std::string &key, const float &value) |
bool | SetOption (const std::string &key, const double &value) |
bool | SetOption (const std::string &key, const std::string &value) |
bool | SetOption (const std::string &key, const char *value) |
bool | GetOption (const std::string &key, bool *value) |
bool | GetOption (const std::string &key, int32 *value) |
bool | GetOption (const std::string &key, uint32 *value) |
bool | GetOption (const std::string &key, float *value) |
bool | GetOption (const std::string &key, double *value) |
bool | GetOption (const std::string &key, std::string *value) |
std::vector< std::pair< std::string, OptionInfo > > | GetOptionInfoList () |
bool | GetOptionType (const std::string &key, OptionType *type) |
Public Member Functions inherited from OptionsItf | |
virtual | ~OptionsItf () |
Private Attributes | |
std::vector< std::pair< std::string, OptionInfo > > | option_info_list_ |
std::map< std::string, bool * > | bool_map_ |
std::map< std::string, int32 * > | int_map_ |
std::map< std::string, uint32 * > | uint_map_ |
std::map< std::string, float * > | float_map_ |
std::map< std::string, double * > | double_map_ |
std::map< std::string, std::string * > | string_map_ |
The class SimpleOptions is an implementation of OptionsItf that allows setting and getting option values programmatically, i.e., via getter and setter methods.
It doesn't provide any command line parsing functionality. The class ParseOptions should be used for command-line options.
Definition at line 38 of file simple-options.h.
enum OptionType |
Enumerator | |
---|---|
kBool | |
kInt32 | |
kUint32 | |
kFloat | |
kDouble | |
kString |
Definition at line 73 of file simple-options.h.
|
inline |
Definition at line 40 of file simple-options.h.
|
inlinevirtual |
Definition at line 43 of file simple-options.h.
References SimpleOptions::GetOption(), SimpleOptions::Register(), and SimpleOptions::SetOption().
Definition at line 140 of file simple-options.cc.
References SimpleOptions::bool_map_, and kaldi::GetOptionImpl().
Referenced by SimpleOptions::~SimpleOptions().
Definition at line 144 of file simple-options.cc.
References kaldi::GetOptionImpl(), and SimpleOptions::int_map_.
bool GetOption | ( | const std::string & | key, |
uint32 * | value | ||
) |
Definition at line 148 of file simple-options.cc.
References kaldi::GetOptionImpl(), and SimpleOptions::uint_map_.
Definition at line 152 of file simple-options.cc.
References SimpleOptions::float_map_, and kaldi::GetOptionImpl().
bool GetOption | ( | const std::string & | key, |
double * | value | ||
) |
Definition at line 156 of file simple-options.cc.
References SimpleOptions::double_map_, and kaldi::GetOptionImpl().
bool GetOption | ( | const std::string & | key, |
std::string * | value | ||
) |
Definition at line 160 of file simple-options.cc.
References kaldi::GetOptionImpl(), and SimpleOptions::string_map_.
std::vector< std::pair< std::string, SimpleOptions::OptionInfo > > GetOptionInfoList | ( | ) |
Definition at line 165 of file simple-options.cc.
References SimpleOptions::option_info_list_.
bool GetOptionType | ( | const std::string & | key, |
OptionType * | type | ||
) |
Definition at line 169 of file simple-options.cc.
References SimpleOptions::option_info_list_.
Referenced by kaldi::UnitTestSimpleOptions().
|
virtual |
Implements OptionsItf.
Definition at line 26 of file simple-options.cc.
References SimpleOptions::bool_map_, SimpleOptions::kBool, and SimpleOptions::option_info_list_.
Referenced by kaldi::UnitTestSimpleOptions(), and SimpleOptions::~SimpleOptions().
|
virtual |
Implements OptionsItf.
Definition at line 33 of file simple-options.cc.
References SimpleOptions::int_map_, SimpleOptions::kInt32, and SimpleOptions::option_info_list_.
|
virtual |
Implements OptionsItf.
Definition at line 40 of file simple-options.cc.
References SimpleOptions::kUint32, SimpleOptions::option_info_list_, and SimpleOptions::uint_map_.
|
virtual |
Implements OptionsItf.
Definition at line 47 of file simple-options.cc.
References SimpleOptions::float_map_, SimpleOptions::kFloat, and SimpleOptions::option_info_list_.
|
virtual |
Implements OptionsItf.
Definition at line 54 of file simple-options.cc.
References SimpleOptions::double_map_, SimpleOptions::kDouble, and SimpleOptions::option_info_list_.
|
virtual |
Implements OptionsItf.
Definition at line 61 of file simple-options.cc.
References SimpleOptions::kString, SimpleOptions::option_info_list_, and SimpleOptions::string_map_.
Definition at line 78 of file simple-options.cc.
References SimpleOptions::bool_map_, and kaldi::SetOptionImpl().
Referenced by kaldi::UnitTestSimpleOptions(), and SimpleOptions::~SimpleOptions().
Definition at line 82 of file simple-options.cc.
References SimpleOptions::int_map_, kaldi::SetOptionImpl(), and SimpleOptions::uint_map_.
bool SetOption | ( | const std::string & | key, |
const uint32 & | value | ||
) |
Definition at line 91 of file simple-options.cc.
References SimpleOptions::int_map_, kaldi::SetOptionImpl(), and SimpleOptions::uint_map_.
Definition at line 100 of file simple-options.cc.
References SimpleOptions::double_map_, SimpleOptions::float_map_, and kaldi::SetOptionImpl().
bool SetOption | ( | const std::string & | key, |
const double & | value | ||
) |
Definition at line 109 of file simple-options.cc.
References SimpleOptions::double_map_, SimpleOptions::float_map_, and kaldi::SetOptionImpl().
bool SetOption | ( | const std::string & | key, |
const std::string & | value | ||
) |
Definition at line 118 of file simple-options.cc.
References kaldi::SetOptionImpl(), and SimpleOptions::string_map_.
bool SetOption | ( | const std::string & | key, |
const char * | value | ||
) |
Definition at line 123 of file simple-options.cc.
References kaldi::SetOptionImpl(), and SimpleOptions::string_map_.
|
private |
Definition at line 103 of file simple-options.h.
Referenced by SimpleOptions::GetOption(), SimpleOptions::Register(), and SimpleOptions::SetOption().
|
private |
Definition at line 107 of file simple-options.h.
Referenced by SimpleOptions::GetOption(), SimpleOptions::Register(), and SimpleOptions::SetOption().
|
private |
Definition at line 106 of file simple-options.h.
Referenced by SimpleOptions::GetOption(), SimpleOptions::Register(), and SimpleOptions::SetOption().
|
private |
Definition at line 104 of file simple-options.h.
Referenced by SimpleOptions::GetOption(), SimpleOptions::Register(), and SimpleOptions::SetOption().
|
private |
Definition at line 100 of file simple-options.h.
Referenced by SimpleOptions::GetOptionInfoList(), SimpleOptions::GetOptionType(), and SimpleOptions::Register().
|
private |
Definition at line 108 of file simple-options.h.
Referenced by SimpleOptions::GetOption(), SimpleOptions::Register(), and SimpleOptions::SetOption().
|
private |
Definition at line 105 of file simple-options.h.
Referenced by SimpleOptions::GetOption(), SimpleOptions::Register(), and SimpleOptions::SetOption().