Compare commits

..

5 Commits

Author SHA1 Message Date
Beman Dawes
08795327e0 Release 1.45.0
[SVN r66646]
2010-11-19 15:17:53 +00:00
Jürgen Hunold
0c04bde7e0 Merge 65318,65319 from ^/trunk
------------------------------------------------------------------------
r65318 | jhunold | 2010-09-06 10:43:06 +0200 (Mo, 06 Sep 2010) | 3 lines

Suppress msvc warning 4251 about templates as base classes not having a dll-interface.
Suppress msvc warning 4275 about base class std::logic_error not having a dll-interface.

------------------------------------------------------------------------
r65319 | jhunold | 2010-09-06 16:14:09 +0200 (Mo, 06 Sep 2010) | 2 lines

Fix: windows does not have wait(), use own macros instead.

------------------------------------------------------------------------


[SVN r65326]
2010-09-07 05:52:45 +00:00
Vladimir Prus
cd1b58aac2 Merge from trunk
[SVN r63911]
2010-07-12 07:14:14 +00:00
Daniel James
310a638dc8 Merge documentation fixes.
* Use `doc/src/*.css` instead of `doc/html/*.css`.
* Remove wiki and people directories.
* Some documentation fixes.
* Left out `minimal.css` changes and boostbook changes because of clashes.


[SVN r63347]
2010-06-26 12:30:09 +00:00
Vladimir Prus
cbacc90d8f Merge from trunk
[SVN r61962]
2010-05-14 06:55:15 +00:00
17 changed files with 105 additions and 40 deletions

View File

@@ -5,6 +5,7 @@ toolset.using doxygen ;
boostbook program_option
: program_options.xml
: <implicit-dependency>autodoc
<xsl:param>boost.root=../../../..
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
;

View File

