Skip to content

Commit fae2d4c

Browse files
committed
Merge from develop for 1.59
- Fix compilation errors, missing dllexport and warnings on Windows and/or MSVC (Daniela Engert, Marcel Raad) - Fix unintialized fields (Zoey Greer) - Stop options with implicit value from consuming separate tokens (Michael John Decker) - Make multitoken limit be max int, not 32K (Hans Hohenfeld) - Code formatting and documentation fixes (Jurko, Lauri Nurmi) - Minimal support for no-rtti build (Minmin Gong) - Don't increment environment pointer past the end (Vladimir Prus)
2 parents 9d7c987 + c0cee7f commit fae2d4c

26 files changed

+352
-261
lines changed

doc/design.xml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
not mean strict 7-bit ASCII encoding, but rather "char" strings in local
2323
8-bit encoding.
2424
</para>
25-
25+
2626
<para>
2727
Generally, &quot;Unicode support&quot; can mean
2828
many things, but for the program_options library it means that:
@@ -54,7 +54,7 @@
5454
passed to an ascii value will be converted using a codecvt
5555
facet (which may be specified by the user).
5656
</para>
57-
</listitem>
57+
</listitem>
5858
</itemizedlist>
5959
</para>
6060
</listitem>
@@ -68,8 +68,8 @@
6868
Second, imagine a reusable library which has some options and exposes
6969
options description in its interface. If <emphasis>all</emphasis>
7070
options are either ascii or Unicode, and the library does not use any
71-
Unicode strings, then the author will likely to use ascii options, which
72-
would make the library unusable inside Unicode
71+
Unicode strings, then the author is likely to use ascii options, making
72+
the library unusable inside Unicode
7373
applications. Essentially, it would be necessary to provide two versions
7474
of the library -- ascii and Unicode.
7575
</para>
@@ -94,7 +94,7 @@
9494
<para>The primary question in implementing the Unicode support is whether
9595
to use templates and <code>std::basic_string</code> or to use some
9696
internal encoding and convert between internal and external encodings on
97-
the interface boundaries.
97+
the interface boundaries.
9898
</para>
9999

100100
<para>The choice, mostly, is between code size and execution
@@ -171,14 +171,14 @@
171171
number of new instantiations.
172172
</para>
173173
</listitem>
174-
174+
175175
</itemizedlist>
176176
There's no clear leader, but the last point seems important, so UTF-8
177-
will be used.
177+
will be used.
178178
</para>
179179

180-
<para>Choosing the UTF-8 encoding allows the use of existing parsers,
181-
because 7-bit ascii characters retain their values in UTF-8,
180+
<para>Choosing the UTF-8 encoding allows the use of existing parsers,
181+
because 7-bit ascii characters retain their values in UTF-8,
182182
so searching for 7-bit strings is simple. However, there are
183183
two subtle issues:
184184
<itemizedlist>
@@ -197,16 +197,16 @@
197197
almost universal encoding and since composing characters following '=' (and
198198
other characters with special meaning to the library) are not likely to appear.
199199
</para>
200-
200+
201201
</section>
202202

203-
203+
204204
</section>
205205

206206
<!--
207207
Local Variables:
208208
mode: xml
209-
sgml-indent-data: t
209+
sgml-indent-data: t
210210
sgml-parent-document: ("program_options.xml" "section")
211211
sgml-set-face: t
212212
End:

doc/howto.xml

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ options groups/hidden options
2121
-->
2222
<section>
2323
<title>Non-conventional Syntax</title>
24-
24+
2525
<para>Sometimes, standard command line syntaxes are not enough. For
2626
example, the gcc compiler has "-frtti" and -fno-rtti" options, and this
2727
syntax is not directly supported.
@@ -57,14 +57,14 @@ store(command_line_parser(ac, av).options(desc).extra_parser(reg_foo)
5757
.run(), vm);
5858
</programlisting>
5959
The complete example can be found in the "example/custom_syntax.cpp"
60-
file.
60+
file.
6161
</para>
6262
</section>
6363

6464
<section>
6565
<title>Response Files</title>
6666

67-
<indexterm><primary>response files</primary></indexterm>
67+
<indexterm><primary>response files</primary></indexterm>
6868

6969
<para>Some operating system have very low limits of the command line
7070
length. The common way to work around those limitations is using
@@ -79,7 +79,7 @@ store(command_line_parser(ac, av).options(desc).extra_parser(reg_foo)
7979
<para>
8080
First, you need to define an option for the response file:
8181
<programlisting>
82-
("response-file", value&lt;string&gt;(),
82+
("response-file", value&lt;string&gt;(),
8383
"can be specified with '@name', too")
8484
</programlisting>
8585
</para>
@@ -120,14 +120,14 @@ if (vm.count("response-file")) {
120120
vector<string> args;
121121
copy(tok.begin(), tok.end(), back_inserter(args));
122122
// Parse the file and store the options
123-
store(command_line_parser(args).options(desc).run(), vm);
123+
store(command_line_parser(args).options(desc).run(), vm);
124124
}
125125
]]>
126126
</programlisting>
127127
The complete example can be found in the "example/response_file.cpp"
128-
file.
128+
file.
129129
</para>
130-
130+
131131
</section>
132132

