source: NonGTP/Boost/boost/program_options/option.hpp @ 857

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