Compare commits

..

24 Commits

Author SHA1 Message Date
nobody
5feec9388e This commit was manufactured by cvs2svn to create tag
'Version_1_34_0_RC3'.

[SVN r37663]
2007-05-11 03:40:35 +00:00
Vladimir Prus
87938cfa8e Merge: Add missing include, to try to fix compilation on sun
[SVN r37006]
2007-02-19 19:28:49 +00:00
Hartmut Kaiser
9a73a1c412 Trying to fix sun-5.8 error.
[SVN r36943]
2007-02-15 01:25:10 +00:00
Daniel James
37143a449d Fix a broken link
[SVN r36653]
2007-01-07 22:51:27 +00:00
Vladimir Prus
2e0e9fd30b Merge: Fix dynamic linking
[SVN r35992]
2006-11-10 20:31:43 +00:00
Vladimir Prus
1bd588d677 Merge from HEAD.
Allow building of shared versions of some Boost.Test libraries.
Adjust tests to use always use static linking to Boost.Test, since
linking to the shared version requires test changes.

Patch from Juergen Hunold.


[SVN r35990]
2006-11-10 19:59:52 +00:00
Beman Dawes
d83e0dea37 Merged copyright and license addition
[SVN r35907]
2006-11-07 19:27:00 +00:00
Rene Rivera
54daca4c09 Remove obsolete Boost.Build v1 files.
[SVN r35880]
2006-11-06 17:10:46 +00:00
John Maddock
f4eac99310 Fix for Borland compilers.
[SVN r35652]
2006-10-18 12:33:54 +00:00
Vladimir Prus
a367a1b021 Make intel happy
[SVN r35034]
2006-09-07 08:06:16 +00:00
Gennaro Prota
720d0455dd avoid bogus detection of min/max guideline violation (Inspect tool)
[SVN r34784]
2006-07-29 21:00:31 +00:00
Hartmut Kaiser
aad1a60172 Just another fix for the Intel DLL issue.
[SVN r34196]
2006-06-06 14:30:28 +00:00
Hartmut Kaiser
1e4d1dee3d Fixed intel 9.1 dll export problem.
[SVN r34168]
2006-06-04 15:50:47 +00:00
Hartmut Kaiser
e718d0a8a5 Try to fix Intel dll issue on Windows.
[SVN r34104]
2006-05-26 16:52:54 +00:00
Hartmut Kaiser
ab30ec28eb Fixed a dllimport/dllexport problem.
[SVN r34049]
2006-05-20 22:14:41 +00:00
Vladimir Prus
682f1b7670 Merge from trunk
[SVN r33992]
2006-05-18 06:06:53 +00:00
Vladimir Prus
43577d0ca8 Merge from trunk
[SVN r33970]
2006-05-15 14:06:24 +00:00
Vladimir Prus
d05b400b13 Merge from trunk
[SVN r33787]
2006-04-24 09:51:01 +00:00
Vladimir Prus
4863727509 Merge from trunk
[SVN r33785]
2006-04-24 09:41:50 +00:00
Vladimir Prus
7d90a1b1b2 Merge from trunk
[SVN r33783]
2006-04-24 09:15:27 +00:00
Vladimir Prus
ac9830625b Merge from trunk
[SVN r33781]
2006-04-24 08:52:43 +00:00
Vladimir Prus
252a3f9ebd Merge from trunk
[SVN r33779]
2006-04-24 08:29:05 +00:00
Vladimir Prus
b1dc87da3c Merge from trunk
[SVN r33777]
2006-04-24 08:02:07 +00:00
nobody
1fbf955272 This commit was manufactured by cvs2svn to create branch 'RC_1_34_0'.
[SVN r33417]
2006-03-21 02:26:31 +00:00
23 changed files with 62 additions and 229 deletions

View File

