<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Exiv2: Util::Getopt Class Reference</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <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 class="current"><a href="annotated.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> <li> <form action="search.php" method="get"> <table cellspacing="0" cellpadding="0" border="0"> <tr> <td><label> <u>S</u>earch for </label></td> <td><input type="text" name="query" value="" size="20" accesskey="s"/></td> </tr> </table> </form> </li> </ul> </div> <div class="tabs"> <ul> <li><a href="annotated.html"><span>Class List</span></a></li> <li><a href="classes.html"><span>Class Index</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="navpath"><a class="el" href="namespaceUtil.html">Util</a>::<a class="el" href="classUtil_1_1Getopt.html">Getopt</a> </div> </div> <div class="contents"> <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> <div class="dynheader"> Inheritance diagram for Util::Getopt:</div> <div class="dynsection"> <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 shape="rect" id="node3" href="classParams.html" title="Implements the command line handling for the program." alt="" coords="36,80,116,107"></map> <center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div> <div class="dynheader"> Collaboration diagram for Util::Getopt:</div> <div class="dynsection"> <p><center><img src="classUtil_1_1Getopt__coll__graph.png" border="0" usemap="#Util_1_1Getopt__coll__map" alt="Collaboration graph"></center> <map name="Util_1_1Getopt__coll__map"> <area shape="rect" id="node2" title="STL class." alt="" coords="65,83,196,109"><area shape="rect" id="node4" title="STL class." alt="" coords="5,5,256,32"></map> <center><font size="2">[<a href="graph_legend.html">legend</a>]</font></center></div> <p> <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" title="Parse command line arguments.">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#2e9ebfcdeadf83d201002059ec58d908">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" title="Parse command line arguments.">getopt()</a> to pass on each non-option parameter found on the command line. <a href="#2e9ebfcdeadf83d201002059ec58d908"></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" title="Callback used by getopt() to pass on each option and its argument (if any).">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" title="Callback used by getopt() to pass on each option and its argument (if any).">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#2e9ebfcdeadf83d201002059ec58d908" title="Callback used by getopt() to pass on each non-option parameter found on the command...">nonoption()</a> method. <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)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">int Util::Getopt::getopt </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"> <em>argc</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">char *const </td> <td class="paramname"> <em>argv</em>[], </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>optstring</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td></td> </tr> </table> </div> <div class="memdoc"> <p> Parse command line arguments. <p> Parses the command line arguments. Calls <a class="el" href="classUtil_1_1Getopt.html#27e365f1f9710ce80f4b534686d7e887" title="Callback used by getopt() to pass on each option and its argument (if any).">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#2e9ebfcdeadf83d201002059ec58d908" title="Callback used by getopt() to pass on each non-option parameter found on the command...">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 class="return" 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" title="Callback used by getopt() to pass on each option and its argument (if any).">option()</a> and <a class="el" href="classUtil_1_1Getopt.html#2e9ebfcdeadf83d201002059ec58d908" title="Callback used by getopt() to pass on each non-option parameter found on the command...">nonoption()</a>). </dd></dl> </div> </div><p> <a class="anchor" name="2e9ebfcdeadf83d201002059ec58d908"></a><!-- doxytag: member="Util::Getopt::nonoption" ref="2e9ebfcdeadf83d201002059ec58d908" args="(const std::string &argv)" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual int Util::Getopt::nonoption </td> <td>(</td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>argv</em> </td> <td> ) </td> <td><code> [virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Callback used by <a class="el" href="classUtil_1_1Getopt.html#e0f18bdea00878d0e8a9e83370a0812e" title="Parse command line arguments.">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 class="return" 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>.</p> </div> </div><p> <a class="anchor" name="27e365f1f9710ce80f4b534686d7e887"></a><!-- doxytag: member="Util::Getopt::option" ref="27e365f1f9710ce80f4b534686d7e887" args="(int opt, const std::string &optarg, int optopt)=0" --> <div class="memitem"> <div class="memproto"> <table class="memname"> <tr> <td class="memname">virtual int Util::Getopt::option </td> <td>(</td> <td class="paramtype">int </td> <td class="paramname"> <em>opt</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const std::string & </td> <td class="paramname"> <em>optarg</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </td> <td class="paramname"> <em>optopt</em></td><td> </td> </tr> <tr> <td></td> <td>)</td> <td></td><td></td><td><code> [pure virtual]</code></td> </tr> </table> </div> <div class="memdoc"> <p> Callback used by <a class="el" href="classUtil_1_1Getopt.html#e0f18bdea00878d0e8a9e83370a0812e" title="Parse command line arguments.">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 class="return" 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>.</p> </div> </div><p> <hr>The documentation for this class was generated from the following file:<ul> <li><a class="el" href="utils_8hpp.html">utils.hpp</a></ul> </div> <hr size="1"><address style="text-align: right;"><small>Generated on Thu Jun 25 15:18:18 2009 for Exiv2 by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> </body> </html>