Skip to content

Commit 1d3294a

Browse files
committed
Merge pull request #7 from jurko-gospodnetic/develop
Slight documentation cleanup.
2 parents 095cb36 + 7542447 commit 1d3294a

File tree

3 files changed

+78
-78
lines changed

3 files changed

+78
-78
lines changed

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>

example/options_description.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ using namespace std;
1818
template<class T>
1919
ostream& operator<<(ostream& os, const vector<T>& v)
2020
{
21-
copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
21+
copy(v.begin(), v.end(), ostream_iterator<T>(os, " "));
2222
return os;
2323
}
2424

@@ -30,26 +30,26 @@ int main(int ac, char* av[])
3030
po::options_description desc("Allowed options");
3131
desc.add_options()
3232
("help", "produce help message")
33-
("optimization", po::value<int>(&opt)->default_value(10),
33+
("optimization", po::value<int>(&opt)->default_value(10),
3434
"optimization level")
3535
("verbose,v", po::value<int>()->implicit_value(1),
3636
"enable verbosity (optionally specify level)")
3737
("listen,l", po::value<int>(&portnum)->implicit_value(1001)
3838
->default_value(0,"no"),
3939
"listen on a port.")
40-
("include-path,I", po::value< vector<string> >(),
40+
("include-path,I", po::value< vector<string> >(),
4141
"include path")
4242
("input-file", po::value< vector<string> >(), "input file")
4343
;
4444

4545
po::positional_options_description p;
4646
p.add("input-file", -1);
47-
47+
4848
po::variables_map vm;
4949
po::store(po::command_line_parser(ac, av).
5050
options(desc).positional(p).run(), vm);
5151
po::notify(vm);
52-
52+
5353
if (vm.count("help")) {
5454
cout << "Usage: options_description [options]\n";
5555
cout << desc;
@@ -58,13 +58,13 @@ int main(int ac, char* av[])
5858

5959
if (vm.count("include-path"))
6060
{
61-
cout << "Include paths are: "
61+
cout << "Include paths are: "
6262
<< vm["include-path"].as< vector<string> >() << "\n";
6363
}
6464

6565
if (vm.count("input-file"))
6666
{
67-
cout << "Input files are: "
67+
cout << "Input files are: "
6868
<< vm["input-file"].as< vector<string> >() << "\n";
6969
}
7070

@@ -73,14 +73,14 @@ int main(int ac, char* av[])
7373
<< "\n";
7474
}
7575

76-
cout << "Optimization level is " << opt << "\n";
76+
cout << "Optimization level is " << opt << "\n";
7777

78-
cout << "Listen port is " << portnum << "\n";
78+
cout << "Listen port is " << portnum << "\n";
7979
}
8080
catch(std::exception& e)
8181
{
8282
cout << e.what() << "\n";
8383
return 1;
84-
}
84+
}
8585
return 0;
8686
}

0 commit comments

Comments
 (0)