summaryrefslogtreecommitdiff
path: root/doc/html/option_description.html
blob: 7b63a3783726a200eed7adf7659d33c437a1322e (plain)
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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Class option_description</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
<link rel="start" href="index.html" title="The Boost C++ Libraries">
<link rel="up" href="program_options/reference.html#id835103" title="Header &lt;boost/program_options/options_description.hpp&gt;">
<link rel="prev" href="duplicate_option_error.html" title="Class duplicate_option_error">
<link rel="next" href="options_description.html" title="Class options_description">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%">
<td valign="top"><img alt="boost.png (6897 bytes)" width="277" height="86" src="../../boost.png"></td>
<td align="center"><a href="../../index.htm">Home</a></td>
<td align="center"><a href="../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="../../people/people.htm">People</a></td>
<td align="center"><a href="../../more/faq.htm">FAQ</a></td>
<td align="center"><a href="../../more/index.htm">More</a></td>
</table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="duplicate_option_error.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="program_options/reference.html#id835103"><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="options_description.html"><img src="images/next.png" alt="Next"></a>
</div>
<div class="refentry" lang="en">
<a name="option_description"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class option_description</span></h2>
<p>boost::program_options::option_description &#8212; </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis">
<span class="bold"><strong>class</strong></span> option_description {
<span class="bold"><strong>public</strong></span>:
  <span class="emphasis"><em>// <a href="option_description.html#option_descriptionconstruct-copy-destruct">construct/copy/destruct</a></em></span>
  <a href="option_description.html#id962641-bb">option_description</a>();
  <a href="option_description.html#id962643-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> *);
  <a href="option_description.html#id764286-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> *);
  <a href="option_description.html#id756834-bb">~option_description</a>();

  <span class="emphasis"><em>// <a href="option_description.html#id729258-bb">public member functions</a></em></span>
  <span class="type"><span class="bold"><strong>bool</strong></span></span> <a href="option_description.html#id1109513-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>;
  <span class="type"><span class="bold"><strong>const</strong></span>  std::string &amp;</span> <a href="option_description.html#id663838-bb">key</a>(<span class="bold"><strong>const</strong></span> std::string &amp;) <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>const</strong></span>  std::string &amp;</span> <a href="option_description.html#id1006651-bb">long_name</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type"><span class="bold"><strong>const</strong></span>  std::string &amp;</span> <a href="option_description.html#id791699-bb">description</a>() <span class="bold"><strong>const</strong></span>;
  <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#id934552-bb">semantic</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">std::string</span> <a href="option_description.html#id1081789-bb">format_name</a>() <span class="bold"><strong>const</strong></span>;
  <span class="type">std::string</span> <a href="option_description.html#id864053-bb">format_parameter</a>() <span class="bold"><strong>const</strong></span>;

  <span class="emphasis"><em>// <a href="option_description.html#id756836-bb">private member functions</a></em></span>
  <span class="type"><a href="option_description.html" title="Class option_description">option_description</a> &amp;</span> <a href="option_description.html#id757426-bb">set_name</a>(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> *) ;
};</pre></div>
<div class="refsect1" lang="en">
<a name="id1252751"></a><h2>Description</h2>
<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>
<p>options_description </p>
<div class="refsect2" lang="en">
<a name="id1252766"></a><h3>
<a name="option_descriptionconstruct-copy-destruct"></a><code class="computeroutput">option_description</code> construct/copy/destruct</h3>
<div class="orderedlist"><ol type="1">
<li><pre class="literallayout"><a name="id962641-bb"></a>option_description();</pre></li>
<li>
<pre class="literallayout"><a name="id962643-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>
<p>Initializes the object with the passed data.</p>
<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>
<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>
<p>So, we have to use plain old pointers. Besides, users are not expected to use the constructor directly.</p>
<p>The 'name' parameter is interpreted by the following rules:</p>
<div class="itemizedlist"><ul type="disc">
<li><p>if there's no "," character in 'name', it specifies long name</p></li>
<li><p>otherwise, the part before "," specifies long name and the part after -- long name. </p></li>
</ul></div>
</li>
<li>
<pre class="literallayout"><a name="id764286-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, 
                   <span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> * description);</pre>
<p>Initializes the class with the passed data. </p>
</li>
<li><pre class="literallayout"><a name="id756834-bb"></a>~option_description();</pre></li>
</ol></div>
</div>
<div class="refsect2" lang="en">
<a name="id1252945"></a><h3>
<a name="id729258-bb"></a><code class="computeroutput">option_description</code> public member functions</h3>
<div class="orderedlist"><ol type="1">
<li>
<pre class="literallayout"><span class="type"><span class="bold"><strong>bool</strong></span></span> <a name="id1109513-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>
<p>Given 'option', specified in the input source, return 'true' is 'option' specifies *this. </p>
</li>
<li>
<pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span>  std::string &amp;</span> <a name="id663838-bb"></a>key(<span class="bold"><strong>const</strong></span> std::string &amp; option) <span class="bold"><strong>const</strong></span>;</pre>
<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>
</li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span>  std::string &amp;</span> <a name="id1006651-bb"></a>long_name() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type"><span class="bold"><strong>const</strong></span>  std::string &amp;</span> <a name="id791699-bb"></a>description() <span class="bold"><strong>const</strong></span>;</pre></li>
<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="id934552-bb"></a>semantic() <span class="bold"><strong>const</strong></span>;</pre></li>
<li><pre class="literallayout"><span class="type">std::string</span> <a name="id1081789-bb"></a>format_name() <span class="bold"><strong>const</strong></span>;</pre></li>
<li>
<pre class="literallayout"><span class="type">std::string</span> <a name="id864053-bb"></a>format_parameter() <span class="bold"><strong>const</strong></span>;</pre>
<p>Return the parameter name and properties, formatted suitably for usage message. </p>
</li>
</ol></div>
</div>
<div class="refsect2" lang="en">
<a name="id1253185"></a><h3>
<a name="id756836-bb"></a><code class="computeroutput">option_description</code> private member functions</h3>
<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="id757426-bb"></a>set_name(<span class="bold"><strong>const</strong></span> <span class="bold"><strong>char</strong></span> * name) ;</pre></li></ol></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><small>Copyright © 2002-2004 Vladimir Prus</small></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="duplicate_option_error.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="program_options/reference.html#id835103"><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="options_description.html"><img src="images/next.png" alt="Next"></a>
</div>
</body>
</html>