| 478 | |
| 479 | |
| 480 | std::string SingleCommandOption::getopt_optstring() |
| 481 | { |
| 482 | if (0 == shortopt) |
| 483 | { |
| 484 | return ""; |
| 485 | } |
| 486 | |
| 487 | std::stringstream ret; |
| 488 | ret << shortopt; |
| 489 | |
| 490 | switch (getopt_option.has_arg) |
| 491 | { |
| 492 | case optional_argument: |
| 493 | ret << ":"; |
| 494 | // The fall-through is by design. |
| 495 | // optional arguments should have two colons |
| 496 | case required_argument: |
| 497 | ret << ":"; |
| 498 | break; |
| 499 | default: |
| 500 | break; |
| 501 | } |
| 502 | |
| 503 | return ret.str(); |
| 504 | } |
| 505 | |
| 506 | |
| 507 | bool SingleCommandOption::check_short_option(const char o) |