qcommandline 0.2.0
[qcommandline:qcommandline.git] / doc / html / qcommandline_8h-source.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
3 <title>QCommandLine: /home/iksaif/dev/.priv/QCommandLine/src/qcommandline.h Source File</title>
4 <link href="tabs.css" rel="stylesheet" type="text/css">
5 <link href="doxygen.css" rel="stylesheet" type="text/css">
6 </head><body>
7 <!-- Generated by Doxygen 1.5.8 -->
8 <script type="text/javascript">
9 <!--
10 function changeDisplayState (e){
11   var num=this.id.replace(/[^[0-9]/g,'');
12   var button=this.firstChild;
13   var sectionDiv=document.getElementById('dynsection'+num);
14   if (sectionDiv.style.display=='none'||sectionDiv.style.display==''){
15     sectionDiv.style.display='block';
16     button.src='open.gif';
17   }else{
18     sectionDiv.style.display='none';
19     button.src='closed.gif';
20   }
21 }
22 function initDynSections(){
23   var divs=document.getElementsByTagName('div');
24   var sectionCounter=1;
25   for(var i=0;i<divs.length-1;i++){
26     if(divs[i].className=='dynheader'&&divs[i+1].className=='dynsection'){
27       var header=divs[i];
28       var section=divs[i+1];
29       var button=header.firstChild;
30       if (button!='IMG'){
31         divs[i].insertBefore(document.createTextNode(' '),divs[i].firstChild);
32         button=document.createElement('img');
33         divs[i].insertBefore(button,divs[i].firstChild);
34       }
35       header.style.cursor='pointer';
36       header.onclick=changeDisplayState;
37       header.id='dynheader'+sectionCounter;
38       button.src='closed.gif';
39       section.id='dynsection'+sectionCounter;
40       section.style.display='none';
41       section.style.marginLeft='14px';
42       sectionCounter++;
43     }
44   }
45 }
46 window.onload = initDynSections;
47 -->
48 </script>
49 <div class="navigation" id="top">
50   <div class="tabs">
51     <ul>
52       <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
53       <li><a href="annotated.html"><span>Classes</span></a></li>
54       <li class="current"><a href="files.html"><span>Files</span></a></li>
55     </ul>
56   </div>
57   <div class="tabs">
58     <ul>
59       <li><a href="files.html"><span>File&nbsp;List</span></a></li>
60     </ul>
61   </div>
62 <h1>/home/iksaif/dev/.priv/QCommandLine/src/qcommandline.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef QCOMMAND_LINE_H</span>
63 <a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor"># define QCOMMAND_LINE_H</span>
64 <a name="l00003"></a>00003 <span class="preprocessor"></span>
65 <a name="l00004"></a>00004 <span class="preprocessor">#include &lt;QtCore/QObject&gt;</span>
66 <a name="l00005"></a>00005 <span class="preprocessor">#include &lt;QtCore/QList&gt;</span>
67 <a name="l00006"></a>00006 <span class="preprocessor">#include &lt;QtCore/QStringList&gt;</span>
68 <a name="l00007"></a>00007 
69 <a name="l00008"></a>00008 <span class="preprocessor">#ifndef QCOMMANDLINE_EXPORT</span>
70 <a name="l00009"></a>00009 <span class="preprocessor"></span><span class="preprocessor"># if defined(QCOMMANDLINE_MAKEDLL)</span>
71 <a name="l00010"></a>00010 <span class="preprocessor"></span>   <span class="comment">/* We are building this library */</span>
72 <a name="l00011"></a>00011 <span class="preprocessor">#  define QCOMMANDLINE_EXPORT Q_DECL_EXPORT</span>
73 <a name="l00012"></a>00012 <span class="preprocessor"></span><span class="preprocessor"># else</span>
74 <a name="l00013"></a>00013 <span class="preprocessor"></span>   <span class="comment">/* We are using this library */</span>
75 <a name="l00014"></a>00014 <span class="preprocessor">#  define QCOMMANDLINE_EXPORT Q_DECL_IMPORT</span>
76 <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor"># endif</span>
77 <a name="l00016"></a>00016 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
78 <a name="l00017"></a>00017 <span class="preprocessor"></span>
79 <a name="l00018"></a>00018 <span class="keyword">class </span>QCoreApplication;
80 <a name="l00019"></a>00019 
81 <a name="l00020"></a>00020 <span class="keyword">struct </span><a class="code" href="struct_q_command_line_config_entry.html" title="Configuration entry structure.">QCommandLineConfigEntry</a>;
82 <a name="l00021"></a>00021 <span class="keyword">typedef</span> QList&lt; QCommandLineConfigEntry &gt; QCommandLineConfig;
83 <a name="l00022"></a>00022 
84 <a name="l00023"></a>00023 <span class="keyword">struct </span>QCommandLinePrivate {
85 <a name="l00024"></a>00024     <span class="keywordtype">bool</span> version;
86 <a name="l00025"></a>00025     <span class="keywordtype">bool</span> help;
87 <a name="l00026"></a>00026     QStringList args;
88 <a name="l00027"></a>00027     QCommandLineConfig config;
89 <a name="l00028"></a>00028 };
90 <a name="l00029"></a>00029 
91 <a name="l00033"></a>00033 <span class="preprocessor">#define QCOMMANDLINE_CONFIG_ENTRY_END      \</span>
92 <a name="l00034"></a>00034 <span class="preprocessor">    { QCommandLine::None, '\0', NULL, NULL, QCommandLine::Default }</span>
93 <a name="l00035"></a>00035 <span class="preprocessor"></span>
94 <a name="l00039"></a><a class="code" href="class_q_command_line.html">00039</a> <span class="keyword">class </span>QCOMMANDLINE_EXPORT <a class="code" href="class_q_command_line.html" title="Main class used to convert parse command line.">QCommandLine</a> : <span class="keyword">public</span> QObject
95 <a name="l00040"></a>00040 {
96 <a name="l00041"></a>00041   Q_OBJECT
97 <a name="l00042"></a>00042 <span class="keyword">public</span>:
98 <a name="l00046"></a><a class="code" href="class_q_command_line.html#b7800ba521ac8bc5aa3159d2c5843d1c">00046</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span> {
99 <a name="l00047"></a><a class="code" href="class_q_command_line.html#b7800ba521ac8bc5aa3159d2c5843d1ca79ded71152b893b172df56a4eaf0dc8">00047</a>         None = 0, 
100 <a name="l00048"></a><a class="code" href="class_q_command_line.html#b7800ba521ac8bc5aa3159d2c5843d1c205c5d127bf40b2ee50043e82ba40b3a">00048</a>         Switch, 
101 <a name="l00049"></a><a class="code" href="class_q_command_line.html#b7800ba521ac8bc5aa3159d2c5843d1c8b14ef103bb24ae3ff9ef312709968a0">00049</a>         Option, 
102 <a name="l00050"></a><a class="code" href="class_q_command_line.html#b7800ba521ac8bc5aa3159d2c5843d1ce94f6d953303e1ef30b772982ae898bd">00050</a>         Param 
103 <a name="l00051"></a>00051     } Type;
104 <a name="l00052"></a>00052 
105 <a name="l00056"></a><a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf">00056</a>     <span class="keyword">typedef</span> <span class="keyword">enum</span> {
106 <a name="l00057"></a><a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf7f2caac9ce4ac91db8feb0d23bdb0b56">00057</a>         Default = 0, 
107 <a name="l00058"></a><a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bfd13780f6d768c16ed235f68c751fc844">00058</a>         Mandatory = 0x01, 
108 <a name="l00059"></a><a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf3cb70be5d114404d065112110ebc51e5">00059</a>         Optional = 0x02, 
109 <a name="l00060"></a><a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf25c45f4e4843deac514dd547b96d2258">00060</a>         Multiple = 0x04, 
110 <a name="l00061"></a>00061         MandatoryMultiple = Mandatory|Multiple,
111 <a name="l00062"></a>00062         OptionalMultiple = Optional|Multiple,
112 <a name="l00063"></a>00063     } Flags;
113 <a name="l00064"></a>00064 
114 <a name="l00069"></a>00069     <a class="code" href="class_q_command_line.html" title="Main class used to convert parse command line.">QCommandLine</a>(QObject * parent = 0);
115 <a name="l00070"></a>00070 
116 <a name="l00078"></a>00078     <a class="code" href="class_q_command_line.html" title="Main class used to convert parse command line.">QCommandLine</a>(<span class="keyword">const</span> QCoreApplication &amp; app,
117 <a name="l00079"></a>00079                  <span class="keyword">const</span> QCommandLineConfig &amp; config = QCommandLineConfig(),
118 <a name="l00080"></a>00080                  QObject * parent = 0);
119 <a name="l00081"></a>00081 
120 <a name="l00091"></a>00091     <a class="code" href="class_q_command_line.html" title="Main class used to convert parse command line.">QCommandLine</a>(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[],
121 <a name="l00092"></a>00092                  <span class="keyword">const</span> QCommandLineConfig &amp; config = QCommandLineConfig(),
122 <a name="l00093"></a>00093                  QObject * parent = 0);
123 <a name="l00094"></a>00094 
124 <a name="l00103"></a>00103     <a class="code" href="class_q_command_line.html" title="Main class used to convert parse command line.">QCommandLine</a>(<span class="keyword">const</span> QStringList args,
125 <a name="l00104"></a>00104                  <span class="keyword">const</span> QCommandLineConfig &amp; config = QCommandLineConfig(),
126 <a name="l00105"></a>00105                  QObject * parent = 0);
127 <a name="l00106"></a>00106 
128 <a name="l00110"></a>00110    ~<a class="code" href="class_q_command_line.html" title="Main class used to convert parse command line.">QCommandLine</a>();
129 <a name="l00111"></a>00111 
130 <a name="l00117"></a>00117     <span class="keywordtype">void</span> setConfig(<span class="keyword">const</span> QCommandLineConfig &amp; config);
131 <a name="l00118"></a>00118 
132 <a name="l00124"></a>00124     <span class="keywordtype">void</span> setConfig(<span class="keyword">const</span> <a class="code" href="struct_q_command_line_config_entry.html" title="Configuration entry structure.">QCommandLineConfigEntry</a> config[]);
133 <a name="l00125"></a>00125 
134 <a name="l00131"></a>00131     QCommandLineConfig config();
135 <a name="l00132"></a>00132 
136 <a name="l00139"></a>00139     <span class="keywordtype">void</span> setArguments(<span class="keywordtype">int</span> argc, <span class="keywordtype">char</span> *argv[]);
137 <a name="l00140"></a>00140 
138 <a name="l00146"></a>00146     <span class="keywordtype">void</span> setArguments(QStringList args);
139 <a name="l00147"></a>00147 
140 <a name="l00153"></a>00153     QStringList arguments();
141 <a name="l00154"></a>00154 
142 <a name="l00160"></a>00160     <span class="keywordtype">void</span> enableHelp(<span class="keywordtype">bool</span> enable);
143 <a name="l00161"></a>00161 
144 <a name="l00167"></a>00167     <span class="keywordtype">bool</span> helpEnabled();
145 <a name="l00168"></a>00168 
146 <a name="l00174"></a>00174     <span class="keywordtype">void</span> enableVersion(<span class="keywordtype">bool</span> enable);
147 <a name="l00175"></a>00175 
148 <a name="l00181"></a>00181     <span class="keywordtype">bool</span> versionEnabled();
149 <a name="l00182"></a>00182 
150 <a name="l00189"></a>00189     <span class="keywordtype">bool</span> parse();
151 <a name="l00190"></a>00190 
152 <a name="l00200"></a>00200     <span class="keywordtype">void</span> addOption(<span class="keyword">const</span> QChar &amp; shortName,
153 <a name="l00201"></a>00201                    <span class="keyword">const</span> QString &amp; longName = QString(),
154 <a name="l00202"></a>00202                    <span class="keyword">const</span> QString &amp; descr = QString(),
155 <a name="l00203"></a>00203                    <a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf">QCommandLine::Flags</a> flags = <a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf3cb70be5d114404d065112110ebc51e5">QCommandLine::Optional</a>);
156 <a name="l00204"></a>00204 
157 <a name="l00214"></a>00214     <span class="keywordtype">void</span> addSwitch(<span class="keyword">const</span> QChar &amp; shortName,
158 <a name="l00215"></a>00215                    <span class="keyword">const</span> QString &amp; longName = QString(),
159 <a name="l00216"></a>00216                    <span class="keyword">const</span> QString &amp; descr = QString(),
160 <a name="l00217"></a>00217                    <a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf">QCommandLine::Flags</a> flags = <a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf3cb70be5d114404d065112110ebc51e5">QCommandLine::Optional</a>);
161 <a name="l00218"></a>00218 
162 <a name="l00227"></a>00227     <span class="keywordtype">void</span> addParam(<span class="keyword">const</span> QString &amp; name,
163 <a name="l00228"></a>00228                   <span class="keyword">const</span> QString &amp; descr = QString(),
164 <a name="l00229"></a>00229                   <a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf">QCommandLine::Flags</a> flags = <a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf3cb70be5d114404d065112110ebc51e5">QCommandLine::Optional</a>);
165 <a name="l00230"></a>00230 
166 <a name="l00237"></a>00237     <span class="keywordtype">void</span> removeOption(<span class="keyword">const</span> QString &amp; name);
167 <a name="l00238"></a>00238 
168 <a name="l00245"></a>00245     <span class="keywordtype">void</span> removeSwitch(<span class="keyword">const</span> QString &amp; name);
169 <a name="l00246"></a>00246 
170 <a name="l00253"></a>00253     <span class="keywordtype">void</span> removeParam(<span class="keyword">const</span> QString &amp; name);
171 <a name="l00254"></a>00254 
172 <a name="l00260"></a>00260     QString help(<span class="keywordtype">bool</span> logo = <span class="keyword">true</span>);
173 <a name="l00261"></a>00261 
174 <a name="l00266"></a>00266     QString version();
175 <a name="l00267"></a>00267 
176 <a name="l00274"></a>00274     <span class="keywordtype">void</span> showHelp(<span class="keywordtype">bool</span> exit = <span class="keyword">true</span>, <span class="keywordtype">int</span> returnCode = 0);
177 <a name="l00275"></a>00275 
178 <a name="l00282"></a>00282     <span class="keywordtype">void</span> showVersion(<span class="keywordtype">bool</span> exit = <span class="keyword">true</span>, <span class="keywordtype">int</span> returnCode = 0);
179 <a name="l00283"></a>00283 
180 <a name="l00287"></a><a class="code" href="class_q_command_line.html#5576b07bb95326a0edf219b972a39aa6">00287</a>     <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="struct_q_command_line_config_entry.html" title="Configuration entry structure.">QCommandLineConfigEntry</a> helpEntry;
181 <a name="l00288"></a>00288 
182 <a name="l00292"></a><a class="code" href="class_q_command_line.html#4bb2308ed7ce991912c95508f21e5350">00292</a>     <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="struct_q_command_line_config_entry.html" title="Configuration entry structure.">QCommandLineConfigEntry</a> versionEntry;
183 <a name="l00293"></a>00293 
184 <a name="l00294"></a>00294 signals:
185 <a name="l00301"></a>00301     <span class="keywordtype">void</span> switchFound(<span class="keyword">const</span> QString &amp; name);
186 <a name="l00302"></a>00302 
187 <a name="l00310"></a>00310     <span class="keywordtype">void</span> optionFound(<span class="keyword">const</span> QString &amp; name, <span class="keyword">const</span> QVariant &amp; value);
188 <a name="l00311"></a>00311 
189 <a name="l00319"></a>00319     <span class="keywordtype">void</span> paramFound(<span class="keyword">const</span> QString &amp; name, <span class="keyword">const</span> QVariant &amp; value);
190 <a name="l00320"></a>00320 
191 <a name="l00326"></a>00326     <span class="keywordtype">void</span> parseError(<span class="keyword">const</span> QString &amp; error);
192 <a name="l00327"></a>00327 <span class="keyword">private</span>:
193 <a name="l00328"></a>00328     QCommandLinePrivate *d;
194 <a name="l00329"></a>00329     Q_DECLARE_PRIVATE(<a class="code" href="class_q_command_line.html" title="Main class used to convert parse command line.">QCommandLine</a>);
195 <a name="l00330"></a>00330 };
196 <a name="l00331"></a>00331 
197 <a name="l00335"></a><a class="code" href="struct_q_command_line_config_entry.html">00335</a> <span class="keyword">struct </span><a class="code" href="struct_q_command_line_config_entry.html" title="Configuration entry structure.">QCommandLineConfigEntry</a> {
198 <a name="l00339"></a><a class="code" href="struct_q_command_line_config_entry.html#a151d2ee04de721f5d7e45050c8102df">00339</a>     <a class="code" href="class_q_command_line.html#b7800ba521ac8bc5aa3159d2c5843d1c">QCommandLine::Type</a> <a class="code" href="struct_q_command_line_config_entry.html#a151d2ee04de721f5d7e45050c8102df">type</a>;
199 <a name="l00343"></a><a class="code" href="struct_q_command_line_config_entry.html#9afa720ba159042097566708fc566b50">00343</a>     QChar shortName;
200 <a name="l00347"></a><a class="code" href="struct_q_command_line_config_entry.html#39ed71444b17d75fc0cd8223d36267e6">00347</a>     QString <a class="code" href="struct_q_command_line_config_entry.html#39ed71444b17d75fc0cd8223d36267e6">longName</a>;
201 <a name="l00351"></a><a class="code" href="struct_q_command_line_config_entry.html#d6ea57728ea781f6359a30a85ac5887c">00351</a>     QString <a class="code" href="struct_q_command_line_config_entry.html#d6ea57728ea781f6359a30a85ac5887c">descr</a>;
202 <a name="l00355"></a><a class="code" href="struct_q_command_line_config_entry.html#2f6ed82d6104ec17009c04f53ef870d6">00355</a>     <a class="code" href="class_q_command_line.html#a6d7f44346a07b8e9bbc19861d7679bf">QCommandLine::Flags</a> <a class="code" href="struct_q_command_line_config_entry.html#2f6ed82d6104ec17009c04f53ef870d6">flags</a>;
203 <a name="l00356"></a>00356 };
204 <a name="l00357"></a>00357 
205 <a name="l00358"></a>00358 <span class="preprocessor">#endif</span>
206 </pre></div></div>
207 <hr size="1"><address style="text-align: right;"><small>Generated on Thu Oct 21 15:13:57 2010 for QCommandLine by&nbsp;
208 <a href="http://www.doxygen.org/index.html">
209 <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
210 </body>
211 </html>