summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '3rdParty/Boost/src/libs/program_options/src/options_description.cpp')
-rw-r--r--3rdParty/Boost/src/libs/program_options/src/options_description.cpp56
1 files changed, 41 insertions, 15 deletions
diff --git a/3rdParty/Boost/src/libs/program_options/src/options_description.cpp b/3rdParty/Boost/src/libs/program_options/src/options_description.cpp
index 0d8dfd4..343bd30 100644
--- a/3rdParty/Boost/src/libs/program_options/src/options_description.cpp
+++ b/3rdParty/Boost/src/libs/program_options/src/options_description.cpp
@@ -137,6 +137,31 @@ namespace boost { namespace program_options {
return m_short_name;
}
+ std::string
+ option_description::canonical_display_name(int prefix_style) const
+ {
+ if (!m_long_name.empty())
+ {
+ if (prefix_style == command_line_style::allow_long)
+ return "--" + m_long_name;
+ if (prefix_style == command_line_style::allow_long_disguise)
+ return "-" + m_long_name;
+ }
+ // sanity check: m_short_name[0] should be '-' or '/'
+ if (m_short_name.length() == 2)
+ {
+ if (prefix_style == command_line_style::allow_slash_for_short)
+ return string("/") + m_short_name[1];
+ if (prefix_style == command_line_style::allow_dash_for_short)
+ return string("-") + m_short_name[1];
+ }
+ if (!m_long_name.empty())
+ return m_long_name;
+ else
+ return m_short_name;
+ }
+
+
const std::string&
option_description::long_name() const
{
@@ -174,10 +199,13 @@ namespace boost { namespace program_options {
option_description::format_name() const
{
if (!m_short_name.empty())
- return string(m_short_name).append(" [ --").
- append(m_long_name).append(" ]");
- else
- return string("--").append(m_long_name);
+ {
+ return m_long_name.empty()
+ ? m_short_name
+ : string(m_short_name).append(" [ --").
+ append(m_long_name).append(" ]");
+ }
+ return string("--").append(m_long_name);
}
std::string
@@ -289,7 +317,7 @@ namespace boost { namespace program_options {
const option_description* d = find_nothrow(name, approx,
long_ignore_case, short_ignore_case);
if (!d)
- boost::throw_exception(unknown_option(name));
+ boost::throw_exception(unknown_option());
return *d;
}
@@ -337,8 +365,7 @@ namespace boost { namespace program_options {
}
}
if (full_matches.size() > 1)
- boost::throw_exception(
- ambiguous_option(name, full_matches));
+ boost::throw_exception(ambiguous_option(full_matches));
// If we have a full match, and an approximate match,
// ignore approximate match instead of reporting error.
@@ -346,8 +373,7 @@ namespace boost { namespace program_options {
// "--all" on the command line should select the first one,
// without ambiguity.
if (full_matches.empty() && approximate_matches.size() > 1)
- boost::throw_exception(
- ambiguous_option(name, approximate_matches));
+ boost::throw_exception(ambiguous_option(approximate_matches));
return found.get();
}
@@ -396,7 +422,7 @@ namespace boost { namespace program_options {
if (count(par.begin(), par.end(), '\t') > 1)
{
boost::throw_exception(program_options::error(
- "Only one tab per paragraph is allowed"));
+ "Only one tab per paragraph is allowed in the options description"));
}
// erase tab from string
@@ -443,7 +469,7 @@ namespace boost { namespace program_options {
// Take care to never increment the iterator past
// the end, since MSVC 8.0 (brokenly), assumes that
// doing that, even if no access happens, is a bug.
- unsigned remaining = distance(line_begin, par_end);
+ unsigned remaining = static_cast<unsigned>(std::distance(line_begin, par_end));
string::const_iterator line_end = line_begin +
((remaining < line_length) ? remaining : line_length);
@@ -463,7 +489,7 @@ namespace boost { namespace program_options {
{
// is last_space within the second half ot the
// current line
- if (static_cast<unsigned>(distance(last_space, line_end)) <
+ if (static_cast<unsigned>(std::distance(last_space, line_end)) <
(line_length / 2))
{
line_end = last_space;
@@ -476,8 +502,8 @@ namespace boost { namespace program_options {
if (first_line)
{
- indent += par_indent;
- line_length -= par_indent; // there's less to work with now
+ indent += static_cast<unsigned>(par_indent);
+ line_length -= static_cast<unsigned>(par_indent); // there's less to work with now
first_line = false;
}
@@ -566,7 +592,7 @@ namespace boost { namespace program_options {
os.put(' ');
}
} else {
- for(unsigned pad = first_column_width - ss.str().size(); pad > 0; --pad)
+ for(unsigned pad = first_column_width - static_cast<unsigned>(ss.str().size()); pad > 0; --pad)
{
os.put(' ');
}