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
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Exiv2: Util::Getopt Class Reference</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
<link href="tabs.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.6 -->
<div class="tabs">
<ul>
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li id="current"><a href="classes.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
<li><a href="examples.html"><span>Examples</span></a></li>
</ul></div>
<div class="tabs">
<ul>
<li><a href="classes.html"><span>Alphabetical List</span></a></li>
<li><a href="annotated.html"><span>Class List</span></a></li>
<li><a href="hierarchy.html"><span>Class Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class Members</span></a></li>
</ul></div>
<div class="nav">
<a class="el" href="namespaceUtil.html">Util</a>::<a class="el" href="classUtil_1_1Getopt.html">Getopt</a></div>
<h1>Util::Getopt Class Reference</h1><!-- doxytag: class="Util::Getopt" -->Parse the command line options of a program.
<a href="#_details">More...</a>
<p>
<code>#include <utils.hpp></code>
<p>
Inheritance diagram for Util::Getopt:<p><center><img src="classUtil_1_1Getopt__inherit__graph.png" border="0" usemap="#Util_1_1Getopt__inherit__map" alt="Inheritance graph"></center>
<map name="Util_1_1Getopt__inherit__map">
<area href="classParams.html" shape="rect" coords="16,81,83,105" alt="">
</map>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center>Collaboration diagram for Util::Getopt:<p><center><img src="classUtil_1_1Getopt__coll__graph.png" border="0" usemap="#Util_1_1Getopt__coll__map" alt="Collaboration graph"></center>
<center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center><a href="classUtil_1_1Getopt-members.html">List of all members.</a><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
<tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="b376b23300a3609929509138b218f91f"></a><!-- doxytag: member="Util::Getopt::Getopt" ref="b376b23300a3609929509138b218f91f" args="()" -->
</td><td class="memItemRight" valign="bottom"><a class="el" href="classUtil_1_1Getopt.html#b376b23300a3609929509138b218f91f">Getopt</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="355c5d5f1c442febecbef3ee8958c090"></a><!-- doxytag: member="Util::Getopt::~Getopt" ref="355c5d5f1c442febecbef3ee8958c090" args="()" -->
virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classUtil_1_1Getopt.html#355c5d5f1c442febecbef3ee8958c090">~Getopt</a> ()</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classUtil_1_1Getopt.html#e0f18bdea00878d0e8a9e83370a0812e">getopt</a> (int argc, char *const argv[], const std::string &optstring)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Parse command line arguments. <a href="#e0f18bdea00878d0e8a9e83370a0812e"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int </td><td class="memItemRight" valign="bottom"><a class="el" href="classUtil_1_1Getopt.html#27e365f1f9710ce80f4b534686d7e887">option</a> (int opt, const std::string &optarg, int optopt)=0</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Callback used by <a class="el" href="classUtil_1_1Getopt.html#e0f18bdea00878d0e8a9e83370a0812e">getopt()</a> to pass on each option and its argument (if any). <a href="#27e365f1f9710ce80f4b534686d7e887"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top">virtual int </td><td class="memItemRight" valign="bottom"><a class="el" href="classUtil_1_1Getopt.html#f182b096eb3da4ce48c1bbb8b84817b1">nonoption</a> (const std::string &argv)</td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Callback used by <a class="el" href="classUtil_1_1Getopt.html#e0f18bdea00878d0e8a9e83370a0812e">getopt()</a> to pass on each non-option parameter found on the command line. <a href="#f182b096eb3da4ce48c1bbb8b84817b1"></a><br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="d9bfd88842108ef3506c3567bc63dec0"></a><!-- doxytag: member="Util::Getopt::progname" ref="d9bfd88842108ef3506c3567bc63dec0" args="() const " -->
const std::string & </td><td class="memItemRight" valign="bottom"><a class="el" href="classUtil_1_1Getopt.html#d9bfd88842108ef3506c3567bc63dec0">progname</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Program name (argv[0]). <br></td></tr>
<tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="504c4af3e01af5466459c03a90bafb83"></a><!-- doxytag: member="Util::Getopt::errcnt" ref="504c4af3e01af5466459c03a90bafb83" args="() const " -->
int </td><td class="memItemRight" valign="bottom"><a class="el" href="classUtil_1_1Getopt.html#504c4af3e01af5466459c03a90bafb83">errcnt</a> () const </td></tr>
<tr><td class="mdescLeft"> </td><td class="mdescRight">Total number of errors returned by calls to <a class="el" href="classUtil_1_1Getopt.html#27e365f1f9710ce80f4b534686d7e887">option()</a>. <br></td></tr>
</table>
<hr><a name="_details"></a><h2>Detailed Description</h2>
Parse the command line options of a program.
<p>
A wrapper around the POSIX getopt(3) function. Parses the command line options and passes each option to virtual <a class="el" href="classUtil_1_1Getopt.html#27e365f1f9710ce80f4b534686d7e887">option()</a>. A derived class implements this method to handle options as needed. Similarly, remaining non-option parameters are passed to the virtual <a class="el" href="classUtil_1_1Getopt.html#f182b096eb3da4ce48c1bbb8b84817b1">nonoption()</a> method.
<p>
<hr><h2>Member Function Documentation</h2>
<a class="anchor" name="e0f18bdea00878d0e8a9e83370a0812e"></a><!-- doxytag: member="Util::Getopt::getopt" ref="e0f18bdea00878d0e8a9e83370a0812e" args="(int argc, char *const argv[], const std::string &optstring)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">int Util::Getopt::getopt </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">int </td>
<td class="mdname" nowrap> <em>argc</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>char *const </td>
<td class="mdname" nowrap> <em>argv</em>[], </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>const std::string & </td>
<td class="mdname" nowrap> <em>optstring</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">) </td>
<td class="md" colspan="2"></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Parse command line arguments.
<p>
Parses the command line arguments. Calls <a class="el" href="classUtil_1_1Getopt.html#27e365f1f9710ce80f4b534686d7e887">option()</a> with the character value of the option and its argument (if any) for each recognized option and with ':' or '?' for unrecognized options. See the manual pages for getopt(3) for details. In addition, <a class="el" href="classUtil_1_1Getopt.html#f182b096eb3da4ce48c1bbb8b84817b1">nonoption()</a> is invoked for each remaining non-option parameter on the command line.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>argc</em> </td><td>Argument count as passed to main() on program invocation. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>argv</em> </td><td>Argument array as passed to main() on program invocation. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>optstring</em> </td><td>String containing the legitimate option characters.</td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>Number of errors (the sum of the return values from <a class="el" href="classUtil_1_1Getopt.html#27e365f1f9710ce80f4b534686d7e887">option()</a> and <a class="el" href="classUtil_1_1Getopt.html#f182b096eb3da4ce48c1bbb8b84817b1">nonoption()</a>). </dd></dl>
</td>
</tr>
</table>
<a class="anchor" name="f182b096eb3da4ce48c1bbb8b84817b1"></a><!-- doxytag: member="Util::Getopt::nonoption" ref="f182b096eb3da4ce48c1bbb8b84817b1" args="(const std::string &argv)" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">int Util::Getopt::nonoption </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">const std::string & </td>
<td class="mdname1" valign="top" nowrap> <em>argv</em> </td>
<td class="md" valign="top"> ) </td>
<td class="md" nowrap><code> [virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Callback used by <a class="el" href="classUtil_1_1Getopt.html#e0f18bdea00878d0e8a9e83370a0812e">getopt()</a> to pass on each non-option parameter found on the command line.
<p>
Implement this method in a derived class to handle the non-option parameters as needed. The default implementation ignores all non-option parameters.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>argv</em> </td><td>The non-option parameter from the command line.</td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>0 if successful, 1 in case of an error. </dd></dl>
<p>
Reimplemented in <a class="el" href="classParams.html#00a1171555548b5903e52a12354309b4">Params</a>, and <a class="el" href="classParams.html#f788b09ae4abb849e760e3a46e92bcf2">Params</a>. </td>
</tr>
</table>
<a class="anchor" name="27e365f1f9710ce80f4b534686d7e887"></a><!-- doxytag: member="Util::Getopt::option" ref="27e365f1f9710ce80f4b534686d7e887" args="(int opt, const std::string &optarg, int optopt)=0" --><p>
<table class="mdTable" cellpadding="2" cellspacing="0">
<tr>
<td class="mdRow">
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="md" nowrap valign="top">virtual int Util::Getopt::option </td>
<td class="md" valign="top">( </td>
<td class="md" nowrap valign="top">int </td>
<td class="mdname" nowrap> <em>opt</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>const std::string & </td>
<td class="mdname" nowrap> <em>optarg</em>, </td>
</tr>
<tr>
<td class="md" nowrap align="right"></td>
<td class="md"></td>
<td class="md" nowrap>int </td>
<td class="mdname" nowrap> <em>optopt</em></td>
</tr>
<tr>
<td class="md"></td>
<td class="md">) </td>
<td class="md" colspan="2"><code> [pure virtual]</code></td>
</tr>
</table>
</td>
</tr>
</table>
<table cellspacing="5" cellpadding="0" border="0">
<tr>
<td>
</td>
<td>
<p>
Callback used by <a class="el" href="classUtil_1_1Getopt.html#e0f18bdea00878d0e8a9e83370a0812e">getopt()</a> to pass on each option and its argument (if any).
<p>
Implement this method in a derived class to handle the options as needed. See the manual pages for getopt(3) for further details, in particular, the semantics of optarg and optopt.<p>
<dl compact><dt><b>Parameters:</b></dt><dd>
<table border="0" cellspacing="2" cellpadding="0">
<tr><td valign="top"></td><td valign="top"><em>opt</em> </td><td>Value of the option character as returned by getopt(3). </td></tr>
<tr><td valign="top"></td><td valign="top"><em>optarg</em> </td><td>The corresponding option argument. </td></tr>
<tr><td valign="top"></td><td valign="top"><em>optopt</em> </td><td>The actual option character in case of an unrecognized option or a missing option argument (opt is '?' or ':').</td></tr>
</table>
</dl>
<dl compact><dt><b>Returns:</b></dt><dd>0 if successful, 1 in case of an error. </dd></dl>
<p>
Implemented in <a class="el" href="classParams.html#8d28eab356e60994d9bcf6c9c6ff1cdb">Params</a>, and <a class="el" href="classParams.html#6db679664dff3fb8d1c807aa01c7aa45">Params</a>. </td>
</tr>
</table>
<hr>The documentation for this class was generated from the following files:<ul>
<li><a class="el" href="utils_8hpp.html">utils.hpp</a><li>utils.cpp</ul>
<hr size="1"><address style="align: right;"><small>Generated on Fri Jun 2 23:55:45 2006 for Exiv2 by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
</body>
</html>
|