133133
<section>
@@ -146,7 +146,7 @@ if (vm.count("response-file")) {
146146
<programlisting>
147147
vector&lt;string&gt; args = split_winmain(lpCmdLine);
148148
store(command_line_parser(args).options(desc).run(), vm);
149-
</programlisting>
149+
</programlisting>
150150
The <code>split_winmain</code> function is overloaded for <code>wchar_t</code> strings, so can
151151
also be used in Unicode applications.
152152
</para>
@@ -223,7 +223,7 @@ visible.add(general).add(gui);
223223
variables_map vm;
224224
store(parse_command_line(ac, av, all), vm);
225225
226-
if (vm.count("help"))
226+
if (vm.count("help"))
227227
{
228228
cout << visible;
229229
return 0;
@@ -235,16 +235,16 @@ if (vm.count("help-module")) {
235235
} else if (s == "backend") {
236236
cout << backend;
237237
} else {
238-
cout << "Unknown module '"
238+
cout << "Unknown module '"
239239
<< s << "' in the --help-module option\n";
240240
return 1;
241241
}
242242
return 0;
243243
}
244244
if (vm.count("num-threads")) {
245245
cout << "The 'num-threads' options was set to "
246-
<< vm["num-threads"].as<int>() << "\n";
247-
}
246+
<< vm["num-threads"].as<int>() << "\n";
247+
}
248248
]]></programlisting>
249249
When parsing the command line, all options are allowed. The "--help"
250250
message, however, does not include the "Backend options" group -- the
@@ -253,7 +253,7 @@ if (vm.count("num-threads")) {
253253
option. The complete example can be found in the
254254
"example/option_groups.cpp" file.
255255
</para>
256-
256+
257257
</section>
258258

259259
<section>
@@ -276,7 +276,7 @@ public:
276276
};
277277
]]></programlisting> and then overload the <code>validate</code> function:
278278
<programlisting><![CDATA[
279-
void validate(boost::any& v,
279+
void validate(boost::any& v,
280280
const std::vector<std::string>& values,
281281
magic_number* target_type, int)
282282
{
@@ -290,16 +290,16 @@ void validate(boost::any& v,
290290
// one string, it's an error, and exception will be thrown.
291291
const string& s = validators::get_single_string(values);
292292
293-
// Do regex match and convert the interesting part to
293+
// Do regex match and convert the interesting part to
294294
// int.
295295
smatch match;
296296
if (regex_match(s, match, r)) {
297297
v = any(magic_number(lexical_cast<int>(match[1])));
298298
} else {
299299
throw validation_error(validation_error::invalid_option_value);
300-
}
300+
}
301301
}
302-
]]>
302+
]]>
303303
</programlisting>The function takes four parameters. The first is the storage
304304
for the value, and in this case is either empty or contains an instance of
305305
the <code>magic_number</code> class. The second is the list of strings
@@ -372,7 +372,7 @@ void validate(boost::any& v,
372372
locale::global(locale(""));
373373
</programlisting>
374374
which would set up the conversion facet according to the user's selected
375-
locale.
375+
locale.
376376
</para>
377377

378378
<para>It's wise to check the status of the C++ locale support on your
@@ -382,7 +382,7 @@ locale::global(locale(""));
382382
<para>Go the the "test" directory and build the "test_convert" binary.</para>
383383
</listitem>
384384
<listitem>
385-
<para>Set some non-ascii locale in the environmemt. On Linux, one can
385+
<para>Set some non-ascii locale in the environment. On Linux, one can
386386
run, for example: <screen>
387387
$ export LC_CTYPE=ru_RU.KOI8-R
388388
</screen>
@@ -402,37 +402,37 @@ $ export LC_CTYPE=ru_RU.KOI8-R
402402
<section>
403403
<title>Allowing Unknown Options</title>
404404

405-
<para>Usually, the library throws an exception on unknown option names. This
406-
behaviour can be changed. For example, only some part of your application uses
405+
<para>Usually, the library throws an exception on unknown option names. This
406+
behaviour can be changed. For example, only some part of your application uses
407407
<libraryname>Program_options</libraryname>, and you wish to pass unrecognized options to another part of
408408
the program, or even to another application.</para>
409409

410-
<para>To allow unregistered options on the command line, you need to use
410+
<para>To allow unregistered options on the command line, you need to use
411411
the &basic_command_line_parser; class for parsing (not &parse_command_line;)
412-
and call the <methodname alt="boost::program_options::basic_command_line_parser::allow_unregistered">allow_unregistered</methodname>
412+
and call the <methodname alt="boost::program_options::basic_command_line_parser::allow_unregistered">allow_unregistered</methodname>
413413
method of that class:
414414
<programlisting>
415-
parsed_options parsed =
416-
command_line_parser(argc, argv).options(desc).allow_unregistered().run();
415+
parsed_options parsed =
416+
command_line_parser(argc, argv).options(desc).allow_unregistered().run();
417417
</programlisting>
418-
419-
For each token that looks like an option, but does not have a known name,
420-
an instance of &basic_option; will be added to the result.
421-
The <code>string_key</code> and <code>value</code> fields of the instance will contain results
418+
419+
For each token that looks like an option, but does not have a known name,
420+
an instance of &basic_option; will be added to the result.
421+
The <code>string_key</code> and <code>value</code> fields of the instance will contain results
422422
of syntactic parsing of the token, the <code>unregistered</code> field will be set to <code>true</code>,
423423
and the <code>original_tokens</code> field will contain the token as it appeared on the command line.
424424
</para>
425425

426-
<para>If you want to pass the unrecognized options further, the
426+
<para>If you want to pass the unrecognized options further, the
427427
<functionname alt="boost::program_options::collect_unrecognized">collect_unrecognized</functionname> function can be used.
428428
The function will collect original tokens for all unrecognized values, and optionally, all found positional options.
429-
Say, if your code handles a few options, but does not handles positional options at all, you can use the function like this:
429+
Say, if your code handles a few options, but does not handle positional options at all, you can use the function like this:
430430
<programlisting>
431431
vector&lt;string&gt; to_pass_further = collect_unrecognized(parsed.options, include_positional);
432432
</programlisting>
433-
434-
</para>
435-
433+
434+
</para>
435+
436436
</section>
437437

438438
</section>

0 commit comments

Comments
 (0)