mirror of
https://github.com/boostorg/program_options.git
synced 2026-01-24 18:12:37 +00:00
Compare commits
1 Commits
svn-branch
...
svn-branch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0ceebb0b7 |
@@ -77,13 +77,13 @@ if (vm.count("compression")) {
|
||||
<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 << "Optimization level is " << opt << "\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
|
||||
$ <userinput>bin/gcc/debug/options_description</userinput>
|
||||
$bin/gcc/debug/options_description
|
||||
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
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
project
|
||||
: requirements <library>../build//boost_program_options
|
||||
<hardcode-dll-paths>true
|
||||
<link>static
|
||||
;
|
||||
|
||||
exe first : first.cpp ;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -306,7 +306,6 @@ 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;
|
||||
|
||||
@@ -324,17 +323,15 @@ 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(
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace boost { namespace program_options {
|
||||
|
||||
std::string current;
|
||||
bool inside_quoted = false;
|
||||
bool empty_quote = false;
|
||||
int backslash_count = 0;
|
||||
|
||||
for(; i != e; ++i) {
|
||||
@@ -39,7 +38,6 @@ 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.
|
||||
@@ -61,7 +59,6 @@ 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;
|
||||
@@ -77,7 +74,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 || empty_quote)
|
||||
if (!current.empty() || inside_quoted)
|
||||
result.push_back(current);
|
||||
}
|
||||
return result;
|
||||
@@ -97,4 +94,3 @@ namespace boost { namespace program_options {
|
||||
|
||||
}}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -53,17 +53,6 @@ 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");
|
||||
|
||||
Reference in New Issue
Block a user