blob: cb6a1452404f19d0bdb6977e8e03bd38faa8c12f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// Copyright Vladimir Prus 2004.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PROGRAM_OPTIONS_SOURCE
# define BOOST_PROGRAM_OPTIONS_SOURCE
#endif
#include <boost/program_options/config.hpp>
#include <boost/program_options/positional_options.hpp>
#include <boost/limits.hpp>
#include <cassert>
namespace boost { namespace program_options {
positional_options_description::positional_options_description()
{}
positional_options_description&
positional_options_description::add(const char* name, int max_count)
{
assert(max_count != -1 || m_trailing.empty());
if (max_count == -1)
m_trailing = name;
else {
m_names.resize(m_names.size() + max_count, name);
}
return *this;
}
unsigned
positional_options_description::max_total_count() const
{
return m_trailing.empty() ?
static_cast<unsigned>(m_names.size()) : (std::numeric_limits<unsigned>::max)();
}
const std::string&
positional_options_description::name_for_position(unsigned position) const
{
assert(position < max_total_count());
if (position < m_names.size())
return m_names[position];
else
return m_trailing;
}
}}
|