File: Poco.Util.Option.html

package info (click to toggle)
poco-doc 1.3.6-1
  • links: PTS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, squeeze, stretch, wheezy
  • size: 10,076 kB
  • ctags: 9,611
  • sloc: makefile: 31
file content (249 lines) | stat: -rw-r--r-- 19,171 bytes parent folder | download | duplicates (2)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Class Poco::Util::Option</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<meta name="author" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="publisher" content="Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="copyright" content="Copyright (c) 2009, Applied Informatics Software Engineering GmbH and Contributors"/>
<meta name="language" content="en"/>
<meta name="date" content="2009-11-24"/>
<meta name="generator" content="PocoDoc"/>
<link rel="stylesheet" href="css/styles.css" type="text/css"/>
</head>
<body bgcolor="#ffffff" leftmargin="0" topmargin="0">
<div class="header">
<h1 class="namespace"><a href="Poco.Util.html" class="namespace">Poco::Util</a></h1>
<h1 class="symbol">class Option</h1>
</div>
<div class="body">
<p>
<b>Library:</b> Util<br />
<b>Package:</b> Options<br />
<b>Header:</b> Poco/Util/Option.h</p>
<h2>Description</h2>
<div class="description">
<p>This class represents and stores the properties of a command line option. </p>
<p>An option has a full name, an optional short name, a description (used for printing a usage statement), and an optional argument name. An option can be optional or required. An option can be repeatable, which means that it can be given more than once on the command line. </p>
<p>An option can be part of an option group. At most one option of each group may be specified on the command line. </p>
<p>An option can be bound to a configuration property. In this case, a configuration property will automatically receive the option's argument value. </p>
<p>A callback method can be specified for options. This method is called whenever an option is specified on the command line. </p>
<p><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> argument values can be automatically validated using a <a href="Poco.Util.Validator.html" title="class Poco::Util::Validator">Validator</a>. </p>
<p><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> instances are value objects. </p>
<p>Typcally, after construction, an <a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> object is immediately passed to an Options object. </p>
<p>An <a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> object can be created by chaining the constructor with any of the setter methods, as in the following example: </p>
<p></p>
<pre>Option versionOpt(&quot;include&quot;, &quot;I&quot;, &quot;specify an include directory&quot;)
   .required(false)
   .repeatable(true)
   .argument(&quot;directory&quot;);
