Changeset 1426 for trunk/yat/utility/CommandLine.cc
- Timestamp:
- Aug 21, 2008, 12:26:31 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/yat/utility/CommandLine.cc
r1275 r1426 56 56 void CommandLine::add(Option& option) 57 57 { 58 if (option.long_name().size()) 58 if (option.long_name().size()) { 59 if (long_options_.find(option.long_name())!=long_options_.end()) { 60 std::stringstream ss; 61 ss << "yat::utility::Commandline: two options with long_name: " 62 << option.long_name(); 63 throw std::runtime_error(ss.str()); 64 } 59 65 long_options_[option.long_name()] = &option; 60 if (option.short_name()) 66 } 67 if (option.short_name()) { 68 if (short_options_.find(option.short_name())!=short_options_.end()) { 69 std::stringstream ss; 70 ss << "yat::utility::Commandline: two options with short_name: " 71 << option.short_name(); 72 throw std::runtime_error(ss.str()); 73 } 61 74 short_options_[option.short_name()] = &option; 75 } 62 76 if (option.long_name().size() || option.short_name()) 63 77 options_.push_back(&option); 64 78 // allow `no-switch' for option `switch' 65 79 OptionSwitch* o = dynamic_cast<OptionSwitch*>(&option); 80 std::string no_name = std::string("no-")+option.long_name(); 66 81 if (option.long_name().size() && o && 67 !( o->long_name().size()>2 && o->long_name().substr(0,3)=="no-")) 68 long_options_[std::string("no-")+option.long_name()] = &option; 82 !( o->long_name().size()>2 && o->long_name().substr(0,3)=="no-") && 83 long_options_.find(no_name)==long_options_.end()) 84 long_options_[no_name] = &option; 69 85 } 70 86
Note: See TracChangeset
for help on using the changeset viewer.