Parse options string passed to file IO routines. More...
#include <FileOptions.hpp>
Public Member Functions | |
FileOptions (const char *option_string) | |
FileOptions (const FileOptions ©) | |
FileOptions & | operator= (const FileOptions ©) |
~FileOptions () | |
ErrorCode | get_null_option (const char *name) const |
Check for option with no value. More... | |
ErrorCode | get_toggle_option (const char *name, bool default_value, bool &value) const |
Check for option with boolean (true/false, yes/no) value. More... | |
ErrorCode | get_int_option (const char *name, int &value) const |
Check for option with an integer value. More... | |
ErrorCode | get_int_option (const char *name, int default_val, int &value) const |
Check for option with an integer value. Accept option with no value. More... | |
ErrorCode | get_real_option (const char *name, double &value) const |
Check for option with a double value. More... | |
ErrorCode | get_str_option (const char *name, std::string &value) const |
Check for option with any value. More... | |
ErrorCode | get_option (const char *name, std::string &value) const |
Check for option. More... | |
ErrorCode | match_option (const char *name, const char *const *values, int &index) const |
Check the string value of an option. More... | |
ErrorCode | match_option (const char *name, const char *value) const |
Check if an option matches a string value. More... | |
ErrorCode | get_ints_option (const char *name, std::vector< int > &values) const |
Check for option for which the value is a list of ints. More... | |
ErrorCode | get_reals_option (const char *name, std::vector< double > &values) const |
Check for option for which the value is a list of doubles. More... | |
ErrorCode | get_strs_option (const char *name, std::vector< std::string > &values) const |
Check for option for which the value is a list of strings. More... | |
unsigned | size () const |
bool | empty () const |
void | get_options (std::vector< std::string > &list) const |
bool | all_seen () const |
void | mark_all_seen () const |
ErrorCode | get_unseen_option (std::string &value) const |
Private Member Functions | |
ErrorCode | get_option (const char *name, const char *&value) const |
Check for option. More... | |
Static Private Member Functions | |
static bool | compare (const char *name, const char *option) |
Private Attributes | |
char * | mData |
std::vector< const char * > | mOptions |
std::vector< bool > | mSeen |
Parse options string passed to file IO routines.
This is a utility class used by file-IO-related code to parse the options string passed to Core::load_file and Core::write_file
Definition at line 37 of file FileOptions.hpp.
moab::FileOptions::FileOptions | ( | const char * | option_string | ) |
Definition at line 38 of file FileOptions.cpp.
References moab::DEFAULT_SEPARATOR, mData, mOptions, mSeen, and moab::strempty().
moab::FileOptions::FileOptions | ( | const FileOptions & | copy | ) |
Definition at line 67 of file FileOptions.cpp.
moab::FileOptions::~FileOptions | ( | ) |
bool moab::FileOptions::all_seen | ( | ) | const |
Check if all options have been looked at
Definition at line 377 of file FileOptions.cpp.
References mSeen.
Referenced by moab::AdaptiveKDTree::build_tree(), moab::BVHTree::build_tree(), moab::Core::load_file(), and moab::Core::write_file().
|
staticprivate |
Case-insensitive compare of name with option value.
Definition at line 357 of file FileOptions.cpp.
References moab::strempty().
Referenced by get_option(), and match_option().
|
inline |
true if no options
Definition at line 212 of file FileOptions.hpp.
ErrorCode moab::FileOptions::get_int_option | ( | const char * | name, |
int & | value | ||
) | const |
Check for option with an integer value.
Check for an option with an integer value
name | The option name |
value | Output. The value. |
Definition at line 119 of file FileOptions.cpp.
References ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
Referenced by moab::NCHelperEuler::init_mesh_vals(), moab::NCHelperFV::init_mesh_vals(), moab::ReadParallel::load_file(), moab::ReadMCNP5::load_file(), moab::Tqdcfr::load_file(), moab::Core::load_file(), moab::WriteHDF5Parallel::parallel_create_file(), moab::Tree::parse_common_options(), moab::ReadNC::parse_options(), moab::WriteNC::parse_options(), moab::AdaptiveKDTree::parse_options(), moab::BVHTree::parse_options(), moab::ReadHDF5::set_up_read(), moab::WriteGmsh::write_file(), moab::WriteSmf::write_file(), moab::WriteSTL::write_file(), moab::WriteVtk::write_file(), and moab::WriteHDF5::write_file().
ErrorCode moab::FileOptions::get_int_option | ( | const char * | name, |
int | default_val, | ||
int & | value | ||
) | const |
Check for option with an integer value. Accept option with no value.
Check for an option with an integer value. If the option is found but has no value specified, then pass back the user-specified default value.
\NOTE: This function will not pass back the default_val, but will instead return MB_ENTITY_NOT_FOUND if the option is not specified at all. The default value is returned only when the option is specified, but is specified w/out a value.
name | The option name |
default_val | The default value for the option. |
value | Output. The value. |
Definition at line 141 of file FileOptions.cpp.
References ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
ErrorCode moab::FileOptions::get_ints_option | ( | const char * | name, |
std::vector< int > & | values | ||
) | const |
Check for option for which the value is a list of ints.
Check for an option which is an int list. The value is expected to be a comma-separated list of int ranges, where an int range can be either a single integer value or a range of integer values separated by a dash ('-').
name | The option name |
values | Output. The list of integer values. |
Definition at line 167 of file FileOptions.cpp.
References EATSPACE, ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
Referenced by moab::ReadParallel::load_file(), main(), moab::ReadNC::parse_options(), and moab::WriteNC::parse_options().
ErrorCode moab::FileOptions::get_null_option | ( | const char * | name | ) | const |
Check for option with no value.
Check for an option w/out a value.
name | The option name |
Definition at line 111 of file FileOptions.cpp.
References ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
Referenced by moab::ReadParallel::load_file(), moab::ReadHDF5::load_file(), moab::ReadSTL::load_file(), moab::Tqdcfr::load_file(), moab::ReadMCNP5::load_one_file(), moab::WriteHDF5Parallel::parallel_create_file(), moab::ReadDamsel::parse_options(), moab::ReadNC::parse_options(), moab::WriteNC::parse_options(), moab::ReadHDF5::set_up_read(), moab::WriteNCDF::write_file(), moab::WriteSTL::write_file(), moab::WriteVtk::write_file(), moab::Core::write_file(), moab::WriteHDF5::write_file(), and moab::WriteHDF5::write_file_impl().
|
private |
Check for option.
Check for an option
name | The option name |
value | The option value, or an empty string if no value. |
Definition at line 292 of file FileOptions.cpp.
References compare(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, mOptions, and mSeen.
ErrorCode moab::FileOptions::get_option | ( | const char * | name, |
std::string & | value | ||
) | const |
Check for option.
Check for an option
name | The option name |
value | The option value, or an empty string if no value. |
Definition at line 282 of file FileOptions.cpp.
References ErrorCode, and MB_SUCCESS.
Referenced by get_int_option(), get_ints_option(), get_null_option(), get_real_option(), get_reals_option(), get_str_option(), get_strs_option(), moab::ReadParallel::load_file(), moab::ReadSmf::load_file(), moab::ReadVtk::load_file(), moab::Core::load_file(), moab::ReadHDF5::load_file_partial(), match_option(), and moab::ReadTetGen::open_file().
void moab::FileOptions::get_options | ( | std::vector< std::string > & | list | ) | const |
ErrorCode moab::FileOptions::get_real_option | ( | const char * | name, |
double & | value | ||
) | const |
Check for option with a double value.
Check for an option with a double value
name | The option name |
value | Output. The value. |
Definition at line 234 of file FileOptions.cpp.
References ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
Referenced by moab::ReadParallel::load_file(), moab::Tree::parse_common_options(), and moab::AdaptiveKDTree::parse_options().
ErrorCode moab::FileOptions::get_reals_option | ( | const char * | name, |
std::vector< double > & | values | ||
) | const |
Check for option for which the value is a list of doubles.
Check for an option which is a double list. The value is expected to be a comma-separated list of double values
name | The option name |
values | Output. The list of double values. |
Definition at line 210 of file FileOptions.cpp.
References EATSPACE, ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
Referenced by moab::ReadNC::parse_options(), and moab::WriteNC::parse_options().
ErrorCode moab::FileOptions::get_str_option | ( | const char * | name, |
std::string & | value | ||
) | const |
Check for option with any value.
Check for an option with any value.
name | The option name |
value | Output. The value. |
Definition at line 272 of file FileOptions.cpp.
References ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
Referenced by moab::NCHelperHOMME::create_mesh(), moab::ReadParallel::load_file(), moab::ReadNCDF::load_file(), moab::ReadTetGen::load_file(), moab::Tqdcfr::load_file(), moab::WriteHDF5Parallel::parallel_create_file(), moab::Tree::parse_common_options(), moab::ReadHDF5::set_up_read(), and moab::ReadNCDF::update().
ErrorCode moab::FileOptions::get_strs_option | ( | const char * | name, |
std::vector< std::string > & | values | ||
) | const |
Check for option for which the value is a list of strings.
Check for an option which is a string list. The value is expected to be a comma-separated list of string values, with no embedded spaces or commas.
name | The option name |
values | Output. The list of string values. |
Definition at line 252 of file FileOptions.cpp.
References ErrorCode, get_option(), MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::strempty().
Referenced by main(), moab::ReadNC::parse_options(), and moab::WriteNC::parse_options().
ErrorCode moab::FileOptions::get_toggle_option | ( | const char * | name, |
bool | default_value, | ||
bool & | value | ||
) | const |
Check for option with boolean (true/false, yes/no) value.
Check for an option with a true/false value. Allowable values are "true", "false", "yes", "no", "1", "0", "on", "off".
name | The option name |
default_value | The value to return if the option is not specified. |
value | The resulting value. This argument is set to the passed default value if the option is not found. |
Definition at line 333 of file FileOptions.cpp.
References ErrorCode, match_option(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, and MB_TYPE_OUT_OF_RANGE.
Referenced by moab::Tree::parse_common_options(), moab::AdaptiveKDTree::parse_options(), and moab::ReadHDF5::set_up_read().
ErrorCode moab::FileOptions::get_unseen_option | ( | std::string & | value | ) | const |
Get first unseen option
Definition at line 388 of file FileOptions.cpp.
References MB_ENTITY_NOT_FOUND, MB_SUCCESS, mOptions, and mSeen.
Referenced by moab::Core::load_file(), and moab::Core::write_file().
void moab::FileOptions::mark_all_seen | ( | ) | const |
Mark all options as seen. USed for non-root procs during bcast-delete read
Definition at line 382 of file FileOptions.cpp.
References mOptions, and mSeen.
Referenced by moab::ReadParallel::load_file(), moab::ReadCGNS::process_options(), and moab::ReadTemplate::process_options().
ErrorCode moab::FileOptions::match_option | ( | const char * | name, |
const char *const * | values, | ||
int & | index | ||
) | const |
Check the string value of an option.
Check which of a list of possible values a string option contains.
name | The option name |
values | A NULL-terminated array of C-style strings enumerating the possible option values. |
index | Output: The index into values for the option value. |
values
array. Definition at line 320 of file FileOptions.cpp.
References compare(), ErrorCode, get_option(), and MB_SUCCESS.
Referenced by get_toggle_option(), moab::ReadParallel::load_file(), moab::ReadHDF5::load_file_partial(), match_option(), moab::ReadDamsel::parse_options(), moab::ReadNC::parse_options(), moab::WriteNC::parse_options(), moab::ReadHDF5::set_up_read(), and moab::WriteHDF5::write_file_impl().
ErrorCode moab::FileOptions::match_option | ( | const char * | name, |
const char * | value | ||
) | const |
Check if an option matches a string value.
Check if the value for an option is the passed string.
name | The option name |
value | The expected value. |
Definition at line 313 of file FileOptions.cpp.
References match_option().
FileOptions & moab::FileOptions::operator= | ( | const FileOptions & | copy | ) |
Definition at line 82 of file FileOptions.cpp.
|
inline |
number of options
Definition at line 206 of file FileOptions.hpp.
Referenced by moab::Core::write_file().
|
private |
Definition at line 239 of file FileOptions.hpp.
Referenced by FileOptions(), operator=(), and ~FileOptions().
|
private |
Definition at line 240 of file FileOptions.hpp.
Referenced by FileOptions(), get_option(), get_options(), get_unseen_option(), mark_all_seen(), and operator=().
|
mutableprivate |
Definition at line 241 of file FileOptions.hpp.
Referenced by all_seen(), FileOptions(), get_option(), get_unseen_option(), mark_all_seen(), and operator=().