@@ -2,10 +2,7 @@
import toolset ;
toolset.using doxygen ;
boostbook program_option
: program_options.xml
: <implicit-dependency>autodoc
;
boostbook program_option : program_options.xml ;
doxygen autodoc
: [ glob ../../../boost/program_options/*.hpp ] ;

View File

@@ -412,7 +412,7 @@ $ export LC_CTYPE=ru_RU.KOI8-R
method of that class:
<programlisting>
parsed_options parsed =
command_line_parser(argc, argv).options(desc).allow_unregistered().run();
command_line_parser(argv, argc).options(desc).allow_unregistered().run();
</programlisting>
For each token that looks like an option, but does not have a known name,
@@ -427,7 +427,7 @@ parsed_options parsed =
The function will collect original tokens for all unrecognized values, and optionally, all found positional options.
Say, if your code handles a few options, but does not handles positional options at all, you can use the function like this:
<programlisting>
vector&lt;string&gt; to_pass_further = collect_unrecognized(parsed.options, include_positional);
vector&lt;string&gt; to_pass_further = collect_arguments(parsed.option, include_positional);
</programlisting>
</para>

View File

@@ -181,7 +181,7 @@ options_description desc;
desc.add_options()
("help", "produce help message")
("compression", value&lt;string&gt;(), "compression level")
("verbose", value&lt;string&gt;()->zero_tokens(), "verbosity level")
("verbose", value&lt;string&gt;()->zero_token(), "verbosity level")
("email", value&lt;string&gt;()->multitoken(), "email to send to")
;
</programlisting>
@@ -478,45 +478,7 @@ notify(vm);
<title>Specific parsers</title>
<section>
<title>Configuration file parser</title>
<para>The &parse_config_file; function implements parsing
of simple INI-like configuration files. Configuration file
syntax is line based:
</para>
<itemizedlist>
<listitem><para>A line in the form:</para>
<screen>
<replaceable>name</replaceable>=<replaceable>value</replaceable>
</screen>
<para>gives a value to an option.</para>
</listitem>
<listitem><para>A line in the form:</para>
<screen>
[<replaceable>section name</replaceable>]
</screen>
<para>introduces a new section in the configuration file.</para>
</listitem>
<listitem><para>The <literal>#</literal> character introduces a
comment that spans until the end of the line.</para>
</listitem>
</itemizedlist>
<para>The option names are relative to the section names, so
the following configuration file part:</para>
<screen>
[gui.accessibility]
visual_bell=yes
</screen>
<para>is equivalent to</para>
<screen>
gui.accessibility.visual_bell=yes
</screen>
</section>
<section>
<title>Environment variables parser</title>
<title>Environment variables</title>
<para><firstterm>Environment variables</firstterm> are string variables
which are available to all programs via the <code>getenv</code> function

View File

@@ -83,5 +83,5 @@
<xi:include href="design.xml"/>
<xi:include href="acknowledgements.xml"/>
<xi:include href="autodoc.xml"/>
<xi:include href="autodoc.boostbook"/>
</library>

View File

@@ -1,6 +1,4 @@
Say that variables_map is actually derived from std::map.
Make parse_config_file("foo.cfg", desc) work.
Document handling of positional options which depends on precedding options.

View File

@@ -1,6 +1,6 @@
project
: requirements <library>../build//boost_program_options
: requirements <library>../build//program_options
<hardcode-dll-paths>true
;
@@ -9,5 +9,7 @@ exe options_description : options_description.cpp ;
exe multiple_sources : multiple_sources.cpp ;
exe custom_syntax : custom_syntax.cpp ;
exe real : real.cpp ;
exe regex : regex.cpp /boost/regex//boost_regex ;
exe a : a.cpp ;
#exe real : real.cpp ;
#exe regex : regex.cpp /boost/regex//boost_regex ;

View File

@@ -26,17 +26,11 @@ int main(int ac, char* av[])
{
try {
int opt;
int portnum;
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("optimization", po::value<int>(&opt)->default_value(10),
"optimization level")
("verbose,v", po::value<int>()->implicit_value(1),
"enable verbosity (optionally specify level)")
("listen,l", po::value<int>(&portnum)->implicit_value(1001)
->default_value(0,"no"),
"listen on a port.")
("include-path,I", po::value< vector<string> >(),
"include path")
("input-file", po::value< vector<string> >(), "input file")
@@ -68,14 +62,7 @@ int main(int ac, char* av[])
<< vm["input-file"].as< vector<string> >() << "\n";
}
if (vm.count("verbose")) {
cout << "Verbosity enabled. Level is " << vm["verbose"].as<int>()
<< "\n";
}
cout << "Optimization level is " << opt << "\n";
cout << "Listen port is " << portnum << "\n";
}
catch(exception& e)
{

View File

@@ -70,8 +70,7 @@ namespace boost { namespace program_options { namespace detail {
public:
common_config_file_iterator() { found_eof(); }
common_config_file_iterator(
const std::set<std::string>& allowed_options,
bool allow_unregistered = false);
const std::set<std::string>& allowed_options);
virtual ~common_config_file_iterator() {}
@@ -104,7 +103,6 @@ namespace boost { namespace program_options { namespace detail {
// Invariant: no element is prefix of other element.
std::set<std::string> allowed_prefixes;
std::string m_prefix;
bool m_allow_unregistered;
};
template<class charT>
@@ -118,8 +116,7 @@ namespace boost { namespace program_options { namespace detail {
/** Creates a config file parser for the specified stream.
*/
basic_config_file_iterator(std::basic_istream<charT>& is,
const std::set<std::string>& allowed_options,
bool allow_unregistered = false);
const std::set<std::string>& allowed_options);
private: // base overrides
@@ -142,9 +139,8 @@ namespace boost { namespace program_options { namespace detail {
template<class charT>
basic_config_file_iterator<charT>::
basic_config_file_iterator(std::basic_istream<charT>& is,
const std::set<std::string>& allowed_options,
bool allow_unregistered)
: common_config_file_iterator(allowed_options, allow_unregistered)
const std::set<std::string>& allowed_options)
: common_config_file_iterator(allowed_options)
{
this->is.reset(&is, null_deleter());
get();

View File

@@ -16,13 +16,7 @@ namespace boost { namespace program_options {
std::string
typed_value<T, charT>::name() const
{
if (!m_implicit_value.empty() && !m_implicit_value_as_text.empty()) {
std::string msg = "[=arg(=" + m_implicit_value_as_text + ")]";
if (!m_default_value.empty() && !m_default_value_as_text.empty())
msg += " (=" + m_default_value_as_text + ")";
return msg;
}
else if (!m_default_value.empty() && !m_default_value_as_text.empty()) {
if (!m_default_value.empty() && !m_default_value_as_text.empty()) {
return arg + " (=" + m_default_value_as_text + ")";
} else {
return arg;
@@ -140,14 +134,7 @@ namespace boost { namespace program_options {
for (unsigned i = 0; i < s.size(); ++i)
{
try {
/* We call validate so that if user provided
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);
tv->push_back(boost::any_cast<T>(a));
tv->push_back(boost::lexical_cast<T>(s[i]));
}
catch(const bad_lexical_cast& /*e*/) {
boost::throw_exception(invalid_option_value(s[i]));
@@ -161,13 +148,7 @@ namespace boost { namespace program_options {
xparse(boost::any& value_store,
const std::vector<std::basic_string<charT> >& new_tokens) const
{
// If no tokens were given, and the option accepts an implicit
// value, then assign the implicit value as the stored value;
// otherwise, validate the user-provided token(s).
if (new_tokens.empty() && !m_implicit_value.empty())
value_store = m_implicit_value;
else
validate(value_store, new_tokens, (T*)0, 0);
validate(value_store, new_tokens, (T*)0, 0);
}
template<class T>

View File

@@ -155,7 +155,7 @@ namespace program_options {
*/
class BOOST_PROGRAM_OPTIONS_DECL options_description {
public:
static const unsigned m_default_line_length;
static const unsigned m_default_line_length = 80;
/** Creates the instance. */
options_description(unsigned line_length = m_default_line_length);

View File

@@ -153,8 +153,7 @@ namespace boost { namespace program_options {
BOOST_PROGRAM_OPTIONS_DECL
#endif
basic_parsed_options<charT>
parse_config_file(std::basic_istream<charT>&, const options_description&,
bool allow_unregistered = false);
parse_config_file(std::basic_istream<charT>&, const options_description&);
/** Controls if the 'collect_unregistered' function should
include positional options, or not. */

View File

@@ -41,7 +41,7 @@ namespace boost { namespace program_options {
add(const char* name, int max_count);
/** Returns the maximum number of positional options that can
be present. Can return numeric_limits<unsigned>::max() to
be present. Can return (numeric_limits<unsigned>::max)() to
indicate unlimited number. */
unsigned max_total_count() const;

View File

@@ -204,38 +204,6 @@ namespace boost { namespace program_options {
return this;
}
/** Specifies an implicit value, which will be used
if the option is given, but without an adjacent value.
Using this implies that an explicit value is optional, but if
given, must be strictly adjacent to the option, i.e.: '-ovalue'
or '--option=value'. Giving '-o' or '--option' will cause the
implicit value to be applied.
*/
typed_value* implicit_value(const T &v)
{
m_implicit_value = boost::any(v);
m_implicit_value_as_text =
boost::lexical_cast<std::string>(v);
return this;
}
/** Specifies an implicit value, which will be used
if the option is given, but without an adjacent value.
Using this implies that an explicit value is optional, but if
given, must be strictly adjacent to the option, i.e.: '-ovalue'
or '--option=value'. Giving '-o' or '--option' will cause the
implicit value to be applied.
Unlike the above overload, the type 'T' need not provide
operator<< for ostream, but textual representation of default
value must be provided by the user.
*/
typed_value* implicit_value(const T &v, const std::string& textual)
{
m_implicit_value = boost::any(v);
m_implicit_value_as_text = textual;
return this;
}
/** Specifies a function to be called when the final value
is determined. */
typed_value* notifier(function1<void, const T&> f)
@@ -275,7 +243,7 @@ namespace boost { namespace program_options {
unsigned min_tokens() const
{
if (m_zero_tokens || !m_implicit_value.empty()) {
if (m_zero_tokens) {
return 0;
} else {
return 1;
@@ -333,8 +301,6 @@ namespace boost { namespace program_options {
// as boost::optional to avoid unnecessary instantiations.
boost::any m_default_value;
std::string m_default_value_as_text;
boost::any m_implicit_value;
std::string m_implicit_value_as_text;
bool m_composing, m_implicit, m_multitoken, m_zero_tokens;
boost::function1<void, const T&> m_notifier;
};

View File

@@ -30,8 +30,7 @@ namespace boost { namespace program_options {
If 'm' already has a non-defaulted value of an option, that value
is not changed, even if 'options' specify some value.
*/
BOOST_PROGRAM_OPTIONS_DECL
void store(const basic_parsed_options<char>& options, variables_map& m,
BOOST_PROGRAM_OPTIONS_DECL void store(const basic_parsed_options<char>& options, variables_map& m,
bool utf8 = false);
/** Stores in 'm' all options that are defined in 'options'.
@@ -39,8 +38,7 @@ namespace boost { namespace program_options {
is not changed, even if 'options' specify some value.
This is wide character variant.
*/
BOOST_PROGRAM_OPTIONS_DECL
void store(const basic_parsed_options<wchar_t>& options,
BOOST_PROGRAM_OPTIONS_DECL void store(const basic_parsed_options<wchar_t>& options,
variables_map& m);
@@ -89,10 +87,9 @@ namespace boost { namespace program_options {
// be easily accessible, so we need to store semantic here.
shared_ptr<const value_semantic> m_value_semantic;
friend BOOST_PROGRAM_OPTIONS_DECL
void store(const basic_parsed_options<char>& options,
friend void store(const basic_parsed_options<char>& options,
variables_map& m, bool);
friend BOOST_PROGRAM_OPTIONS_DECL void notify(variables_map& m);
friend void notify(variables_map& m);
};
/** Implements string->string mapping with convenient value casting
@@ -157,8 +154,7 @@ namespace boost { namespace program_options {
be changed by subsequence assignments. */
std::set<std::string> m_final;
friend BOOST_PROGRAM_OPTIONS_DECL
void store(const basic_parsed_options<char>& options,
friend void store(const basic_parsed_options<char>& options,
variables_map& xm,
bool utf8);
};

View File

@@ -329,14 +329,6 @@ namespace boost { namespace program_options { namespace detail {
max_tokens -= opt.value.size();
// A value is optional if min_tokens == 0, but max_tokens > 0.
// If a value is optional, it must appear in opt.value (because
// it was 'adjacent'. Otherwise, remove the expectation of a
// non-adjacent value. (For now, we just check max_tokens == 1,
// as there is no current support for max_tokens>1)
if (min_tokens == 0 && max_tokens == 1 && opt.value.empty())
--max_tokens;
// Everything's OK, move the values to the result.
for(;!other_tokens.empty() && max_tokens--; ) {
opt.value.push_back(other_tokens[0]);

View File

@@ -21,10 +21,8 @@ namespace boost { namespace program_options { namespace detail {
using namespace std;
common_config_file_iterator::common_config_file_iterator(
const std::set<std::string>& allowed_options,
bool allow_unregistered)
: allowed_options(allowed_options),
m_allow_unregistered(allow_unregistered)
const std::set<std::string>& allowed_options)
: allowed_options(allowed_options)
{
for(std::set<std::string>::const_iterator i = allowed_options.begin();
i != allowed_options.end();
@@ -102,8 +100,7 @@ namespace boost { namespace program_options { namespace detail {
string name = m_prefix + trim_ws(s.substr(0, n));
string value = trim_ws(s.substr(n+1));
bool registered = allowed_option(name);
if (!registered && !m_allow_unregistered)
if (!allowed_option(name))
boost::throw_exception(unknown_option(name));
if (value.empty())
@@ -113,7 +110,6 @@ namespace boost { namespace program_options { namespace detail {
this->value().string_key = name;
this->value().value.clear();
this->value().value.push_back(value);
this->value().unregistered = !registered;
break;
} else {

View File

@@ -201,8 +201,6 @@ namespace boost { namespace program_options {
return *this;
}
const unsigned options_description::m_default_line_length = 80;
options_description::options_description(unsigned line_length)
: m_line_length(line_length)
{}
@@ -254,12 +252,11 @@ namespace boost { namespace program_options {
return m_options;
}
const option_description*
const option_description*
options_description::find_nothrow(const std::string& name,
bool approx) const
{
shared_ptr<option_description> found;
vector<string> approximate_matches;
int found = -1;
// We use linear search because matching specified option
// name with the declared option name need to take care about
// case sensitivity and trailing '*' and so we can't use simple map.
@@ -279,22 +276,31 @@ namespace boost { namespace program_options {
//
// For now, we don't check the situation when there are
// two full matches.
if (r == option_description::full_match)
{
return m_options[i].get();
return m_options[i].get();
}
found = m_options[i];
// FIXME: the use of 'key' here might not
// be the best approach.
approximate_matches.push_back(m_options[i]->key(name));
if (found != -1)
{
vector<string> alts;
// FIXME: the use of 'key' here might not
// be the best approach.
alts.push_back(m_options[found]->key(name));
alts.push_back(m_options[i]->key(name));
boost::throw_exception(ambiguous_option(name, alts));
}
else
{
found = i;
}
}
if (found != -1) {
return m_options[found].get();
} else {
return 0;
}
if (approximate_matches.size() > 1)
boost::throw_exception(
ambiguous_option(name, approximate_matches));
return found.get();
}
BOOST_PROGRAM_OPTIONS_DECL
@@ -406,9 +412,9 @@ namespace boost { namespace program_options {
if (last_space != line_begin)
{
// is last_space within the second half ot the
// is last_space within the second half of the
// current line
if (unsigned(distance(last_space, line_end)) <
if ((unsigned)std::distance(last_space, line_end) <
(line_length - indent) / 2)
{
line_end = last_space;

View File

@@ -88,8 +88,7 @@ namespace boost { namespace program_options {
template<class charT>
basic_parsed_options<charT>
parse_config_file(std::basic_istream<charT>& is,
const options_description& desc,
bool allow_unregistered)
const options_description& desc)
{
set<string> allowed_options;
@@ -107,8 +106,7 @@ namespace boost { namespace program_options {
// Parser return char strings
parsed_options result(&desc);
copy(detail::basic_config_file_iterator<charT>(
is, allowed_options, allow_unregistered),
copy(detail::basic_config_file_iterator<charT>(is, allowed_options),
detail::basic_config_file_iterator<charT>(),
back_inserter(result.options));
// Convert char strings into desired type.
@@ -118,15 +116,13 @@ namespace boost { namespace program_options {
template
BOOST_PROGRAM_OPTIONS_DECL basic_parsed_options<char>
parse_config_file(std::basic_istream<char>& is,
const options_description& desc,
bool allow_unregistered);
const options_description& desc);
#ifndef BOOST_NO_STD_WSTRING
template
BOOST_PROGRAM_OPTIONS_DECL basic_parsed_options<wchar_t>
parse_config_file(std::basic_istream<wchar_t>& is,
const options_description& desc,
bool allow_unregistered);
const options_description& desc);
#endif
// This versio, which accepts any options without validation, is disabled,

View File

@@ -122,8 +122,8 @@ namespace boost { namespace program_options {
/* Validates bool value.
Any of "1", "true", "yes", "on" will be converted to "1".<br>
Any of "0", "false", "no", "off" will be converted to "0".<br>
Case is ignored. The 'xs' vector can either be empty, in which
case the value is 'true', or can contain explicit value.
Case is ignored. Regardless of name passed, parameter will always
be optional.
*/
BOOST_PROGRAM_OPTIONS_DECL void validate(any& v, const vector<string>& xs,
bool*, int)

View File

@@ -44,9 +44,9 @@ void test_approximation()
("foo", new untyped_value())
("fee", new untyped_value())
("baz", new untyped_value())
("all", new untyped_value())
("all-chroots", new untyped_value())
("all-sessions", new untyped_value())
("all", new untyped_value())
;
BOOST_CHECK_EQUAL(desc.find("fo", true).long_name(), "foo");

View File

@@ -18,14 +18,9 @@ using namespace boost;
#include <boost/test/test_tools.hpp>
#include <sstream>
#include <iostream>
using namespace std;
#if defined(__sun)
#include <stdlib.h> // for putenv on solaris
#else
#include <cstdlib> // for putenv
#endif
#define TEST_CHECK_THROW(expression, exception, description) \
try \
@@ -243,20 +238,6 @@ void test_unregistered()
vm);
BOOST_CHECK_EQUAL(vm.size(), 0u);
const char content1[] =
"gv1 = 0\n"
"[m1]\n"
"v1 = 1\n"
;
stringstream ss(content1);
vector<option> a3 = parse_config_file(ss, desc, true).options;
BOOST_REQUIRE(a3.size() == 2);
cout << "XXX" << a3[0].value.front() << "\n";
check_value(a3[0], "gv1", "0");
check_value(a3[1], "m1.v1", "1");
}
int test_main(int, char* [])

View File

@@ -3,7 +3,6 @@
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <cassert>
#include <string>
#include <fstream>
#include <sstream>
@@ -15,8 +14,6 @@
#include <boost/program_options/detail/convert.hpp>
#include <boost/program_options/detail/utf8_codecvt_facet.hpp>
#include <boost/test/test_tools.hpp>
using namespace std;
string file_content(const string& filename)
@@ -77,7 +74,7 @@ std::wstring from_8_bit_2(const std::string& s,
void test_convert(const std::string& input,
const std::string& expected_output)
{
boost::program_options::detail::utf8_codecvt_facet facet;
boost::program_options::detail::utf8_codecvt_facet<wchar_t, char> facet;
std::wstring output;
{

View File

@@ -102,25 +102,6 @@ void test_variable_map()
BOOST_CHECK(vm3["vee"].as<string>() == "42");
BOOST_CHECK(vm3["voo"].as<string>() == "1");
BOOST_CHECK(vm3["iii"].as<int>() == 123);
options_description desc3;
desc3.add_options()
("imp", po::value<int>()->implicit_value(100))
("iim", po::value<int>()->implicit_value(200)->default_value(201))
("mmp,m", po::value<int>()->implicit_value(123)->default_value(124))
;
char* cmdline6_[] = { "--imp=1", "-m" };
vector<string> cmdline6 = sv(cmdline6_,
sizeof(cmdline6_)/sizeof(cmdline6_[0]));
parsed_options a6 = command_line_parser(cmdline6).options(desc3).run();
variables_map vm4;
store(a6, vm4);
notify(vm4);
BOOST_REQUIRE(vm4.size() == 3);
BOOST_CHECK(vm4["imp"].as<int>() == 1);
BOOST_CHECK(vm4["iim"].as<int>() == 201);
BOOST_CHECK(vm4["mmp"].as<int>() == 123);
}
int stored_value;