| 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 | namespace 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 | positional_options_description& |
|---|
| 41 | add(const char* name, int max_count); |
|---|
| 42 | |
|---|
| 43 | /** Returns the maximum number of positional options that can |
|---|
| 44 | be present. Can return (numeric_limits<unsigned>::max)() to |
|---|
| 45 | indicate unlimited number. */ |
|---|
| 46 | unsigned max_total_count() const; |
|---|
| 47 | |
|---|
| 48 | /** Returns the name that should be associated with positional |
|---|
| 49 | options at 'position'. |
|---|
| 50 | Precondition: position < max_total_count() |
|---|
| 51 | */ |
|---|
| 52 | const std::string& name_for_position(unsigned position) const; |
|---|
| 53 | |
|---|
| 54 | private: |
|---|
| 55 | // List of names corresponding to the positions. If the number of |
|---|
| 56 | // positions is unlimited, then the last name is stored in |
|---|
| 57 | // m_trailing; |
|---|
| 58 | std::vector<std::string> m_names; |
|---|
| 59 | std::string m_trailing; |
|---|
| 60 | }; |
|---|
| 61 | |
|---|
| 62 | }} |
|---|
| 63 | |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|