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_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 |
7 | #define BOOST_PROGRAM_OPTIONS_POSITIONAL_OPTIONS_VP_2004_03_02 |
8 | |
9 | #include <boost/program_options/config.hpp> |
10 | |
11 | #include <vector> |
12 | #include <string> |
13 | |
14 | #if defined(BOOST_MSVC) |
15 | # pragma warning (push) |
16 | # pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::positional_options_description' |
17 | #endif |
18 | |
19 | namespace boost { namespace program_options { |
20 | |
21 | /** Describes positional options. |
22 | |
23 | The class allows to guess option names for positional options, which |
24 | are specified on the command line and are identified by the position. |
25 | The class uses the information provided by the user to associate a name |
26 | with every positional option, or tell that no name is known. |
27 | |
28 | The primary assumption is that only the relative order of the |
29 | positional options themselves matters, and that any interleaving |
30 | ordinary options don't affect interpretation of positional options. |
31 | |
32 | The user initializes the class by specifying that first N positional |
33 | options should be given the name X1, following M options should be given |
34 | the name X2 and so on. |
35 | */ |
36 | class BOOST_PROGRAM_OPTIONS_DECL positional_options_description { |
37 | public: |
38 | positional_options_description(); |
39 | |
40 | /** Species that up to 'max_count' next positional options |
41 | should be given the 'name'. The value of '-1' means 'unlimited'. |
42 | No calls to 'add' can be made after call with 'max_value' equal to |
43 | '-1'. |
44 | */ |
45 | positional_options_description& |
46 | add(const char* name, int max_count); |
47 | |
48 | /** Returns the maximum number of positional options that can |
49 | be present. Can return (numeric_limits<unsigned>::max)() to |
50 | indicate unlimited number. */ |
51 | unsigned max_total_count() const; |
52 | |
53 | /** Returns the name that should be associated with positional |
54 | options at 'position'. |
55 | Precondition: position < max_total_count() |
56 | */ |
57 | const std::string& name_for_position(unsigned position) const; |
58 | |
59 | private: |
60 | // List of names corresponding to the positions. If the number of |
61 | // positions is unlimited, then the last name is stored in |
62 | // m_trailing; |
63 | std::vector<std::string> m_names; |
64 | std::string m_trailing; |
65 | }; |
66 | |
67 | }} |
68 | |
69 | #if defined(BOOST_MSVC) |
70 | # pragma warning (pop) |
71 | #endif |
72 | |
73 | #endif |
74 | |
75 | |