@@ -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< string> (),
82+ ("response-file", value< string> (),
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 >
147147vector< string> args = split_winmain(lpCmdLine);
148148store(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);
223223variables_map vm;
224224store(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}
244244if (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,
372372locale::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 >
431431vector< string> 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