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

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