cmdline.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // Copyright Vladimir Prus 2004.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt
  4. // or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BOOST_CMDLINE_HPP_VP_2004_03_13
  6. #define BOOST_CMDLINE_HPP_VP_2004_03_13
  7. namespace boost { namespace program_options { namespace command_line_style {
  8. /** Various possible styles of options.
  9. There are "long" options, which start with "--" and "short",
  10. which start with either "-" or "/". Both kinds can be allowed or
  11. disallowed, see allow_long and allow_short. The allowed character
  12. for short options is also configurable.
  13. Option's value can be specified in the same token as name
  14. ("--foo=bar"), or in the next token.
  15. It's possible to introduce long options by the same character as
  16. short options, see allow_long_disguise.
  17. Finally, guessing (specifying only prefix of option) and case
  18. insensitive processing are supported.
  19. */
  20. enum style_t {
  21. /// Allow "--long_name" style
  22. allow_long = 1,
  23. /// Allow "-<single character" style
  24. allow_short = allow_long << 1,
  25. /// Allow "-" in short options
  26. allow_dash_for_short = allow_short << 1,
  27. /// Allow "/" in short options
  28. allow_slash_for_short = allow_dash_for_short << 1,
  29. /** Allow option parameter in the same token
  30. for long option, like in
  31. @verbatim
  32. --foo=10
  33. @endverbatim
  34. */
  35. long_allow_adjacent = allow_slash_for_short << 1,
  36. /** Allow option parameter in the next token for
  37. long options. */
  38. long_allow_next = long_allow_adjacent << 1,
  39. /** Allow option parameter in the same token for
  40. short options. */
  41. short_allow_adjacent = long_allow_next << 1,
  42. /** Allow option parameter in the next token for
  43. short options. */
  44. short_allow_next = short_allow_adjacent << 1,
  45. /** Allow to merge several short options together,
  46. so that "-s -k" become "-sk". All of the options
  47. but last should accept no parameter. For example, if
  48. "-s" accept a parameter, then "k" will be taken as
  49. parameter, not another short option.
  50. Dos-style short options cannot be sticky.
  51. */
  52. allow_sticky = short_allow_next << 1,
  53. /** Allow abbreviated spellings for long options,
  54. if they unambiguously identify long option.
  55. No long option name should be prefix of other
  56. long option name if guessing is in effect.
  57. */
  58. allow_guessing = allow_sticky << 1,
  59. /** Ignore the difference in case for long options.
  60. */
  61. long_case_insensitive = allow_guessing << 1,
  62. /** Ignore the difference in case for short options.
  63. */
  64. short_case_insensitive = long_case_insensitive << 1,
  65. /** Ignore the difference in case for all options.
  66. */
  67. case_insensitive = (long_case_insensitive | short_case_insensitive),
  68. /** Allow long options with single option starting character,
  69. e.g <tt>-foo=10</tt>
  70. */
  71. allow_long_disguise = short_case_insensitive << 1,
  72. /** The more-or-less traditional unix style. */
  73. unix_style = (allow_short | short_allow_adjacent | short_allow_next
  74. | allow_long | long_allow_adjacent | long_allow_next
  75. | allow_sticky | allow_guessing
  76. | allow_dash_for_short),
  77. /** The default style. */
  78. default_style = unix_style
  79. };
  80. }}}
  81. #endif