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