Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/doc/html/option_description.html @ 25

Last change on this file since 25 was 12, checked in by landauf, 17 years ago

added boost

File size: 11.4 KB
Line 
1<html>
2<head>
3<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
4<title>Class option_description</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="program_options/reference.html#id2473651" title="Header &lt;boost/program_options/options_description.hpp&gt;">
9<link rel="prev" href="basic_option.html" title="Class template basic_option">
10<link rel="next" href="id2411202.html" title="Class options_description_easy_init">
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="basic_option.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="program_options/reference.html#id2473651"><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="id2411202.html"><img src="images/next.png" alt="Next"></a>
24</div>
25<div class="refentry" lang="en">
26<a name="option_description"></a><div class="titlepage"></div>
27<div class="refnamediv">
28<h2><span class="refentrytitle">Class option_description</span></h2>
29<p>boost::program_options::option_description &#8212; </p>
30</div>
31<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
32<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis">
33<span class="bold"><strong>class</strong></span> option_description {
34<span class="bold"><strong>public</strong></span>:
35  <span class="emphasis"><em>// <a href="option_description.html#option_descriptionconstruct-copy-destruct">construct/copy/destruct</a></em></span>
36  <a href="option_description.html#id2336994-bb">option_description</a>();
37  <a href="option_description.html#id2336996-bb">option_description</a>(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> *, <span class="bold"><strong>const</strong></span> <a href="value_semantic.html" title="Class value_semantic">value_semantic</a> *);
38  <a href="option_description.html#id2496239-bb">option_description</a>(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> *, <span class="bold"><strong>const</strong></span> <a href="value_semantic.html" title="Class value_semantic">value_semantic</a> *, <span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> *);
39  <a href="option_description.html#id2365528-bb">~option_description</a>();
40
41  <span class="emphasis"><em>// <a href="option_description.html#id2399875-bb">public member functions</a></em></span>
42  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="option_description.html#id2380521-bb">match</a>(<span class="bold"><strong>const</strong></span> std::string &amp;, <span class="bold"><strong>bool</strong></span>) <span class="bold"><strong>const</strong></span>;
43  <span class="type"><span class="bold"><strong>const</strong></span> std::string &amp;</span> <a href="option_description.html#id2508624-bb">key</a>(<span class="bold"><strong>const</strong></span> std::string &amp;) <span class="bold"><strong>const</strong></span>;
44  <span class="type"><span class="bold"><strong>const</strong></span> std::string &amp;</span> <a href="option_description.html#id2376105-bb">long_name</a>() <span class="bold"><strong>const</strong></span>;
45  <span class="type"><span class="bold"><strong>const</strong></span> std::string &amp;</span> <a href="option_description.html#id2376118-bb">description</a>() <span class="bold"><strong>const</strong></span>;
46  <span class="type">shared_ptr&lt; <span class="bold"><strong>const</strong></span> <a href="value_semantic.html" title="Class value_semantic">value_semantic</a> &gt;</span> <a href="option_description.html#id2340842-bb">semantic</a>() <span class="bold"><strong>const</strong></span>;
47  <span class="type">std::string</span> <a href="option_description.html#id2461312-bb">format_name</a>() <span class="bold"><strong>const</strong></span>;
48  <span class="type">std::string</span> <a href="option_description.html#id2343692-bb">format_parameter</a>() <span class="bold"><strong>const</strong></span>;
49
50  <span class="emphasis"><em>// <a href="option_description.html#id2365530-bb">private member functions</a></em></span>
51  <span class="type"><a href="option_description.html" title="Class option_description">option_description</a> &amp;</span> <a href="option_description.html#id2365535-bb">set_name</a>(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> *) ;
52};</pre></div>
53<div class="refsect1" lang="en">
54<a name="id2720910"></a><h2>Description</h2>
55<p>Describes one possible command line/config file option. There are two kinds of properties of an option. First describe it syntactically and are used only to validate input. Second affect interpretation of the option, for example default value for it or function that should be called when the value is finally known. Routines which perform parsing never use second kind of properties -- they are side effect free. </p>
56<p>options_description </p>
57<div class="refsect2" lang="en">
58<a name="id2720925"></a><h3>
59<a name="option_descriptionconstruct-copy-destruct"></a><code class="computeroutput">option_description</code> construct/copy/destruct</h3>
60<div class="orderedlist"><ol type="1">
61<li><pre class="literallayout"><a name="id2336994-bb"></a>option_description();</pre></li>
62<li>
63<pre class="literallayout"><a name="id2336996-bb"></a>option_description(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> * name, <span class="bold"><strong>const</strong></span> <a href="value_semantic.html" title="Class value_semantic">value_semantic</a> * s);</pre>
64<p>Initializes the object with the passed data.</p>
65<p>Note: it would be nice to make the second parameter auto_ptr, to explicitly pass ownership. Unfortunately, it's often needed to create objects of types derived from 'value_semantic': options_description d; d.add_options()("a", parameter&lt;int&gt;("n")-&gt;default_value(1)); Here, the static type returned by 'parameter' should be derived from value_semantic.</p>
66<p>Alas, derived-&gt;base conversion for auto_ptr does not really work, see http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2000/n1232.pdf http://std.dkuug.dk/jtc1/sc22/wg21/docs/cwg_defects.html#84</p>
67<p>So, we have to use plain old pointers. Besides, users are not expected to use the constructor directly.</p>
68<p>The 'name' parameter is interpreted by the following rules:</p>
69<div class="itemizedlist"><ul type="disc">
70<li><p>if there's no "," character in 'name', it specifies long name</p></li>
71<li><p>otherwise, the part before "," specifies long name and the part after -- long name. </p></li>
72</ul></div>
73</li>
74<li>
75<pre class="literallayout"><a name="id2496239-bb"></a>option_description(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> * name, <span class="bold"><strong>const</strong></span> <a href="value_semantic.html" title="Class value_semantic">value_semantic</a> * s,
76                   <span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> * description);</pre>
77<p>Initializes the class with the passed data. </p>
78</li>
79<li><pre class="literallayout"><a name="id2365528-bb"></a>~option_description();</pre></li>
80</ol></div>
81</div>
82<div class="refsect2" lang="en">
83<a name="id2721106"></a><h3>
84<a name="id2399875-bb"></a><code class="computeroutput">option_description</code> public member functions</h3>
85<div class="orderedlist"><ol type="1">
86<li>
87<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id2380521-bb"></a>match(<span class="bold"><strong>const</strong></span> std::string &amp; option, <span class="bold"><strong>bool</strong></span> approx) <span class="bold"><strong>const</strong></span>;</pre>
88<p>Given 'option', specified in the input source, return 'true' is 'option' specifies *this. </p>
89</li>
90<li>
91<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> std::string &amp;</span> <a name="id2508624-bb"></a>key(<span class="bold"><strong>const</strong></span> std::string &amp; option) <span class="bold"><strong>const</strong></span>;</pre>
92<p>Return the key that should identify the option, in particular in the variables_map class. The 'option' parameter is the option spelling from the input source. If option name contains '*', returns 'option'. If long name was specified, it's the long name, otherwise it's a short name with prepended '-'. </p>
93</li>
94<li><pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> std::string &amp;</span> <a name="id2376105-bb"></a>long_name() <span class="bold"><strong>const</strong></span>;</pre></li>
95<li><pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span> std::string &amp;</span> <a name="id2376118-bb"></a>description() <span class="bold"><strong>const</strong></span>;</pre></li>
96<li><pre class="literallayout"><span class="type">shared_ptr&lt; <span class="bold"><strong>const</strong></span> <a href="value_semantic.html" title="Class value_semantic">value_semantic</a> &gt;</span> <a name="id2340842-bb"></a>semantic() <span class="bold"><strong>const</strong></span>;</pre></li>
97<li><pre class="literallayout"><span class="type">std::string</span> <a name="id2461312-bb"></a>format_name() <span class="bold"><strong>const</strong></span>;</pre></li>
98<li>
99<pre class="literallayout"><span class="type">std::string</span> <a name="id2343692-bb"></a>format_parameter() <span class="bold"><strong>const</strong></span>;</pre>
100<p>Return the parameter name and properties, formatted suitably for usage message. </p>
101</li>
102</ol></div>
103</div>
104<div class="refsect2" lang="en">
105<a name="id2721353"></a><h3>
106<a name="id2365530-bb"></a><code class="computeroutput">option_description</code> private member functions</h3>
107<div class="orderedlist"><ol type="1"><li><pre class="literallayout"><span class="type"><a href="option_description.html" title="Class option_description">option_description</a> &amp;</span> <a name="id2365535-bb"></a>set_name(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> * name) ;</pre></li></ol></div>
108</div>
109</div>
110</div>
111<table width="100%"><tr>
112<td align="left"></td>
113<td align="right"><small>Copyright © 2002-2004 Vladimir Prus</small></td>
114</tr></table>
115<hr>
116<div class="spirit-nav">
117<a accesskey="p" href="basic_option.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="program_options/reference.html#id2473651"><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="id2411202.html"><img src="images/next.png" alt="Next"></a>
118</div>
119</body>
120</html>
Note: See TracBrowser for help on using the repository browser.