1 | <html> |
---|
2 | <head> |
---|
3 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
---|
4 | <title>Chapter 7. Boost.Program_options</title> |
---|
5 | <link rel="stylesheet" href="boostbook.css" type="text/css"> |
---|
6 | <meta name="generator" content="DocBook XSL Stylesheets V1.69.1"> |
---|
7 | <link rel="start" href="index.html" title="The Boost C++ Libraries"> |
---|
8 | <link rel="up" href="libraries.html" title="Part I. The Boost C++ Libraries"> |
---|
9 | <link rel="prev" href="apa.html" title="Appendix A. Rationale for some of the design decisions"> |
---|
10 | <link rel="next" href="program_options/tutorial.html" title="Tutorial"> |
---|
11 | </head> |
---|
12 | <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
---|
13 | <table cellpadding="2" width="100%"> |
---|
14 | <td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td> |
---|
15 | <td align="center"><a href="../../index.htm">Home</a></td> |
---|
16 | <td align="center"><a href="../../libs/libraries.htm">Libraries</a></td> |
---|
17 | <td align="center"><a href="../../people/people.htm">People</a></td> |
---|
18 | <td align="center"><a href="../../more/faq.htm">FAQ</a></td> |
---|
19 | <td align="center"><a href="../../more/index.htm">More</a></td> |
---|
20 | </table> |
---|
21 | <hr> |
---|
22 | <div class="spirit-nav"> |
---|
23 | <a accesskey="p" href="apa.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="program_options/tutorial.html"><img src="images/next.png" alt="Next"></a> |
---|
24 | </div> |
---|
25 | <div class="chapter" lang="en"> |
---|
26 | <div class="titlepage"><div> |
---|
27 | <div><h2 class="title"> |
---|
28 | <a name="program_options"></a>Chapter 7. Boost.Program_options</h2></div> |
---|
29 | <div><div class="author"><h3 class="author"> |
---|
30 | <span class="firstname">Vladimir</span> <span class="surname">Prus</span> |
---|
31 | </h3></div></div> |
---|
32 | <div><p class="copyright">Copyright © 2002-2004 Vladimir Prus</p></div> |
---|
33 | <div><div class="legalnotice"> |
---|
34 | <a name="id2714112"></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>) |
---|
37 | </p> |
---|
38 | </div></div> |
---|
39 | </div></div> |
---|
40 | <div class="toc"> |
---|
41 | <p><b>Table of Contents</b></p> |
---|
42 | <dl> |
---|
43 | <dt><span class="section"><a href="program_options.html#id2714132">Introduction</a></span></dt> |
---|
44 | <dt><span class="section"><a href="program_options/tutorial.html">Tutorial</a></span></dt> |
---|
45 | <dd><dl> |
---|
46 | <dt><span class="section"><a href="program_options/tutorial.html#id2714212">Getting Started</a></span></dt> |
---|
47 | <dt><span class="section"><a href="program_options/tutorial.html#id2714372">Option Details</a></span></dt> |
---|
48 | <dt><span class="section"><a href="program_options/tutorial.html#id2714557">Multiple Sources</a></span></dt> |
---|
49 | </dl></dd> |
---|
50 | <dt><span class="section"><a href="program_options/overview.html">Library Overview</a></span></dt> |
---|
51 | <dd><dl> |
---|
52 | <dt><span class="section"><a href="program_options/overview.html#id2714805">Options Description Component</a></span></dt> |
---|
53 | <dt><span class="section"><a href="program_options/overview.html#id2715353">Parsers Component</a></span></dt> |
---|
54 | <dt><span class="section"><a href="program_options/overview.html#id2715436">Storage Component</a></span></dt> |
---|
55 | <dt><span class="section"><a href="program_options/overview.html#id2715519">Specific parsers</a></span></dt> |
---|
56 | <dt><span class="section"><a href="program_options/overview.html#id2715692">Annotated List of Symbols</a></span></dt> |
---|
57 | </dl></dd> |
---|
58 | <dt><span class="section"><a href="program_options/howto.html">How To</a></span></dt> |
---|
59 | <dd><dl> |
---|
60 | <dt><span class="section"><a href="program_options/howto.html#id2715843">Non-conventional Syntax</a></span></dt> |
---|
61 | <dt><span class="section"><a href="program_options/howto.html#id2715898">Response Files</a></span></dt> |
---|
62 | <dt><span class="section"><a href="program_options/howto.html#id2715975">Winmain Command Line</a></span></dt> |
---|
63 | <dt><span class="section"><a href="program_options/howto.html#id2716014">Option Groups and Hidden Options</a></span></dt> |
---|
64 | <dt><span class="section"><a href="program_options/howto.html#id2716150">Custom Validators</a></span></dt> |
---|
65 | <dt><span class="section"><a href="program_options/howto.html#id2716238">Unicode Support</a></span></dt> |
---|
66 | <dt><span class="section"><a href="program_options/howto.html#id2716386">Allowing Unknown Options</a></span></dt> |
---|
67 | </dl></dd> |
---|
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> |
---|
72 | <dd><dl> |
---|
73 | <dt><span class="section"><a href="program_options/reference.html#id2355176">Header <boost/program_options/cmdline.hpp></a></span></dt> |
---|
74 | <dt><span class="section"><a href="program_options/reference.html#id2380073">Header <boost/program_options/environment_iterator.hpp></a></span></dt> |
---|
75 | <dt><span class="section"><a href="program_options/reference.html#id2338601">Header <boost/program_options/eof_iterator.hpp></a></span></dt> |
---|
76 | <dt><span class="section"><a href="program_options/reference.html#id2399042">Header <boost/program_options/errors.hpp></a></span></dt> |
---|
77 | <dt><span class="section"><a href="program_options/reference.html#id2359341">Header <boost/program_options/option.hpp></a></span></dt> |
---|
78 | <dt><span class="section"><a href="program_options/reference.html#id2473651">Header <boost/program_options/options_description.hpp></a></span></dt> |
---|
79 | <dt><span class="section"><a href="program_options/reference.html#id2348797">Header <boost/program_options/parsers.hpp></a></span></dt> |
---|
80 | <dt><span class="section"><a href="program_options/reference.html#id2525887">Header <boost/program_options/positional_options.hpp></a></span></dt> |
---|
81 | <dt><span class="section"><a href="program_options/reference.html#id2379391">Header <boost/program_options/value_semantic.hpp></a></span></dt> |
---|
82 | <dt><span class="section"><a href="program_options/reference.html#id2524541">Header <boost/program_options/variables_map.hpp></a></span></dt> |
---|
83 | <dt><span class="section"><a href="program_options/reference.html#id2363464">Header <boost/program_options/version.hpp></a></span></dt> |
---|
84 | </dl></dd> |
---|
85 | </dl> |
---|
86 | </div> |
---|
87 | <div class="section" lang="en"> |
---|
88 | <div class="titlepage"><div><div><h3 class="title"> |
---|
89 | <a name="id2714132"></a>Introduction</h3></div></div></div> |
---|
90 | <p>The program_options library allows program developers to obtain |
---|
91 | <span class="emphasis"><em>program options</em></span>, that is (name, value) pairs from the user, |
---|
92 | via conventional methods such as command line and config file.</p> |
---|
93 | <p>Why would you use such a library, and why is it better than parsing |
---|
94 | your command line by straightforward hand-written code? |
---|
95 | </p> |
---|
96 | <div class="itemizedlist"><ul type="disc"> |
---|
97 | <li><p>It's easier. The syntax for declaring options is simple, and |
---|
98 | the library itself is small. Things like conversion of option values to |
---|
99 | desired type and storing into program variables are handled |
---|
100 | automatically. |
---|
101 | </p></li> |
---|
102 | <li><p>Error reporting is better. All the problems with the command line are |
---|
103 | reported, while hand-written code can just misparse the input. In |
---|
104 | addition, the usage message can be automatically generated, to |
---|
105 | avoid falling out of sync with the real list of options.</p></li> |
---|
106 | <li><p>Options can be read from anywhere. Sooner or later the command |
---|
107 | line will be not enough for your users, and you'll want config files |
---|
108 | or maybe even environment variables. These can be added without significant |
---|
109 | effort on your part. |
---|
110 | </p></li> |
---|
111 | </ul></div> |
---|
112 | <p> |
---|
113 | Now let's see some examples of the library usage in the <a href="program_options/tutorial.html" title="Tutorial">the section called “Tutorial”</a>. |
---|
114 | </p> |
---|
115 | </div> |
---|
116 | </div> |
---|
117 | <table width="100%"><tr> |
---|
118 | <td align="left"><small><p>Last revised: July 30, 2004 at 13:20:27 GMT</p></small></td> |
---|
119 | <td align="right"><small></small></td> |
---|
120 | </tr></table> |
---|
121 | <hr> |
---|
122 | <div class="spirit-nav"> |
---|
123 | <a accesskey="p" href="apa.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="libraries.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="program_options/tutorial.html"><img src="images/next.png" alt="Next"></a> |
---|
124 | </div> |
---|
125 | </body> |
---|
126 | </html> |
---|