3 <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
4 <title>Chapter 21. Boost.Program_options</title>
5 <link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
6 <meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
7 <link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
8 <link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)">
9 <link rel="prev" href="mpi/python.html" title="Python Bindings">
10 <link rel="next" href="program_options/tutorial.html" title="Tutorial">
12 <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13 <table cellpadding="2" width="100%"><tr>
14 <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
15 <td align="center"><a href="../../index.html">Home</a></td>
16 <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
17 <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
18 <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
19 <td align="center"><a href="../../more/index.htm">More</a></td>
22 <div class="spirit-nav">
23 <a accesskey="p" href="mpi/python.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="program_options/tutorial.html"><img src="../../doc/src/images/next.png" alt="Next"></a>
26 <div class="titlepage"><div>
27 <div><h2 class="title">
28 <a name="program_options"></a>Chapter 21. Boost.Program_options</h2></div>
29 <div><div class="author"><h3 class="author">
30 <span class="firstname">Vladimir</span> <span class="surname">Prus</span>
32 <div><p class="copyright">Copyright © 2002-2004 Vladimir Prus</p></div>
33 <div><div class="legalnotice">
34 <a name="idp343121888"></a><p>Distributed under the Boost Software License, Version 1.0.
35 (See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at
36 <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
41 <p><b>Table of Contents</b></p>
43 <dt><span class="section"><a href="program_options.html#idp343124656">Introduction</a></span></dt>
44 <dt><span class="section"><a href="program_options/tutorial.html">Tutorial</a></span></dt>
46 <dt><span class="section"><a href="program_options/tutorial.html#idp343134496">Getting Started</a></span></dt>
47 <dt><span class="section"><a href="program_options/tutorial.html#idp343152640">Option Details</a></span></dt>
48 <dt><span class="section"><a href="program_options/tutorial.html#idp343179072">Multiple Sources</a></span></dt>
50 <dt><span class="section"><a href="program_options/overview.html">Library Overview</a></span></dt>
52 <dt><span class="section"><a href="program_options/overview.html#idp343206656">Options Description Component</a></span></dt>
53 <dt><span class="section"><a href="program_options/overview.html#idp343269664">Parsers Component</a></span></dt>
54 <dt><span class="section"><a href="program_options/overview.html#idp343280080">Storage Component</a></span></dt>
55 <dt><span class="section"><a href="program_options/overview.html#idp343291568">Specific parsers</a></span></dt>
56 <dt><span class="section"><a href="program_options/overview.html#idp343323824">Annotated List of Symbols</a></span></dt>
58 <dt><span class="section"><a href="program_options/howto.html">How To</a></span></dt>
60 <dt><span class="section"><a href="program_options/howto.html#idp343350720">Non-conventional Syntax</a></span></dt>
61 <dt><span class="section"><a href="program_options/howto.html#idp343356848">Response Files</a></span></dt>
62 <dt><span class="section"><a href="program_options/howto.html#idp343364880">Winmain Command Line</a></span></dt>
63 <dt><span class="section"><a href="program_options/howto.html#idp343370112">Option Groups and Hidden Options</a></span></dt>
64 <dt><span class="section"><a href="program_options/howto.html#idp343385248">Custom Validators</a></span></dt>
65 <dt><span class="section"><a href="program_options/howto.html#idp343394240">Unicode Support</a></span></dt>
66 <dt><span class="section"><a href="program_options/howto.html#idp343413520">Allowing Unknown Options</a></span></dt>
68 <dt><span class="section"><a href="program_options/design.html">Design Discussion</a></span></dt>
69 <dd><dl><dt><span class="section"><a href="program_options/design.html#program_options.design.unicode">Unicode Support</a></span></dt></dl></dd>
70 <dt><span class="section"><a href="program_options/s06.html">Acknowledgements</a></span></dt>
71 <dt><span class="section"><a href="program_options/reference.html">Reference</a></span></dt>
73 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.cmdline_hpp">Header <boost/program_options/cmdline.hpp></a></span></dt>
74 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.config_hpp">Header <boost/program_options/config.hpp></a></span></dt>
75 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.environment_iterator_hpp">Header <boost/program_options/environment_iterator.hpp></a></span></dt>
76 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.eof_iterator_hpp">Header <boost/program_options/eof_iterator.hpp></a></span></dt>
77 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.errors_hpp">Header <boost/program_options/errors.hpp></a></span></dt>
78 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.option_hpp">Header <boost/program_options/option.hpp></a></span></dt>
79 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.options_description_hpp">Header <boost/program_options/options_description.hpp></a></span></dt>
80 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.parsers_hpp">Header <boost/program_options/parsers.hpp></a></span></dt>
81 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.positional_options_hpp">Header <boost/program_options/positional_options.hpp></a></span></dt>
82 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.value_semantic_hpp">Header <boost/program_options/value_semantic.hpp></a></span></dt>
83 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.variables_map_hpp">Header <boost/program_options/variables_map.hpp></a></span></dt>
84 <dt><span class="section"><a href="program_options/reference.html#header.boost.program_options.version_hpp">Header <boost/program_options/version.hpp></a></span></dt>
89 <div class="titlepage"><div><div><h2 class="title" style="clear: both">
90 <a name="idp343124656"></a>Introduction</h2></div></div></div>
91 <p>The program_options library allows program developers to obtain
92 <span class="emphasis"><em>program options</em></span>, that is (name, value) pairs from the user,
93 via conventional methods such as command line and config file.</p>
94 <p>Why would you use such a library, and why is it better than parsing
95 your command line by straightforward hand-written code?
97 <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
98 <li class="listitem"><p>It's easier. The syntax for declaring options is simple, and
99 the library itself is small. Things like conversion of option values to
100 desired type and storing into program variables are handled
103 <li class="listitem"><p>Error reporting is better. All the problems with the command line are
104 reported, while hand-written code can just misparse the input. In
105 addition, the usage message can be automatically generated, to
106 avoid falling out of sync with the real list of options.</p></li>
107 <li class="listitem"><p>Options can be read from anywhere. Sooner or later the command
108 line will be not enough for your users, and you'll want config files
109 or maybe even environment variables. These can be added without significant
116 Now let's see some examples of the library usage in the <a class="xref" href="program_options/tutorial.html" title="Tutorial">the section called “Tutorial”</a>.
120 <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
121 <td align="left"></td>
122 <td align="right"><div class="copyright-footer"></div></td>
125 <div class="spirit-nav">
126 <a accesskey="p" href="mpi/python.html"><img src="../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="program_options/tutorial.html"><img src="../../doc/src/images/next.png" alt="Next"></a>