| 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 | |
| 14 | namespace 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() |
| 27 | : position_key(-1) |
| 28 | , unregistered(false) |
| 29 | , case_insensitive(false) |
| 30 | {} |
| 31 | basic_option(const std::string& xstring_key, |
| 32 | const std::vector< std::string> &xvalue) |
| 33 | : string_key(xstring_key) |
| 34 | , position_key(-1) |
| 35 | , value(xvalue) |
| 36 | , unregistered(false) |
| 37 | , case_insensitive(false) |
| 38 | {} |
| 39 | |
| 40 | /** String key of this option. Intentionally independent of the template |
| 41 | parameter. */ |
| 42 | std::string string_key; |
| 43 | /** Position key of this option. All options without an explicit name are |
| 44 | sequentially numbered starting from 0. If an option has explicit name, |
| 45 | 'position_key' is equal to -1. It is possible that both |
| 46 | position_key and string_key is specified, in case name is implicitly |
| 47 | added. |
| 48 | */ |
| 49 | int position_key; |
| 50 | /** Option's value */ |
| 51 | std::vector< std::basic_string<charT> > value; |
| 52 | /** The original unchanged tokens this option was |
| 53 | created from. */ |
| 54 | std::vector< std::basic_string<charT> > original_tokens; |
| 55 | /** True if option was not recognized. In that case, |
| 56 | 'string_key' and 'value' are results of purely |
| 57 | syntactic parsing of source. The original tokens can be |
| 58 | recovered from the "original_tokens" member. |
| 59 | */ |
| 60 | bool unregistered; |
| 61 | /** True if string_key has to be handled |
| 62 | case insensitive. |
| 63 | */ |
| 64 | bool case_insensitive; |
| 65 | }; |
| 66 | typedef basic_option<char> option; |
| 67 | typedef basic_option<wchar_t> woption; |
| 68 | |
| 69 | }} |
| 70 | |
| 71 | #endif |
| 72 | |