9 static const char rcsid[] __attribute__((used)) =
"$Id: CommandLineOption.cpp 1653 2016-02-28 19:54:59Z sella $";
11 #include "CommandLineOption.h"
17 using namespace sella::util;
19 CommandLineOption::CommandLineOption(
char opt,
const std::string &option,
const std::string &usage,
const std::string &label,
const std::string &value)
throw () :
26 argumented(label.size() > 0)
30 if (((opt >=
'a') && (opt <=
'z')) || ((opt >=
'A') && (opt <=
'Z')) || ((opt >=
'0') && (opt <=
'9'))) {
31 if (this->argumented) {
32 snprintf(buffer,
sizeof(buffer),
" -%c,--%s=%s", opt, option.c_str(), label.c_str());
34 snprintf(buffer,
sizeof(buffer),
" -%c,--%s", opt, option.c_str());
37 if (this->argumented) {
38 snprintf(buffer,
sizeof(buffer),
" --%s=%s", option.c_str(), label.c_str());
40 snprintf(buffer,
sizeof(buffer),
" --%s", option.c_str());
46 CommandLineOption::CommandLineOption() throw () :
60 option(copy.getOption()),
62 usage(copy.getUsage()),
63 value(copy.getValue()),
67 argumented(copy.getArgumented())
70 CommandLineOption::~CommandLineOption() throw () {
79 this->setOpt(other.getOpt());
80 this->setOption(other.getOption());
82 this->setUsage(other.getUsage());
83 this->setValue(other.getValue());
85 this->setTags(other.getTags());
87 this->setArgumented(other.getArgumented());
92 void CommandLineOption::setOpt(
char opt)
throw () {
96 void CommandLineOption::setOption(
const std::string &option)
throw () {
97 this->option = option;
100 void CommandLineOption::setUsage(
const std::string &usage)
throw () {
104 void CommandLineOption::setValue(
const std::string &value)
throw () {
108 void CommandLineOption::setTags(
const std::string &tags)
throw () {
112 void CommandLineOption::setArgumented(
bool value)
throw () {
113 this->argumented = value;
116 char CommandLineOption::getOpt()
const throw () {
120 const std::string & CommandLineOption::getOption()
const throw () {
124 const std::string & CommandLineOption::getUsage()
const throw () {
128 const std::string & CommandLineOption::getValue()
const throw () {
132 const std::string & CommandLineOption::getTags()
const throw () {
136 bool CommandLineOption::getArgumented()
const throw () {
137 return this->argumented;