</pre>
</div>
<h2>Member Summary</h2>
<p><b>Member Functions: </b><a href="Poco.Util.Option.html#16815" title="Poco::Util::Option::argument()">argument</a>, <a href="Poco.Util.Option.html#16837" title="Poco::Util::Option::argumentName()">argumentName</a>, <a href="Poco.Util.Option.html#16836" title="Poco::Util::Option::argumentRequired()">argumentRequired</a>, <a href="Poco.Util.Option.html#16821" title="Poco::Util::Option::binding()">binding</a>, <a href="Poco.Util.Option.html#16826" title="Poco::Util::Option::callback()">callback</a>, <a href="Poco.Util.Option.html#16842" title="Poco::Util::Option::config()">config</a>, <a href="Poco.Util.Option.html#16809" title="Poco::Util::Option::description()">description</a>, <a href="Poco.Util.Option.html#16807" title="Poco::Util::Option::fullName()">fullName</a>, <a href="Poco.Util.Option.html#16819" title="Poco::Util::Option::group()">group</a>, <a href="Poco.Util.Option.html#16845" title="Poco::Util::Option::matchesFull()">matchesFull</a>, <a href="Poco.Util.Option.html#16847" title="Poco::Util::Option::matchesPartial()">matchesPartial</a>, <a href="Poco.Util.Option.html#16843" title="Poco::Util::Option::matchesShort()">matchesShort</a>, <a href="Poco.Util.Option.html#16818" title="Poco::Util::Option::noArgument()">noArgument</a>, <a href="Poco.Util.Option.html#16801" title="Poco::Util::Option::operator =()">operator&nbsp;=</a>, <a href="Poco.Util.Option.html#16849" title="Poco::Util::Option::process()">process</a>, <a href="Poco.Util.Option.html#16813" title="Poco::Util::Option::repeatable()">repeatable</a>, <a href="Poco.Util.Option.html#16811" title="Poco::Util::Option::required()">required</a>, <a href="Poco.Util.Option.html#16805" title="Poco::Util::Option::shortName()">shortName</a>, <a href="Poco.Util.Option.html#16803" title="Poco::Util::Option::swap()">swap</a>, <a href="Poco.Util.Option.html#16835" title="Poco::Util::Option::takesArgument()">takesArgument</a>, <a href="Poco.Util.Option.html#16828" title="Poco::Util::Option::validator()">validator</a></p>
<h2>Constructors</h2>
<h3><a name="16782">Option</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>();</p>
<div class="description">
<p>Creates an empty <a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>. </p>
</div>
<h3><a name="16783">Option</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;const <a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; option<br />);</p>
<div class="description">
<p>Creates an option from another one. </p>
</div>
<h3><a name="16785">Option</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; fullName,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; shortName<br />);</p>
<div class="description">
<p>Creates an option with the given properties. </p>
</div>
<h3><a name="16788">Option</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; fullName,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; shortName,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; description,<br />&nbsp;&nbsp;&nbsp;&nbsp;bool required = false<br />);</p>
<div class="description">
<p>Creates an option with the given properties. </p>
</div>
<h3><a name="16793">Option</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; fullName,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; shortName,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; description,<br />&nbsp;&nbsp;&nbsp;&nbsp;bool required,<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; argName,<br />&nbsp;&nbsp;&nbsp;&nbsp;bool argRequired = false<br />);</p>
<div class="description">
<p>Creates an option with the given properties. </p>
</div>
<h2>Destructor</h2>
<h3><a name="16800">~Option</a></h3>
<p class="decl">~<a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>();</p>
<div class="description">
<p>Destroys the <a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a>. </p>
</div>
<h2>Member Functions</h2>
<h3><a name="16815">argument</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; argument(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; name,<br />&nbsp;&nbsp;&nbsp;&nbsp;bool required = true<br />);</p>
<div class="description">
<p>Specifies that the option takes an (optional or required) argument. </p>
</div>
<h3><a name="16837">argumentName</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">const std::string &amp; argumentName() const;</p>
<div class="description">
<p>Returns the argument name, if specified. </p>
</div>
<h3><a name="16836">argumentRequired</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool argumentRequired() const;</p>
<div class="description">
<p>Returns true if the argument is required. </p>
</div>
<h3><a name="16821">binding</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; binding(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; propertyName<br />);</p>
<div class="description">
<p>Binds the option to the configuration property with the given name. </p>
<p>The configuration will automatically receive the option's argument. </p>
</div>
<h3><a name="16823">binding</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; binding(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; propertyName,<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Util.AbstractConfiguration.html" title="class Poco::Util::AbstractConfiguration">AbstractConfiguration</a> * pConfig<br />);</p>
<div class="description">
<p>Binds the option to the configuration property with the given name,  using the given <a href="Poco.Util.AbstractConfiguration.html" title="class Poco::Util::AbstractConfiguration">AbstractConfiguration</a>. </p>
<p>The configuration will automatically receive the option's argument. </p>
</div>
<h3><a name="16839">binding</a></h3>
<p class="decl">const std::string &amp; binding() const;</p>
<div class="description">
<p>Returns the property name the option is bound to, or an empty string in case it is not bound. </p>
</div>
<h3><a name="16826">callback</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; callback(<br />&nbsp;&nbsp;&nbsp;&nbsp;const <a href="Poco.Util.AbstractOptionCallback.html" title="class Poco::Util::AbstractOptionCallback">AbstractOptionCallback</a> &amp; cb<br />);</p>
<div class="description">
<p>Binds the option to the given method. </p>
<p>The callback method will be called when the option has been specified on the command line. </p>
<p>Usage: </p>
<pre>callback(OptionCallback&lt;MyApplication&gt;(this, &amp;MyApplication::myCallback));
</pre>
</div>
<h3><a name="16840">callback</a></h3>
<p class="decl"><a href="Poco.Util.AbstractOptionCallback.html" title="class Poco::Util::AbstractOptionCallback">AbstractOptionCallback</a> * callback() const;</p>
<div class="description">
<p>Returns a pointer to the callback method for the option, or NULL if no callback has been specified. </p>
</div>
<h3><a name="16842">config</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.AbstractConfiguration.html" title="class Poco::Util::AbstractConfiguration">AbstractConfiguration</a> * config() const;</p>
<div class="description">
<p>Returns the configuration, if specified, or NULL otherwise. </p>
</div>
<h3><a name="16809">description</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; description(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; text<br />);</p>
<div class="description">
<p>Sets the description of the option. </p>
</div>
<h3><a name="16832">description</a></h3>
<p class="decl">const std::string &amp; description() const;</p>
<div class="description">
<p>Returns the description of the option. </p>
</div>
<h3><a name="16807">fullName</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; fullName(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; name<br />);</p>
<div class="description">
<p>Sets the full name of the option. </p>
</div>
<h3><a name="16831">fullName</a></h3>
<p class="decl">const std::string &amp; fullName() const;</p>
<div class="description">
<p>Returns the full name of the option. </p>
</div>
<h3><a name="16819">group</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; group(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; group<br />);</p>
<div class="description">
<p>Specifies the option group the option is part of. </p>
</div>
<h3><a name="16838">group</a></h3>
<p class="decl">const std::string &amp; group() const;</p>
<div class="description">
<p>Returns the option group the option is part of, or an empty string, if the option is not part of a group. </p>
</div>
<h3><a name="16845">matchesFull</a></h3>
<p class="decl">bool matchesFull(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; option<br />) const;</p>
<div class="description">
<p>Returns true if the given option string matches the full name. </p>
<p>The option string must match the full name (case insensitive). </p>
</div>
<h3><a name="16847">matchesPartial</a></h3>
<p class="decl">bool matchesPartial(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; option<br />) const;</p>
<div class="description">
<p>Returns true if the given option string partially matches the full name. </p>
<p>The option string must partially match the full name (case insensitive). </p>
</div>
<h3><a name="16843">matchesShort</a></h3>
<p class="decl">bool matchesShort(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; option<br />) const;</p>
<div class="description">
<p>Returns true if the given option string matches the short name. </p>
<p>The first characters of the option string must match the short name of the option (case sensitive), or the option string must partially match the full name (case insensitive). </p>
</div>
<h3><a name="16818">noArgument</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; noArgument();</p>
<div class="description">
<p>Specifies that the option does not take an argument (default). </p>
</div>
<h3><a name="16801">operator =</a></h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; operator = (<br />&nbsp;&nbsp;&nbsp;&nbsp;const <a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; option<br />);</p>
<div class="description">
<p>Assignment operator. </p>
</div>
<h3><a name="16849">process</a></h3>
<p class="decl">void process(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; option,<br />&nbsp;&nbsp;&nbsp;&nbsp;std::string &amp; arg<br />) const;</p>
<div class="description">
<p>Verifies that the given option string matches the requirements of the option, and extracts the option argument, if present. </p>
<p>If the option string is okay and carries an argument, the argument is returned in arg. </p>
<p>Throws a <a href="Poco.Util.MissingArgumentException.html" title="class Poco::Util::MissingArgumentException">MissingArgumentException</a> if a required argument is missing. Throws an <a href="Poco.Util.UnexpectedArgumentException.html" title="class Poco::Util::UnexpectedArgumentException">UnexpectedArgumentException</a> if an argument has been found, but none is expected.  </p>
</div>
<h3><a name="16813">repeatable</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; repeatable(<br />&nbsp;&nbsp;&nbsp;&nbsp;bool flag<br />);</p>
<div class="description">
<p>Sets whether the option can be specified more than once (flag == true) or at most once (flag == false). </p>
</div>
<h3><a name="16834">repeatable</a></h3>
<p class="decl">bool repeatable() const;</p>
<div class="description">
<p>Returns true if the option can be specified more than once, or false if at most once. </p>
</div>
<h3><a name="16811">required</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; required(<br />&nbsp;&nbsp;&nbsp;&nbsp;bool flag<br />);</p>
<div class="description">
<p>Sets whether the option is required (flag == true) or optional (flag == false). </p>
</div>
<h3><a name="16833">required</a></h3>
<p class="decl">bool required() const;</p>
<div class="description">
<p>Returns true if the option is required, false if not. </p>
</div>
<h3><a name="16805">shortName</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; shortName(<br />&nbsp;&nbsp;&nbsp;&nbsp;const std::string &amp; name<br />);</p>
<div class="description">
<p>Sets the short name of the option. </p>
</div>
<h3><a name="16830">shortName</a></h3>
<p class="decl">const std::string &amp; shortName() const;</p>
<div class="description">
<p>Returns the short name of the option. </p>
</div>
<h3><a name="16803">swap</a></h3>
<p class="decl">void swap(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; option<br />);</p>
<div class="description">
<p>Swaps the option with another one. </p>
</div>
<h3><a name="16835">takesArgument</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl">bool takesArgument() const;</p>
<div class="description">
<p>Returns true if the options takes an (optional) argument. </p>
</div>
<h3><a name="16828">validator</a> <img src="images/inline.gif" alt="inline" title="inline" style="vertical-align:baseline;" border="0" /> </h3>
<p class="decl"><a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> &amp; validator(<br />&nbsp;&nbsp;&nbsp;&nbsp;<a href="Poco.Util.Validator.html" title="class Poco::Util::Validator">Validator</a> * pValidator<br />);</p>
<div class="description">
<p>Sets the validator for the given option. </p>
<p>The <a href="Poco.Util.Option.html" title="class Poco::Util::Option">Option</a> takes ownership of the <a href="Poco.Util.Validator.html" title="class Poco::Util::Validator">Validator</a> and deletes it when it's no longer needed. </p>
</div>
<h3><a name="16841">validator</a></h3>
<p class="decl"><a href="Poco.Util.Validator.html" title="class Poco::Util::Validator">Validator</a> * validator() const;</p>
<div class="description">
<p>Returns the option's <a href="Poco.Util.Validator.html" title="class Poco::Util::Validator">Validator</a>, if one has been specified, or NULL otherwise.	 </p>
</div>
<p class="footer">POCO C++ Libraries 1.3.6-all<br />
Copyright &copy; 2009, <a href="http://pocoproject.org/" target="_blank">Applied Informatics Software Engineering GmbH and Contributors</a></p>

</div>
</body>
</html>