@@ -107,7 +107,7 @@ if (vm.count("response-file")) {
// Load the file and tokenize it
ifstream ifs(vm["response-file"].as<string>().c_str());
if (!ifs) {
cout << "Could no open the response file\n";
cout << "Could not open the response file\n";
return 1;
}
// Read the whole file into a string
@@ -146,7 +146,7 @@ if (vm.count("response-file")) {
vector&lt;string&gt; args = split_winmain(lpCmdLine);
store(command_line_parser(args).options(desc).run(), vm);
</programlisting>
The function is an overload for <code>wchar_t</code> strings, so can
The <code>split_winmain</code> function is overloaded for <code>wchar_t</code> strings, so can
also be used in Unicode applications.
</para>

View File

@@ -77,13 +77,13 @@ if (vm.count(&quot;compression&quot;)) {
<para>It's now a good time to try compiling the code yourself, but if
you're not yet ready, here's an example session:
<screen>
$<userinput>bin/gcc/debug/first</userinput>
$ <userinput>bin/gcc/debug/first</userinput>
Compression level was not set.
$<userinput>bin/gcc/debug/first --help</userinput>
$ <userinput>bin/gcc/debug/first --help</userinput>
Allowed options:
--help : produce help message
--compression arg : set compression level
$<userinput>bin/gcc/debug/first --compression 10</userinput>
$ <userinput>bin/gcc/debug/first --compression 10</userinput>
Compression level was set to 10.
</screen>
</para>
@@ -199,16 +199,16 @@ cout &lt;&lt; &quot;Optimization level is &quot; &lt;&lt; opt &lt;&lt; &quot;\n&
<para>Here's an example session:
<screen>
$<userinput>bin/gcc/debug/options_description --help</userinput>
$ <userinput>bin/gcc/debug/options_description --help</userinput>
Usage: options_description [options]
Allowed options:
--help : produce help message
--optimization arg : optimization level
-I [ --include-path ] arg : include path
--input-file arg : input file
$bin/gcc/debug/options_description
$ <userinput>bin/gcc/debug/options_description</userinput>
Optimization level is 10
$<userinput>bin/gcc/debug/options_description --optimization 4 -I foo a.cpp</userinput>
$ <userinput>bin/gcc/debug/options_description --optimization 4 -I foo a.cpp</userinput>
Include paths are: foo
Input files are: a.cpp
Optimization level is 4
@@ -308,10 +308,10 @@ visible.add(generic).add(config);
<para>Here's an example session:
<screen>
$<userinput>bin/gcc/debug/multiple_sources</userinput>
$ <userinput>bin/gcc/debug/multiple_sources</userinput>
Include paths are: /opt
Optimization level is 1
$<userinput>bin/gcc/debug/multiple_sources --help</userinput>
$ <userinput>bin/gcc/debug/multiple_sources --help</userinput>
Allows options:
Generic options:
@@ -322,7 +322,7 @@ Configuration:
--optimization n : optimization level
-I [ --include-path ] path : include path
$<userinput>bin/gcc/debug/multiple_sources --optimization=4 -I foo a.cpp b.cpp</userinput>
$ <userinput>bin/gcc/debug/multiple_sources --optimization=4 -I foo a.cpp b.cpp</userinput>
Include paths are: foo /opt
Input files are: a.cpp b.cpp
Optimization level is 4

View File

@@ -2,6 +2,7 @@
project
: requirements <library>../build//boost_program_options
<hardcode-dll-paths>true
<link>static
;
exe first : first.cpp ;

View File

@@ -79,7 +79,7 @@ int main(int ac, char* av[])
ifstream ifs(config_file.c_str());
if (!ifs)
{
cout << "can not open config file: " << config_file << "\n";
cout << "can not open config file: " << config_file << "\n";
return 0;
}
else

View File

@@ -22,6 +22,11 @@
#include <string>
#include <vector>
#if defined(BOOST_MSVC)
# pragma warning (push)
# pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::positional_options_description'
#endif
namespace boost { namespace program_options { namespace detail {
/** Command line parser class. Main requirements were:
@@ -134,5 +139,9 @@ namespace boost { namespace program_options { namespace detail {
}}}
#if defined(BOOST_MSVC)
# pragma warning (pop)
#endif
#endif

View File

@@ -29,8 +29,8 @@ namespace boost { namespace program_options {
template<class charT>
basic_command_line_parser<charT>::
basic_command_line_parser(const std::vector<
std::basic_string<charT> >& args)
: detail::cmdline(to_internal(args))
std::basic_string<charT> >& xargs)
: detail::cmdline(to_internal(xargs))
{}
@@ -64,9 +64,9 @@ namespace boost { namespace program_options {
template<class charT>
basic_command_line_parser<charT>&
basic_command_line_parser<charT>::style(int style)
basic_command_line_parser<charT>::style(int xstyle)
{
detail::cmdline::style(style);
detail::cmdline::style(xstyle);
return *this;
}

View File

@@ -143,9 +143,9 @@ namespace boost { namespace program_options {
a validator for class T, we use it even
when parsing vector<T>. */
boost::any a;
std::vector<std::basic_string<charT> > v;
v.push_back(s[i]);
validate(a, v, (T*)0, 0);
std::vector<std::basic_string<charT> > cv;
cv.push_back(s[i]);
validate(a, cv, (T*)0, 0);
tv->push_back(boost::any_cast<T>(a));
}
catch(const bad_lexical_cast& /*e*/) {

View File

@@ -13,14 +13,18 @@
#include <stdexcept>
#include <vector>
#if defined(BOOST_MSVC)
# pragma warning (push)
# pragma warning (disable:4275) // non dll-interface class 'std::logic_error' used as base for dll-interface class 'boost::program_options::error'
# pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::ambiguous_option'
#endif
namespace boost { namespace program_options {
/** Base class for all errors in the library. */
class BOOST_PROGRAM_OPTIONS_DECL error : public std::logic_error {
public:
error(const std::string& what) : std::logic_error(what) {}
error(const std::string& xwhat) : std::logic_error(xwhat) {}
};
class BOOST_PROGRAM_OPTIONS_DECL invalid_syntax : public error {
@@ -78,9 +82,9 @@ namespace boost { namespace program_options {
class BOOST_PROGRAM_OPTIONS_DECL ambiguous_option : public error {
public:
ambiguous_option(const std::string& name,
const std::vector<std::string>& alternatives)
const std::vector<std::string>& xalternatives)
: error(std::string("ambiguous option ").append(name))
, m_alternatives(alternatives)
, m_alternatives(xalternatives)
, m_option_name(name)
{}
@@ -232,5 +236,8 @@ namespace boost { namespace program_options {
};
}}
#if defined(BOOST_MSVC)
# pragma warning (pop)
#endif
#endif

View File

@@ -28,10 +28,10 @@ namespace boost { namespace program_options {
, unregistered(false)
, case_insensitive(false)
{}
basic_option(const std::string& string_key,
const std::vector< std::string> &value)
: string_key(string_key)
, value(value)
basic_option(const std::string& xstring_key,
const std::vector< std::string> &xvalue)
: string_key(xstring_key)
, value(xvalue)
, unregistered(false)
, case_insensitive(false)
{}

View File

@@ -25,6 +25,12 @@
#include <iosfwd>
#if defined(BOOST_MSVC)
# pragma warning (push)
# pragma warning (disable:4251) // class 'boost::shared_ptr<T>' needs to have dll-interface to be used by clients of class 'boost::program_options::option_description'
#endif
/** Boost namespace */
namespace boost {
/** Namespace for the library. */
@@ -65,7 +71,7 @@ namespace program_options {
The 'name' parameter is interpreted by the following rules:
- if there's no "," character in 'name', it specifies long name
- otherwise, the part before "," specifies long name and the part
after -- long name.
after -- short name.
*/
option_description(const char* name,
const value_semantic* s);
@@ -81,12 +87,12 @@ namespace program_options {
enum match_result { no_match, full_match, approximate_match };
/** Given 'option', specified in the input source,
return 'true' is 'option' specifies *this.
returns 'true' if 'option' specifies *this.
*/
match_result match(const std::string& option, bool approx,
bool long_ignore_case, bool short_ignore_case) const;
/** Return the key that should identify the option, in
/** Returns the key that should identify the option, in
particular in the variables_map class.
The 'option' parameter is the option spelling from the
input source.
@@ -107,7 +113,7 @@ namespace program_options {
/// Returns the option name, formatted suitably for usage message.
std::string format_name() const;
/** Return the parameter name and properties, formatted suitably for
/** Returns the parameter name and properties, formatted suitably for
usage message. */
std::string format_parameter() const;
@@ -211,7 +217,7 @@ namespace program_options {
friend BOOST_PROGRAM_OPTIONS_DECL std::ostream& operator<<(std::ostream& os,
const options_description& desc);
/** Output 'desc' to the specified stream, calling 'f' to output each
/** Outputs 'desc' to the specified stream, calling 'f' to output each
option_description element. */
void print(std::ostream& os) const;
@@ -247,8 +253,12 @@ namespace program_options {
/** Class thrown when duplicate option description is found. */
class BOOST_PROGRAM_OPTIONS_DECL duplicate_option_error : public error {
public:
duplicate_option_error(const std::string& what) : error(what) {}
duplicate_option_error(const std::string& xwhat) : error(xwhat) {}
};
}}
#if defined(BOOST_MSVC)
# pragma warning (pop)
#endif
#endif

View File

@@ -17,6 +17,11 @@
#include <vector>
#include <utility>
#if defined(BOOST_MSVC)
# pragma warning (push)
# pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::basic_parsed_options<wchar_t>'
#endif
namespace boost { namespace program_options {
class options_description;
@@ -31,8 +36,8 @@ namespace boost { namespace program_options {
template<class charT>
class basic_parsed_options {
public:
explicit basic_parsed_options(const options_description* description)
: description(description) {}
explicit basic_parsed_options(const options_description* xdescription)
: description(xdescription) {}
/** Options found in the source. */
std::vector< basic_option<charT> > options;
/** Options description that was used for parsing.

View File

@@ -11,6 +11,11 @@
#include <vector>
#include <string>
#if defined(BOOST_MSVC)
# pragma warning (push)
# pragma warning (disable:4251) // class 'std::vector<_Ty>' needs to have dll-interface to be used by clients of class 'boost::program_options::positional_options_description'
#endif
namespace boost { namespace program_options {
/** Describes positional options.
@@ -61,5 +66,9 @@ namespace boost { namespace program_options {
}}
#if defined(BOOST_MSVC)
# pragma warning (pop)
#endif
#endif

View File

@@ -16,6 +16,11 @@
#include <map>
#include <set>
#if defined(BOOST_MSVC)
# pragma warning (push)
# pragma warning (disable:4251) // 'boost::program_options::variable_value::v' : class 'boost::any' needs to have dll-interface to be used by clients of class 'boost::program_options::variable_value
#endif
namespace boost { namespace program_options {
template<class charT>
@@ -53,8 +58,8 @@ namespace boost { namespace program_options {
class BOOST_PROGRAM_OPTIONS_DECL variable_value {
public:
variable_value() : m_defaulted(false) {}
variable_value(const boost::any& v, bool defaulted)
: v(v), m_defaulted(defaulted)
variable_value(const boost::any& xv, bool xdefaulted)
: v(xv), m_defaulted(xdefaulted)
{}
/** If stored value if of type T, returns that value. Otherwise,

View File

@@ -306,6 +306,7 @@ namespace boost { namespace program_options {
bool short_ignore_case) const
{
shared_ptr<option_description> found;
bool had_full_match = false;
vector<string> approximate_matches;
vector<string> full_matches;
@@ -323,15 +324,17 @@ namespace boost { namespace program_options {
if (r == option_description::full_match)
{
full_matches.push_back(m_options[i]->key(name));
found = m_options[i];
had_full_match = true;
}
else
{
// FIXME: the use of 'key' here might not
// be the best approach.
approximate_matches.push_back(m_options[i]->key(name));
if (!had_full_match)
found = m_options[i];
}
found = m_options[i];
}
if (full_matches.size() > 1)
boost::throw_exception(

View File

@@ -30,6 +30,7 @@ namespace boost { namespace program_options {
std::string current;
bool inside_quoted = false;
bool empty_quote = false;
int backslash_count = 0;
for(; i != e; ++i) {
@@ -38,6 +39,7 @@ namespace boost { namespace program_options {
// n/2 backslashes and is a quoted block delimiter
if (backslash_count % 2 == 0) {
current.append(backslash_count / 2, '\\');
empty_quote = inside_quoted && current.empty();
inside_quoted = !inside_quoted;
// '"' preceded by odd number (n) of backslashes generates
// (n-1)/2 backslashes and is literal quote.
@@ -59,6 +61,7 @@ namespace boost { namespace program_options {
// Space outside quoted section terminate the current argument
result.push_back(current);
current.resize(0);
empty_quote = false;
for(;i != e && isspace((unsigned char)*i); ++i)
;
--i;
@@ -74,7 +77,7 @@ namespace boost { namespace program_options {
// If we have non-empty 'current' or we're still in quoted
// section (even if 'current' is empty), add the last token.
if (!current.empty() || inside_quoted)
if (!current.empty() || inside_quoted || empty_quote)
result.push_back(current);
}
return result;
@@ -94,3 +97,4 @@ namespace boost { namespace program_options {
}}
#endif

View File

@@ -53,6 +53,17 @@ void test_approximation()
BOOST_CHECK_EQUAL(desc.find("all", true).long_name(), "all");
BOOST_CHECK_EQUAL(desc.find("all-ch", true).long_name(), "all-chroots");
options_description desc2;
desc2.add_options()
("help", "display this message")
("config", value<string>(), "config file name")
("config-value", value<string>(), "single config value")
;
BOOST_CHECK_EQUAL(desc2.find("config", true).long_name(), "config");
BOOST_CHECK_EQUAL(desc2.find("config-value", true).long_name(),
"config-value");
// BOOST_CHECK(desc.count_approx("foo") == 1);
// set<string> a = desc.approximations("f");