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
|
<!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>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>incron: appargs.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td style="padding-left: 0.5em;">
<div id="projectname">incron
 <span id="projectnumber">0.5.10</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.7.5.1 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li class="current"><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="files.html"><span>File List</span></a></li>
<li><a href="globals.html"><span>File Members</span></a></li>
</ul>
</div>
<div class="header">
<div class="headertitle">
<div class="title">appargs.h</div> </div>
</div>
<div class="contents">
<a href="appargs_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001
<a name="l00003"></a>00003
<a name="l00023"></a>00023 <span class="preprocessor">#ifndef APPARGS_H_</span>
<a name="l00024"></a>00024 <span class="preprocessor"></span><span class="preprocessor">#define APPARGS_H_</span>
<a name="l00025"></a>00025 <span class="preprocessor"></span>
<a name="l00026"></a>00026 <span class="preprocessor">#include <cstring></span>
<a name="l00027"></a>00027 <span class="preprocessor">#include <map></span>
<a name="l00028"></a>00028 <span class="preprocessor">#include <deque></span>
<a name="l00029"></a>00029
<a name="l00030"></a>00030
<a name="l00031"></a>00031
<a name="l00033"></a><a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915">00033</a> <span class="keyword">typedef</span> <span class="keyword">enum</span>
<a name="l00034"></a>00034 {
<a name="l00035"></a><a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915a1c31909a2b0bc9adb3f629dd23708283">00035</a> <a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915a1c31909a2b0bc9adb3f629dd23708283" title="no value needed">AAT_NO_VALUE</a>,
<a name="l00036"></a><a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915ae9375c7b4472dee83cc87409620716fb">00036</a> <a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915ae9375c7b4472dee83cc87409620716fb" title="optional value">AAT_OPTIONAL_VALUE</a>,
<a name="l00037"></a><a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915aade55a552973ac01419c6b768ad98436">00037</a> <a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915aade55a552973ac01419c6b768ad98436" title="mandatory value">AAT_MANDATORY_VALUE</a>
<a name="l00038"></a>00038 } <a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915" title="Option argument type.">AppArgType_t</a>;
<a name="l00039"></a>00039
<a name="l00040"></a>00040
<a name="l00041"></a><a class="code" href="appargs_8h.html#ae17492b30f7d6cb4900a8fba81385f88">00041</a> <span class="preprocessor">#define APPARGS_NOLIMIT 0x7fffffff ///< value count has no limit</span>
<a name="l00042"></a>00042 <span class="preprocessor"></span>
<a name="l00044"></a><a class="code" href="structAppArgOption__t.html">00044</a> <span class="keyword">typedef</span> <span class="keyword">struct</span>
<a name="l00045"></a>00045 {
<a name="l00046"></a><a class="code" href="structAppArgOption__t.html#adac46478f6aa74c770dbac7f8662b825">00046</a> <a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915" title="Option argument type.">AppArgType_t</a> <a class="code" href="structAppArgOption__t.html#adac46478f6aa74c770dbac7f8662b825" title="argument type">type</a>;
<a name="l00047"></a><a class="code" href="structAppArgOption__t.html#ad7aa21e64ba053701e84bf08b1f16234">00047</a> <span class="keywordtype">bool</span> <a class="code" href="structAppArgOption__t.html#ad7aa21e64ba053701e84bf08b1f16234" title="mandatory yes/no">mand</a>;
<a name="l00048"></a><a class="code" href="structAppArgOption__t.html#a5f68151ff4fb08e8dbb2ed35168808a7">00048</a> <span class="keywordtype">bool</span> <a class="code" href="structAppArgOption__t.html#a5f68151ff4fb08e8dbb2ed35168808a7" title="found in argument vector">found</a>;
<a name="l00049"></a><a class="code" href="structAppArgOption__t.html#aa66e5d7dd5f1696cd66bd7149293dde8">00049</a> std::string <a class="code" href="structAppArgOption__t.html#aa66e5d7dd5f1696cd66bd7149293dde8" title="value">val</a>;
<a name="l00050"></a><a class="code" href="structAppArgOption__t.html#a0c92cda0cdbb11e6c3cb14560628aac2">00050</a> <span class="keywordtype">bool</span> <a class="code" href="structAppArgOption__t.html#a0c92cda0cdbb11e6c3cb14560628aac2" title="value is set">hasVal</a>;
<a name="l00051"></a>00051 } <a class="code" href="structAppArgOption__t.html" title="Argument option type.">AppArgOption_t</a>;
<a name="l00052"></a>00052
<a name="l00053"></a>00053
<a name="l00055"></a><a class="code" href="appargs_8h.html#aa051ebe9550c766490a595e2946a1ee7">00055</a> <span class="keyword">typedef</span> std::map<std::string, AppArgOption_t*> <a class="code" href="appargs_8h.html#aa051ebe9550c766490a595e2946a1ee7" title="Mapping from long option name to option data.">AA_LONG_MAP</a>;
<a name="l00056"></a>00056
<a name="l00058"></a><a class="code" href="appargs_8h.html#a3a520fd6ca0fc05ca5789e3a5c879ad6">00058</a> <span class="keyword">typedef</span> std::map<char, AppArgOption_t*> <a class="code" href="appargs_8h.html#a3a520fd6ca0fc05ca5789e3a5c879ad6" title="Mapping from short option name to option data.">AA_SHORT_MAP</a>;
<a name="l00059"></a>00059
<a name="l00061"></a><a class="code" href="appargs_8h.html#a7214da6cf795c2b9a22a763997d674f0">00061</a> <span class="keyword">typedef</span> std::deque<std::string> <a class="code" href="appargs_8h.html#a7214da6cf795c2b9a22a763997d674f0" title="Value list type.">AA_VAL_LIST</a>;
<a name="l00062"></a>00062
<a name="l00063"></a>00063
<a name="l00065"></a>00065
<a name="l00088"></a><a class="code" href="classAppArgs.html">00088</a> <span class="keyword">class </span><a class="code" href="classAppArgs.html" title="Application arguments.">AppArgs</a>
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090 <span class="keyword">public</span>:
<a name="l00092"></a>00092
<a name="l00096"></a>00096 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classAppArgs.html#a5365bfc9a54a0318166cbb003f905dc0" title="Initializes the processor.">Init</a>(<span class="keywordtype">size_t</span> valMinCnt = 0, <span class="keywordtype">size_t</span> valMaxCnt = <a class="code" href="appargs_8h.html#ae17492b30f7d6cb4900a8fba81385f88" title="value count has no limit">APPARGS_NOLIMIT</a>);
<a name="l00097"></a>00097
<a name="l00099"></a>00099
<a name="l00103"></a>00103 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classAppArgs.html#a42655a3eff85509c7f2ce1fcba0b1f31" title="Releases resources allocated by the processor.">Destroy</a>();
<a name="l00104"></a>00104
<a name="l00106"></a>00106
<a name="l00112"></a>00112 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classAppArgs.html#a0f2ab8497fa8c6aaf7b9faf0c75dbcff" title="Parses arguments and builds the appropriate structure.">Parse</a>(<span class="keywordtype">int</span> argc, <span class="keyword">const</span> <span class="keywordtype">char</span>* <span class="keyword">const</span>* argv);
<a name="l00113"></a>00113
<a name="l00115"></a>00115
<a name="l00124"></a>00124 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#aa4a29548cfffac89df731267b79d1d49" title="Checks whether the arguments have valid form.">IsValid</a>();
<a name="l00125"></a>00125
<a name="l00127"></a>00127
<a name="l00131"></a>00131 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#af3336e77fc109c12def19406787d7126" title="Checks whether an option exists.">ExistsOption</a>(<span class="keyword">const</span> std::string& rArg);
<a name="l00132"></a>00132
<a name="l00134"></a>00134
<a name="l00139"></a>00139 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#a274f64c50b8cbbe3094dde621ef3b11d" title="Extracts an option value.">GetOption</a>(<span class="keyword">const</span> std::string& rArg, std::string& rVal);
<a name="l00140"></a>00140
<a name="l00142"></a>00142
<a name="l00153"></a>00153 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#ab19a36ff2e25a416415309b8224bbab1" title="Adds an option.">AddOption</a>(<span class="keyword">const</span> std::string& rName, <span class="keywordtype">char</span> cShort, <a class="code" href="appargs_8h.html#a5704dc04528b6c626472cea01c9a7915" title="Option argument type.">AppArgType_t</a> type, <span class="keywordtype">bool</span> fMandatory);
<a name="l00154"></a>00154
<a name="l00156"></a>00156
<a name="l00159"></a>00159 <span class="keyword">static</span> <span class="keywordtype">size_t</span> <a class="code" href="classAppArgs.html#a4d6e538d8c08bbecc2a3c8dfab75cde7" title="Returns the count of values.">GetValueCount</a>();
<a name="l00160"></a>00160
<a name="l00162"></a>00162
<a name="l00167"></a>00167 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#a050217dd528c4d6c30dc559ba19bbe3d" title="Extracts a value.">GetValue</a>(<span class="keywordtype">size_t</span> index, std::string& rVal);
<a name="l00168"></a>00168
<a name="l00170"></a>00170
<a name="l00173"></a>00173 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classAppArgs.html#a00d5d4d822c8c1bc792313b51eeeec44" title="Dumps information about options and value to STDERR.">Dump</a>();
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <span class="keyword">protected</span>:
<a name="l00177"></a>00177
<a name="l00181"></a>00181 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#a2471f11b0d74e3a427f1d9c02c9d6494" title="Checks whether a string is an option.">IsOption</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* pchStr);
<a name="l00182"></a>00182
<a name="l00184"></a>00184
<a name="l00191"></a>00191 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#a7058134b8e90e9ee7ee9c23d98a03708" title="Checks whether a string is a long option.">IsLongOption</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* pchStr);
<a name="l00192"></a>00192
<a name="l00194"></a>00194
<a name="l00201"></a>00201 <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classAppArgs.html#a1b3384fa201fb04948776c4e79cf633c" title="Parses a string and attempts to treat it as a long option.">ParseLong</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* pchStr, std::string& rName, std::string& rVal, <span class="keywordtype">bool</span>& rfHasVal);
<a name="l00202"></a>00202
<a name="l00204"></a>00204
<a name="l00212"></a>00212 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classAppArgs.html#a9d503ca65c0025cf6d04a00cb2e8b12e" title="Parses a string and attempts to treat it as a short option.">ParseShort</a>(<span class="keyword">const</span> <span class="keywordtype">char</span>* pchStr, <span class="keywordtype">char</span>& rcName, std::string& rVal, <span class="keywordtype">bool</span>& rfHasVal);
<a name="l00213"></a>00213
<a name="l00215"></a>00215
<a name="l00220"></a>00220 <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classAppArgs.html#aee73398d0548dd1aaeb1eee8c959a3a5" title="Dumps an option to STDERR.">DumpOption</a>(<span class="keyword">const</span> std::string& rName, <span class="keywordtype">char</span> cShort, <a class="code" href="structAppArgOption__t.html" title="Argument option type.">AppArgOption_t</a>* pOpt);
<a name="l00221"></a>00221
<a name="l00222"></a>00222
<a name="l00223"></a>00223 <span class="keyword">private</span>:
<a name="l00224"></a>00224 <span class="keyword">static</span> <span class="keywordtype">size_t</span> s_minCnt;
<a name="l00225"></a>00225 <span class="keyword">static</span> <span class="keywordtype">size_t</span> s_maxCnt;
<a name="l00226"></a>00226
<a name="l00227"></a>00227 <span class="keyword">static</span> <a class="code" href="appargs_8h.html#aa051ebe9550c766490a595e2946a1ee7" title="Mapping from long option name to option data.">AA_LONG_MAP</a> s_longMap;
<a name="l00228"></a>00228 <span class="keyword">static</span> <a class="code" href="appargs_8h.html#a3a520fd6ca0fc05ca5789e3a5c879ad6" title="Mapping from short option name to option data.">AA_SHORT_MAP</a> s_shortMap;
<a name="l00229"></a>00229 <span class="keyword">static</span> <a class="code" href="appargs_8h.html#a7214da6cf795c2b9a22a763997d674f0" title="Value list type.">AA_VAL_LIST</a> s_valList;
<a name="l00230"></a>00230
<a name="l00231"></a>00231 };
<a name="l00232"></a>00232
<a name="l00233"></a>00233
<a name="l00234"></a>00234 <span class="preprocessor">#endif </span><span class="comment">/*APPARGS_H_*/</span>
</pre></div></div>
</div>
<hr class="footer"/><address class="footer"><small>
Generated by  <a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>
</body>
</html>
|