Merge branch 'develop'

This commit is contained in:
Vladimir Prus
2013-12-04 09:13:36 +04:00
9 changed files with 51 additions and 3415 deletions

View File

@@ -8,7 +8,7 @@
#ifndef PROGRAM_OPTIONS_VP_2003_05_19
#define PROGRAM_OPTIONS_VP_2003_05_19
#if _MSC_VER >= 1020
#if defined(_MSC_VER)
#pragma once
#endif

View File

@@ -105,12 +105,9 @@ namespace boost { namespace program_options {
int);
#endif
// For some reason, this declaration, which is require by the standard,
// cause gcc 3.2 to not generate code to specialization defined in
// cause msvc 7.1 to not generate code to specialization defined in
// value_semantic.cpp
#if ! ( ( BOOST_WORKAROUND(__GNUC__, <= 3) &&\
BOOST_WORKAROUND(__GNUC_MINOR__, < 3) ) || \
( BOOST_WORKAROUND(BOOST_MSVC, == 1310) ) \
)
#if ! ( BOOST_WORKAROUND(BOOST_MSVC, == 1310) )
BOOST_PROGRAM_OPTIONS_DECL void validate(boost::any& v,
const std::vector<std::string>& xs,
std::string*,

View File

@@ -25,7 +25,8 @@ namespace boost { namespace program_options {
inline std::string strip_prefixes(const std::string& text)
{
return text.substr(text.find_last_of("-/") + 1);
// "--foo-bar" -> "foo-bar"
return text.substr(text.find_first_not_of("-/"));
}
/** Base class for all errors in the library. */

View File

@@ -199,6 +199,10 @@ namespace program_options {
*/
options_description& add(const options_description& desc);
/** Find the maximum width of the option column, including options
in groups. */
unsigned get_option_column_width() const;
public:
/** Returns an object of implementation-defined type suitable for adding
options to options_description. The returned object will
@@ -229,7 +233,7 @@ namespace program_options {
/** Outputs 'desc' to the specified stream, calling 'f' to output each
option_description element. */
void print(std::ostream& os) const;
void print(std::ostream& os, unsigned width = 0) const;
private:
typedef std::map<std::string, int>::const_iterator name2index_iterator;

View File

@@ -98,7 +98,7 @@ namespace boost { namespace program_options {
void store(const basic_parsed_options<char>& options,
variables_map& m, bool);
friend BOOST_PROGRAM_OPTIONS_DECL class variables_map;
friend class BOOST_PROGRAM_OPTIONS_DECL variables_map;
};
/** Implements string->string mapping with convenient value casting

View File

@@ -455,7 +455,7 @@ namespace boost { namespace program_options { namespace detail {
// if they look like options
if (opt.value.size() <= min_tokens)
{
min_tokens -= static_cast<unsigned>(opt.value.size());
min_tokens -= static_cast<unsigned>(opt.value.size());
}
else
{

View File

@@ -604,12 +604,9 @@ namespace boost { namespace program_options {
}
}
void
options_description::print(std::ostream& os) const
unsigned
options_description::get_option_column_width() const
{
if (!m_caption.empty())
os << m_caption << ":\n";
/* Find the maximum width of the option column */
unsigned width(23);
unsigned i; // vc6 has broken for loop scoping
@@ -620,6 +617,11 @@ namespace boost { namespace program_options {
ss << " " << opt.format_name() << ' ' << opt.format_parameter();
width = (max)(width, static_cast<unsigned>(ss.str().size()));
}
/* Get width of groups as well*/
for (unsigned j = 0; j < groups.size(); ++j)
width = max(width, groups[j]->get_option_column_width());
/* this is the column were description should start, if first
column is longer, we go to a new line */
const unsigned start_of_description_column = m_line_length - m_min_description_length;
@@ -628,9 +630,20 @@ namespace boost { namespace program_options {
/* add an additional space to improve readability */
++width;
return width;
}
void
options_description::print(std::ostream& os, unsigned width) const
{
if (!m_caption.empty())
os << m_caption << ":\n";
if (!width)
width = get_option_column_width();
/* The options formatting style is stolen from Subversion. */
for (i = 0; i < m_options.size(); ++i)
for (unsigned i = 0; i < m_options.size(); ++i)
{
if (belong_to_group[i])
continue;
@@ -643,7 +656,8 @@ namespace boost { namespace program_options {
}
for (unsigned j = 0; j < groups.size(); ++j) {
os << "\n" << *groups[j];
os << "\n";
groups[j]->print(os, width);
}
}

View File

@@ -32,6 +32,7 @@ test-suite program_options :
[ po-test split_test.cpp ]
[ po-test unrecognized_test.cpp ]
[ po-test required_test.cpp : required_test.cfg ]
[ po-test exception_txt_test.cpp ]
;
exe test_convert : test_convert.cpp ;

File diff suppressed because it is too large Load Diff