| 630 | } |
| 631 | |
| 632 | inline std::pair<std::string, std::string> SplitSwitchDef(const std::string &text) |
| 633 | { |
| 634 | std::string short_sw, long_sw; |
| 635 | const char *pdata = text.c_str(); |
| 636 | if (isalnum(*pdata) && *(pdata + 1) == ',') { |
| 637 | short_sw = std::string(1, *pdata); |
| 638 | pdata += 2; |
| 639 | } |
| 640 | while (*pdata == ' ') { pdata += 1; } |
| 641 | if (isalnum(*pdata)) { |
| 642 | const char *store = pdata; |
| 643 | pdata += 1; |
| 644 | while (isalnum(*pdata) || *pdata == '-' || *pdata == '_') { |
| 645 | pdata += 1; |
| 646 | } |
| 647 | if (*pdata == '\0') { |
| 648 | long_sw = std::string(store, pdata - store); |
| 649 | } else { |
| 650 | throw_or_mimic<invalid_option_format_error>(text); |
| 651 | } |
| 652 | } |
| 653 | return std::pair<std::string, std::string>(short_sw, long_sw); |
| 654 | } |
| 655 | |
| 656 | inline ArguDesc ParseArgument(const char *arg, bool &matched) |
| 657 | { |