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_OPTION_HPP_VP_2004_02_25
|
Chris@16
|
7 #define BOOST_OPTION_HPP_VP_2004_02_25
|
Chris@16
|
8
|
Chris@16
|
9 #include <boost/program_options/config.hpp>
|
Chris@16
|
10
|
Chris@16
|
11 #include <string>
|
Chris@16
|
12 #include <vector>
|
Chris@16
|
13
|
Chris@16
|
14 namespace boost { namespace program_options {
|
Chris@16
|
15
|
Chris@16
|
16 /** Option found in input source.
|
Chris@16
|
17 Contains a key and a value. The key, in turn, can be a string (name of
|
Chris@16
|
18 an option), or an integer (position in input source) -- in case no name
|
Chris@16
|
19 is specified. The latter is only possible for command line.
|
Chris@16
|
20 The template parameter specifies the type of char used for storing the
|
Chris@16
|
21 option's value.
|
Chris@16
|
22 */
|
Chris@16
|
23 template<class charT>
|
Chris@16
|
24 class basic_option {
|
Chris@16
|
25 public:
|
Chris@16
|
26 basic_option()
|
Chris@16
|
27 : position_key(-1)
|
Chris@16
|
28 , unregistered(false)
|
Chris@16
|
29 , case_insensitive(false)
|
Chris@16
|
30 {}
|
Chris@16
|
31 basic_option(const std::string& xstring_key,
|
Chris@16
|
32 const std::vector< std::string> &xvalue)
|
Chris@16
|
33 : string_key(xstring_key)
|
Chris@16
|
34 , value(xvalue)
|
Chris@16
|
35 , unregistered(false)
|
Chris@16
|
36 , case_insensitive(false)
|
Chris@16
|
37 {}
|
Chris@16
|
38
|
Chris@16
|
39 /** String key of this option. Intentionally independent of the template
|
Chris@16
|
40 parameter. */
|
Chris@16
|
41 std::string string_key;
|
Chris@16
|
42 /** Position key of this option. All options without an explicit name are
|
Chris@16
|
43 sequentially numbered starting from 0. If an option has explicit name,
|
Chris@16
|
44 'position_key' is equal to -1. It is possible that both
|
Chris@16
|
45 position_key and string_key is specified, in case name is implicitly
|
Chris@16
|
46 added.
|
Chris@16
|
47 */
|
Chris@16
|
48 int position_key;
|
Chris@16
|
49 /** Option's value */
|
Chris@16
|
50 std::vector< std::basic_string<charT> > value;
|
Chris@16
|
51 /** The original unchanged tokens this option was
|
Chris@16
|
52 created from. */
|
Chris@16
|
53 std::vector< std::basic_string<charT> > original_tokens;
|
Chris@16
|
54 /** True if option was not recognized. In that case,
|
Chris@16
|
55 'string_key' and 'value' are results of purely
|
Chris@16
|
56 syntactic parsing of source. The original tokens can be
|
Chris@16
|
57 recovered from the "original_tokens" member.
|
Chris@16
|
58 */
|
Chris@16
|
59 bool unregistered;
|
Chris@16
|
60 /** True if string_key has to be handled
|
Chris@16
|
61 case insensitive.
|
Chris@16
|
62 */
|
Chris@16
|
63 bool case_insensitive;
|
Chris@16
|
64 };
|
Chris@16
|
65 typedef basic_option<char> option;
|
Chris@16
|
66 typedef basic_option<wchar_t> woption;
|
Chris@16
|
67
|
Chris@16
|
68 }}
|
Chris@16
|
69
|
Chris@16
|
70 #endif
|