1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Chapter 21. Boost.Program_options</title>
<link rel="stylesheet" href="../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1">
<link rel="home" href="index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries (BoostBook Subset)">
<link rel="prev" href="mpi/python.html" title="Python Bindings">
<link rel="next" href="program_options/tutorial.html" title="Tutorial">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../boost.png"></td>
<td align="center"><a href="../../index.html">Home</a></td>
<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<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>
</div>
<div class="chapter">
<div class="titlepage"><div>
<div><h2 class="title">
<a name="program_options"></a>Chapter 21. Boost.Program_options</h2></div>
<div><div class="author"><h3 class="author">
<span class="firstname">Vladimir</span> <span class="surname">Prus</span>
</h3></div></div>
<div><p class="copyright">Copyright © 2002-2004 Vladimir Prus</p></div>
<div><div class="legalnotice">
<a name="idp163284648"></a><p>Distributed under the Boost Software License, Version 1.0.
(See accompanying file <code class="filename">LICENSE_1_0.txt</code> or copy at
<a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
</p>
</div></div>
</div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl class="toc">
<dt><span class="section"><a href="program_options.html#idp163286136">Introduction</a></span></dt>
<dt><span class="section"><a href="program_options/tutorial.html">Tutorial</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="program_options/tutorial.html#idp163291912">Getting Started</a></span></dt>
<dt><span class="section"><a href="program_options/tutorial.html#idp163301368">Option Details</a></span></dt>
<dt><span class="section"><a href="program_options/tutorial.html#idp163316264">Multiple Sources</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="program_options/overview.html">Library Overview</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="program_options/overview.html#idp163331176">Options Description Component</a></span></dt>
<dt><span class="section"><a href="program_options/overview.html#idp163366168">Parsers Component</a></span></dt>
<dt><span class="section"><a href="program_options/overview.html#idp163372680">Storage Component</a></span></dt>
<dt><span class="section"><a href="program_options/overview.html#idp163378856">Specific parsers</a></span></dt>
<dt><span class="section"><a href="program_options/overview.html#idp163396472">Annotated List of Symbols</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="program_options/howto.html">How To</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="program_options/howto.html#idp163410568">Non-conventional Syntax</a></span></dt>
<dt><span class="section"><a href="program_options/howto.html#idp163413704">Response Files</a></span></dt>
<dt><span class="section"><a href="program_options/howto.html#idp163418392">Winmain Command Line</a></span></dt>
<dt><span class="section"><a href="program_options/howto.html#idp163421144">Option Groups and Hidden Options</a></span></dt>
<dt><span class="section"><a href="program_options/howto.html#idp163429032">Custom Validators</a></span></dt>
<dt><span class="section"><a href="program_options/howto.html#idp163433416">Unicode Support</a></span></dt>
<dt><span class="section"><a href="program_options/howto.html#idp163444056">Allowing Unknown Options</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="program_options/design.html">Design Discussion</a></span></dt>
<dd><dl><dt><span class="section"><a href="program_options/design.html#program_options.design.unicode">Unicode Support</a></span></dt></dl></dd>
<dt><span class="section"><a href="program_options/s06.html">Acknowledgements</a></span></dt>
<dt><span class="section"><a href="program_options/reference.html">Reference</a></span></dt>
<dd><dl>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
</dl></dd>
</dl>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="idp163286136"></a>Introduction</h2></div></div></div>
<p>The program_options library allows program developers to obtain
<span class="emphasis"><em>program options</em></span>, that is (name, value) pairs from the user,
via conventional methods such as command line and config file.</p>
<p>Why would you use such a library, and why is it better than parsing
your command line by straightforward hand-written code?
</p>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>It's easier. The syntax for declaring options is simple, and
the library itself is small. Things like conversion of option values to
desired type and storing into program variables are handled
automatically.
</p></li>
<li class="listitem"><p>Error reporting is better. All the problems with the command line are
reported, while hand-written code can just misparse the input. In
addition, the usage message can be automatically generated, to
avoid falling out of sync with the real list of options.</p></li>
<li class="listitem"><p>Options can be read from anywhere. Sooner or later the command
line will be not enough for your users, and you'll want config files
or maybe even environment variables. These can be added without significant
effort on your part.
</p></li>
</ul></div>
<p>
</p>
<p>
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>.
</p>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 25, 2007 at 18:38:02 +0000</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<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>
</div>
</body>
</html>
|