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