libopenfpga/libopenfpgashell/src/command.cpp
/* Add an option without required values */
Add an option without required values
Add an option without required values
CommandOptionId Command::add_option(const char* name,
                                    const bool& option_required, 
                                    const char* description) {
  std::map<std::string, CommandOptionId>::const_iterator name_it = option_name2ids_.find(std::string(name));
  if (name_it != option_name2ids_.end()) {
    return CommandOptionId::INVALID();
  }
  CommandOptionId option = CommandOptionId(option_ids_.size());
  option_ids_.push_back(option);
  option_names_.push_back(std::string(name));
  option_short_names_.emplace_back();
  option_required_.push_back(option_required);
  option_require_value_types_.push_back(NUM_OPT_VALUE_TYPES);
  option_description_.push_back(std::string(description));
  option_name2ids_[std::string(name)] = option;
  return option;
}
CommandOptionId Command :: add_option ( const char * name , const bool & option_required , const char * description ) { std :: map < std :: string , CommandOptionId > :: const_iterator name_it = option_name2ids_ . find ( std :: string ( name ) ) ; if ( name_it != option_name2ids_ . end ( ) ) { return CommandOptionId :: INVALID ( ) ; } CommandOptionId option = CommandOptionId ( option_ids_ . size ( ) ) ; option_ids_ . push_back ( option ) ; option_names_ . push_back ( std :: string ( name ) ) ; option_short_names_ . emplace_back ( ) ; option_required_ . push_back ( option_required ) ; option_require_value_types_ . push_back ( NUM_OPT_VALUE_TYPES ) ; option_description_ . push_back ( std :: string ( description ) ) ; option_name2ids_ [ std :: string ( name ) ] = option ; return option ; }
Add an option without required values
Add an option without required values
/* Ensure that the name is unique in the option list */ /* This is a legal name. we can create a new id */ /* Register the name and short name in the name2id map */