]>
Commit | Line | Data |
---|---|---|
f6bcfd97 BP |
1 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
2 | %% Name: cmdlpars.tex | |
3 | %% Purpose: wxCmdLineParser documentation | |
4 | %% Author: Vadim Zeitlin | |
5 | %% Modified by: | |
6 | %% Created: 27.03.00 | |
7 | %% RCS-ID: $Id$ | |
8 | %% Copyright: (c) Vadim Zeitlin | |
8795498c | 9 | %% License: wxWindows license |
f6bcfd97 BP |
10 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
11 | ||
12 | \section{\class{wxCmdLineParser}}\label{wxcmdlineparser} | |
13 | ||
dceb1c09 | 14 | wxCmdLineParser is a class for parsing the command line. |
f6bcfd97 BP |
15 | |
16 | It has the following features: | |
5e0e6ceb JS |
17 | |
18 | \begin{enumerate}\itemsep=0pt | |
f6bcfd97 BP |
19 | \item distinguishes options, switches and parameters; allows option grouping |
20 | \item allows both short and long options | |
21 | \item automatically generates the usage message from the command line description | |
22 | \item does type checks on the options values (number, date, $\ldots$). | |
23 | \end{enumerate} | |
24 | ||
25 | To use it you should follow these steps: | |
5e0e6ceb JS |
26 | |
27 | \begin{enumerate}\itemsep=0pt | |
f6bcfd97 BP |
28 | \item \helpref{construct}{wxcmdlineparserconstruction} an object of this class |
29 | giving it the command line to parse and optionally its description or use | |
30 | {\tt AddXXX()} functions later | |
31 | \item call {\tt Parse()} | |
32 | \item use {\tt Found()} to retrieve the results | |
33 | \end{enumerate} | |
34 | ||
35 | In the documentation below the following terminology is used: | |
36 | ||
37 | \begin{twocollist}\itemsep=0pt | |
38 | \twocolitem{switch}{This is a boolean option which can be given or not, but | |
39 | which doesn't have any value. We use the word switch to distinguish such boolean | |
40 | options from more generic options like those described below. For example, | |
41 | {\tt -v} might be a switch meaning "enable verbose mode".} | |
42 | \twocolitem{option}{Option for us here is something which comes with a value 0 | |
43 | unlike a switch. For example, {\tt -o:filename} might be an option which allows | |
44 | to specify the name of the output file.} | |
45 | \twocolitem{parameter}{This is a required program argument.} | |
46 | \end{twocollist} | |
47 | ||
48 | \wxheading{Derived from} | |
49 | ||
50 | No base class | |
51 | ||
52 | \wxheading{Include files} | |
53 | ||
54 | <wx/cmdline.h> | |
55 | ||
a7af285d VZ |
56 | \wxheading{Library} |
57 | ||
58 | \helpref{wxBase}{librarieslist} | |
59 | ||
f6bcfd97 BP |
60 | \wxheading{Constants} |
61 | ||
62 | The structure wxCmdLineEntryDesc is used to describe the one command | |
63 | line switch, option or parameter. An array of such structures should be passed | |
64 | to \helpref{SetDesc()}{wxcmdlineparsersetdesc}. Also, the meanings of parameters | |
65 | of the {\tt AddXXX()} functions are the same as of the corresponding fields in | |
66 | this structure: | |
67 | ||
68 | \begin{verbatim} | |
69 | struct wxCmdLineEntryDesc | |
70 | { | |
71 | wxCmdLineEntryType kind; | |
42599b71 VZ |
72 | wxString shortName; |
73 | wxString longName; | |
a0fef35d | 74 | wxString description; |
f6bcfd97 BP |
75 | wxCmdLineParamType type; |
76 | int flags; | |
77 | }; | |
78 | \end{verbatim} | |
79 | ||
80 | The type of a command line entity is in the {\tt kind} field and may be one of | |
81 | the following constants: | |
5e0e6ceb JS |
82 | |
83 | {\small% | |
84 | \begin{verbatim} | |
f6bcfd97 BP |
85 | enum wxCmdLineEntryType |
86 | { | |
a66abda9 GT |
87 | wxCMD_LINE_SWITCH, |
88 | wxCMD_LINE_OPTION, | |
89 | wxCMD_LINE_PARAM, | |
90 | wxCMD_LINE_NONE // use this to terminate the list | |
f6bcfd97 | 91 | } |
c57e060d JS |
92 | \end{verbatim} |
93 | } | |
f6bcfd97 BP |
94 | |
95 | The field {\tt shortName} is the usual, short, name of the switch or the option. | |
42599b71 | 96 | {\tt longName} is the corresponding long name or empty if the option has no long |
f6bcfd97 BP |
97 | name. Both of these fields are unused for the parameters. Both the short and |
98 | long option names can contain only letters, digits and the underscores. | |
99 | ||
100 | {\tt description} is used by the \helpref{Usage()}{wxcmdlineparserusage} method | |
101 | to construct a help message explaining the syntax of the program. | |
102 | ||
103 | The possible values of {\tt type} which specifies the type of the value accepted | |
104 | by an option or parameter are: | |
5e0e6ceb JS |
105 | |
106 | {\small% | |
107 | \begin{verbatim} | |
f6bcfd97 BP |
108 | enum wxCmdLineParamType |
109 | { | |
a66abda9 GT |
110 | wxCMD_LINE_VAL_STRING, // default |
111 | wxCMD_LINE_VAL_NUMBER, | |
112 | wxCMD_LINE_VAL_DATE, | |
113 | wxCMD_LINE_VAL_NONE | |
f6bcfd97 | 114 | } |
c57e060d JS |
115 | \end{verbatim} |
116 | } | |
f6bcfd97 BP |
117 | |
118 | Finally, the {\tt flags} field is a combination of the following bit masks: | |
5e0e6ceb JS |
119 | |
120 | {\small% | |
121 | \begin{verbatim} | |
f6bcfd97 BP |
122 | enum |
123 | { | |
a66abda9 GT |
124 | wxCMD_LINE_OPTION_MANDATORY = 0x01, // this option must be given |
125 | wxCMD_LINE_PARAM_OPTIONAL = 0x02, // the parameter may be omitted | |
126 | wxCMD_LINE_PARAM_MULTIPLE = 0x04, // the parameter may be repeated | |
127 | wxCMD_LINE_OPTION_HELP = 0x08, // this option is a help request | |
128 | wxCMD_LINE_NEEDS_SEPARATOR = 0x10, // must have sep before the value | |
f6bcfd97 | 129 | } |
c57e060d JS |
130 | \end{verbatim} |
131 | } | |
f6bcfd97 BP |
132 | |
133 | Notice that by default (i.e. if flags are just $0$), options are optional (sic) | |
134 | and each call to \helpref{AddParam()}{wxcmdlineparseraddparam} allows one more | |
135 | parameter - this may be changed by giving non-default flags to it, i.e. use | |
136 | {\tt wxCMD\_LINE\_OPTION\_MANDATORY} to require that the option is given and | |
137 | {\tt wxCMD\_LINE\_PARAM\_OPTIONAL} to make a parameter optional. Also, | |
138 | {\tt wxCMD\_LINE\_PARAM\_MULTIPLE} may be specified if the programs accepts a | |
139 | variable number of parameters - but it only can be given for the last parameter | |
140 | in the command line description. If you use this flag, you will probably need to | |
141 | use \helpref{GetParamCount}{wxcmdlineparsergetparamcount} to retrieve the number | |
142 | of parameters effectively specified after calling | |
143 | \helpref{Parse}{wxcmdlineparserparse}. | |
144 | ||
145 | The last flag {\tt wxCMD\_LINE\_NEEDS\_SEPARATOR} can be specified to require a | |
146 | separator (either a colon, an equal sign or white space) between the option | |
147 | name and its value. By default, no separator is required. | |
148 | ||
149 | \wxheading{See also} | |
150 | ||
151 | \helpref{wxApp::argc}{wxappargc} and \helpref{wxApp::argv}{wxappargv}\\ | |
152 | console sample | |
153 | ||
154 | %%%%%%%%%%%%% Methods by group %%%%%%%%%%%%% | |
155 | \latexignore{\rtfignore{\wxheading{Function groups}}} | |
156 | ||
ff1ce997 | 157 | |
f6bcfd97 BP |
158 | \membersection{Construction}\label{wxcmdlineparserconstruction} |
159 | ||
160 | Before \helpref{Parse}{wxcmdlineparserparse} can be called, the command line | |
161 | parser object must have the command line to parse and also the rules saying | |
162 | which switches, options and parameters are valid - this is called command line | |
163 | description in what follows. | |
164 | ||
165 | You have complete freedom of choice as to when specify the required information, | |
166 | the only restriction is that it must be done before calling | |
167 | \helpref{Parse}{wxcmdlineparserparse}. | |
168 | ||
169 | To specify the command line to parse you may use either one of constructors | |
a9c95884 VZ |
170 | accepting it (\tt{wxCmdLineParser(argc, argv)} or \tt{wxCmdLineParser(const wxString&)} usually) |
171 | or, if you use the default constructor, you can do it later by calling | |
172 | \helpref{SetCmdLine}{wxcmdlineparsersetcmdline}. | |
f6bcfd97 BP |
173 | |
174 | The same holds for command line description: it can be specified either in | |
659f4d76 VZ |
175 | the constructor (\helpref{without\ command\ line}{wxcmdlineparserwxcmdlineparser} or |
176 | \helpref{together\ with\ it}{wxcmdlineparserwxcmdlineparserdescargc}) or | |
f6bcfd97 BP |
177 | constructed later using either \helpref{SetDesc}{wxcmdlineparsersetdesc} or |
178 | combination of \helpref{AddSwitch}{wxcmdlineparseraddswitch}, | |
179 | \helpref{AddOption}{wxcmdlineparseraddoption} and | |
180 | \helpref{AddParam}{wxcmdlineparseraddparam} methods. | |
181 | ||
182 | Using constructors or \helpref{SetDesc}{wxcmdlineparsersetdesc} uses a (usually | |
183 | {\tt const static}) table containing the command line description. If you want | |
2edb0bde | 184 | to decide which options to accept during the run-time, using one of the |
f6bcfd97 BP |
185 | {\tt AddXXX()} functions above might be preferable. |
186 | ||
ff1ce997 | 187 | |
f6bcfd97 BP |
188 | \membersection{Customization}\label{wxcmdlineparsercustomization} |
189 | ||
190 | wxCmdLineParser has several global options which may be changed by the | |
191 | application. All of the functions described in this section should be called | |
192 | before \helpref{Parse}{wxcmdlineparserparse}. | |
193 | ||
194 | First global option is the support for long (also known as GNU-style) options. | |
195 | The long options are the ones which start with two dashes ({\tt "--"}) and look | |
196 | like this: {\tt --verbose}, i.e. they generally are complete words and not some | |
197 | abbreviations of them. As long options are used by more and more applications, | |
198 | they are enabled by default, but may be disabled with | |
199 | \helpref{DisableLongOptions}{wxcmdlineparserdisablelongoptions}. | |
200 | ||
201 | Another global option is the set of characters which may be used to start an | |
202 | option (otherwise, the word on the command line is assumed to be a parameter). | |
203 | Under Unix, {\tt '-'} is always used, but Windows has at least two common | |
204 | choices for this: {\tt '-'} and {\tt '/'}. Some programs also use {\tt '+'}. | |
205 | The default is to use what suits most the current platform, but may be changed | |
206 | with \helpref{SetSwitchChars}{wxcmdlineparsersetswitchchars} method. | |
207 | ||
208 | Finally, \helpref{SetLogo}{wxcmdlineparsersetlogo} can be used to show some | |
209 | application-specific text before the explanation given by | |
210 | \helpref{Usage}{wxcmdlineparserusage} function. | |
211 | ||
ff1ce997 | 212 | |
f6bcfd97 BP |
213 | \membersection{Parsing command line}\label{wxcmdlineparserparsing} |
214 | ||
97d59046 | 215 | After the command line description was constructed and the desired options were |
f6bcfd97 BP |
216 | set, you can finally call \helpref{Parse}{wxcmdlineparserparse} method. |
217 | It returns $0$ if the command line was correct and was parsed, $-1$ if the help | |
218 | option was specified (this is a separate case as, normally, the program will | |
219 | terminate after this) or a positive number if there was an error during the | |
220 | command line parsing. | |
221 | ||
222 | In the latter case, the appropriate error message and usage information are | |
fc2171bd | 223 | logged by wxCmdLineParser itself using the standard wxWidgets logging functions. |
f6bcfd97 | 224 | |
ff1ce997 | 225 | |
f6bcfd97 BP |
226 | \membersection{Getting results}\label{wxcmdlineparsergettingresults} |
227 | ||
228 | After calling \helpref{Parse}{wxcmdlineparserparse} (and if it returned $0$), | |
229 | you may access the results of parsing using one of overloaded {\tt Found()} | |
230 | methods. | |
231 | ||
232 | For a simple switch, you will simply call | |
a9c95884 | 233 | \helpref{Found}{wxcmdlineparserfound} to determine if the switch was given |
f6bcfd97 BP |
234 | or not, for an option or a parameter, you will call a version of {\tt Found()} |
235 | which also returns the associated value in the provided variable. All | |
cc81d32f VS |
236 | {\tt Found()} functions return true if the switch or option were found in the |
237 | command line or false if they were not specified. | |
f6bcfd97 BP |
238 | |
239 | %%%%%%%%%%%%% Methods in alphabetic order %%%%%%%%%%%%% | |
240 | \helponly{\insertatlevel{2}{ | |
241 | ||
242 | \wxheading{Members} | |
243 | ||
244 | }} | |
245 | ||
ff1ce997 | 246 | |
809e21b5 | 247 | \membersection{wxCmdLineParser::wxCmdLineParser}\label{wxcmdlineparserwxcmdlineparserctor} |
f6bcfd97 BP |
248 | |
249 | \func{}{wxCmdLineParser}{\void} | |
250 | ||
251 | Default constructor. You must use | |
a9c95884 | 252 | \helpref{SetCmdLine}{wxcmdlineparsersetcmdline} later. |
f6bcfd97 BP |
253 | |
254 | \func{}{wxCmdLineParser}{\param{int }{argc}, \param{char** }{argv}} | |
255 | ||
ff1ce997 VZ |
256 | \func{}{wxCmdLineParser}{\param{int }{argc}, \param{wchar\_t** }{argv}} |
257 | ||
a9c95884 | 258 | Constructors which specify the command line to parse. This is the traditional |
f6bcfd97 BP |
259 | (Unix) command line format. The parameters {\it argc} and {\it argv} have the |
260 | same meaning as for {\tt main()} function. | |
261 | ||
ff1ce997 VZ |
262 | The second overloaded constructor is only available in Unicode build. The |
263 | first one is available in both ANSI and Unicode modes because under some | |
264 | platforms the command line arguments are passed as ASCII strings even to | |
265 | Unicode programs. | |
266 | ||
f6bcfd97 BP |
267 | \func{}{wxCmdLineParser}{\param{const wxString\& }{cmdline}} |
268 | ||
a9c95884 | 269 | Constructor which specify the command line to parse in Windows format. The parameter |
f6bcfd97 BP |
270 | {\it cmdline} has the same meaning as the corresponding parameter of |
271 | {\tt WinMain()}. | |
272 | ||
f6bcfd97 BP |
273 | \func{}{wxCmdLineParser}{\param{const wxCmdLineEntryDesc* }{desc}} |
274 | ||
a9c95884 VZ |
275 | Specifies the \helpref{command line description}{wxcmdlineparsersetdesc} but not the |
276 | command line. You must use \helpref{SetCmdLine}{wxcmdlineparsersetcmdline} later. | |
f6bcfd97 BP |
277 | |
278 | \func{}{wxCmdLineParser}{\param{const wxCmdLineEntryDesc* }{desc}, \param{int }{argc}, \param{char** }{argv}} | |
279 | ||
a9c95884 VZ |
280 | Specifies both the command line (in Unix format) and the |
281 | \helpref{command line description}{wxcmdlineparsersetdesc}. | |
f6bcfd97 BP |
282 | |
283 | \func{}{wxCmdLineParser}{\param{const wxCmdLineEntryDesc* }{desc}, \param{const wxString\& }{cmdline}} | |
284 | ||
a9c95884 VZ |
285 | Specifies both the command line (in Windows format) and the |
286 | \helpref{command line description}{wxcmdlineparsersetdesc}. | |
ff1ce997 | 287 | |
83a2e3c5 VZ |
288 | \membersection{wxCmdLineParser::ConvertStringToArgs}\label{wxcmdlineparserconvertstringtoargs} |
289 | ||
290 | \func{static wxArrayString}{ConvertStringToArgs}{\param{const wxChar }{*cmdline}} | |
291 | ||
292 | Breaks down the string containing the full command line in words. The words are | |
293 | separated by whitespace. The quotes can be used in the input string to quote | |
294 | the white space and the back slashes can be used to quote the quotes. | |
295 | ||
ff1ce997 | 296 | |
a9c95884 | 297 | \membersection{wxCmdLineParser::SetCmdLine}\label{wxcmdlineparsersetcmdline} |
f6bcfd97 BP |
298 | |
299 | \func{void}{SetCmdLine}{\param{int }{argc}, \param{char** }{argv}} | |
300 | ||
ff1ce997 VZ |
301 | \func{void}{SetCmdLine}{\param{int }{argc}, \param{wchar\_t** }{argv}} |
302 | ||
f6bcfd97 | 303 | Set command line to parse after using one of the constructors which don't do it. |
ff1ce997 | 304 | The second overload of this function is only available in Unicode build. |
f6bcfd97 | 305 | |
f6bcfd97 BP |
306 | \func{void}{SetCmdLine}{\param{const wxString\& }{cmdline}} |
307 | ||
308 | Set command line to parse after using one of the constructors which don't do it. | |
309 | ||
f6bcfd97 | 310 | |
ff1ce997 | 311 | |
f6bcfd97 BP |
312 | \membersection{wxCmdLineParser::\destruct{wxCmdLineParser}}\label{wxcmdlineparserdtor} |
313 | ||
314 | \func{}{\destruct{wxCmdLineParser}}{\void} | |
315 | ||
316 | Frees resources allocated by the object. | |
317 | ||
318 | {\bf NB:} destructor is not virtual, don't use this class polymorphically. | |
319 | ||
ff1ce997 | 320 | |
f6bcfd97 BP |
321 | \membersection{wxCmdLineParser::SetSwitchChars}\label{wxcmdlineparsersetswitchchars} |
322 | ||
323 | \func{void}{SetSwitchChars}{\param{const wxString\& }{switchChars}} | |
324 | ||
325 | {\it switchChars} contains all characters with which an option or switch may | |
326 | start. Default is {\tt "-"} for Unix, {\tt "-/"} for Windows. | |
327 | ||
ff1ce997 | 328 | |
f6bcfd97 BP |
329 | \membersection{wxCmdLineParser::EnableLongOptions}\label{wxcmdlineparserenablelongoptions} |
330 | ||
cc81d32f | 331 | \func{void}{EnableLongOptions}{\param{bool }{enable = true}} |
f6bcfd97 BP |
332 | |
333 | Enable or disable support for the long options. | |
334 | ||
335 | As long options are not (yet) POSIX-compliant, this option allows to disable | |
336 | them. | |
337 | ||
338 | \wxheading{See also} | |
339 | ||
250b589f | 340 | \helpref{Customization}{wxcmdlineparsercustomization} and \helpref{AreLongOptionsEnabled}{wxcmdlineparserarelongoptionsenabled} |
f6bcfd97 | 341 | |
ff1ce997 | 342 | |
f6bcfd97 BP |
343 | \membersection{wxCmdLineParser::DisableLongOptions}\label{wxcmdlineparserdisablelongoptions} |
344 | ||
345 | \func{void}{DisableLongOptions}{\void} | |
346 | ||
cc81d32f | 347 | Identical to \helpref{EnableLongOptions(false)}{wxcmdlineparserenablelongoptions}. |
250b589f | 348 | |
ff1ce997 | 349 | |
250b589f JS |
350 | \membersection{wxCmdLineParser::AreLongOptionsEnabled}\label{wxcmdlineparserarelongoptionsenabled} |
351 | ||
352 | \func{bool}{AreLongOptionsEnabled}{\void} | |
353 | ||
cc81d32f | 354 | Returns true if long options are enabled, otherwise false. |
250b589f JS |
355 | |
356 | \wxheading{See also} | |
357 | ||
358 | \helpref{EnableLongOptions}{wxcmdlineparserenablelongoptions} | |
f6bcfd97 | 359 | |
ff1ce997 | 360 | |
f6bcfd97 BP |
361 | \membersection{wxCmdLineParser::SetLogo}\label{wxcmdlineparsersetlogo} |
362 | ||
363 | \func{void}{SetLogo}{\param{const wxString\& }{logo}} | |
364 | ||
365 | {\it logo} is some extra text which will be shown by | |
366 | \helpref{Usage}{wxcmdlineparserusage} method. | |
367 | ||
ff1ce997 | 368 | |
f6bcfd97 BP |
369 | \membersection{wxCmdLineParser::SetDesc}\label{wxcmdlineparsersetdesc} |
370 | ||
371 | \func{void}{SetDesc}{\param{const wxCmdLineEntryDesc* }{desc}} | |
372 | ||
373 | Construct the command line description | |
374 | ||
375 | Take the command line description from the wxCMD\_LINE\_NONE terminated table. | |
376 | ||
377 | Example of usage: | |
378 | ||
379 | \begin{verbatim} | |
380 | static const wxCmdLineEntryDesc cmdLineDesc[] = | |
381 | { | |
382 | { wxCMD_LINE_SWITCH, "v", "verbose", "be verbose" }, | |
383 | { wxCMD_LINE_SWITCH, "q", "quiet", "be quiet" }, | |
384 | ||
385 | { wxCMD_LINE_OPTION, "o", "output", "output file" }, | |
386 | { wxCMD_LINE_OPTION, "i", "input", "input dir" }, | |
387 | { wxCMD_LINE_OPTION, "s", "size", "output block size", wxCMD_LINE_VAL_NUMBER }, | |
388 | { wxCMD_LINE_OPTION, "d", "date", "output file date", wxCMD_LINE_VAL_DATE }, | |
389 | ||
390 | { wxCMD_LINE_PARAM, NULL, NULL, "input file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_MULTIPLE }, | |
391 | ||
392 | { wxCMD_LINE_NONE } | |
393 | }; | |
394 | ||
395 | wxCmdLineParser parser; | |
396 | ||
397 | parser.SetDesc(cmdLineDesc); | |
398 | \end{verbatim} | |
399 | ||
ff1ce997 | 400 | |
f6bcfd97 BP |
401 | \membersection{wxCmdLineParser::AddSwitch}\label{wxcmdlineparseraddswitch} |
402 | ||
403 | \func{void}{AddSwitch}{\param{const wxString\& }{name}, \param{const wxString\& }{lng = wxEmptyString}, \param{const wxString\& }{desc = wxEmptyString}, \param{int }{flags = 0}} | |
404 | ||
405 | Add a switch {\it name} with an optional long name {\it lng} (no long name if it | |
406 | is empty, which is default), description {\it desc} and flags {\it flags} to the | |
407 | command line description. | |
408 | ||
ff1ce997 | 409 | |
f6bcfd97 BP |
410 | \membersection{wxCmdLineParser::AddOption}\label{wxcmdlineparseraddoption} |
411 | ||
412 | \func{void}{AddOption}{\param{const wxString\& }{name}, \param{const wxString\& }{lng = wxEmptyString}, \param{const wxString\& }{desc = wxEmptyString}, \param{wxCmdLineParamType }{type = wxCMD\_LINE\_VAL\_STRING}, \param{int }{flags = 0}} | |
413 | ||
414 | Add an option {\it name} with an optional long name {\it lng} (no long name if | |
415 | it is empty, which is default) taking a value of the given type (string by | |
416 | default) to the command line description. | |
417 | ||
ff1ce997 | 418 | |
f6bcfd97 BP |
419 | \membersection{wxCmdLineParser::AddParam}\label{wxcmdlineparseraddparam} |
420 | ||
421 | \func{void}{AddParam}{\param{const wxString\& }{desc = wxEmptyString}, \param{wxCmdLineParamType }{type = wxCMD\_LINE\_VAL\_STRING}, \param{int }{flags = 0}} | |
422 | ||
423 | Add a parameter of the given {\it type} to the command line description. | |
424 | ||
ff1ce997 | 425 | |
f6bcfd97 BP |
426 | \membersection{wxCmdLineParser::Parse}\label{wxcmdlineparserparse} |
427 | ||
cc81d32f | 428 | \func{int}{Parse}{\param{bool }{giveUsage = {\tt true}}} |
f6bcfd97 BP |
429 | |
430 | Parse the command line, return $0$ if ok, $-1$ if {\tt "-h"} or {\tt "--help"} | |
431 | option was encountered and the help message was given or a positive value if a | |
43e8916f | 432 | syntax error occurred. |
f6bcfd97 | 433 | |
be03c0ec VZ |
434 | \wxheading{Parameters} |
435 | ||
cc81d32f | 436 | \docparam{giveUsage}{If {\tt true} (default), the usage message is given if a |
be03c0ec | 437 | syntax error was encountered while parsing the command line or if help was |
cc81d32f | 438 | requested. If {\tt false}, only error messages about possible syntax errors |
be03c0ec VZ |
439 | are given, use \helpref{Usage}{wxcmdlineparserusage} to show the usage message |
440 | from the caller if needed.} | |
441 | ||
ff1ce997 | 442 | |
f6bcfd97 BP |
443 | \membersection{wxCmdLineParser::Usage}\label{wxcmdlineparserusage} |
444 | ||
445 | \func{void}{Usage}{\void} | |
446 | ||
447 | Give the standard usage message describing all program options. It will use the | |
448 | options and parameters descriptions specified earlier, so the resulting message | |
449 | will not be helpful to the user unless the descriptions were indeed specified. | |
450 | ||
451 | \wxheading{See also} | |
452 | ||
453 | \helpref{SetLogo}{wxcmdlineparsersetlogo} | |
454 | ||
ff1ce997 | 455 | |
a9c95884 | 456 | \membersection{wxCmdLineParser::Found}\label{wxcmdlineparserfound} |
f6bcfd97 BP |
457 | |
458 | \constfunc{bool}{Found}{\param{const wxString\& }{name}} | |
459 | ||
a9c95884 | 460 | Returns \true if the given switch was found, false otherwise. |
f6bcfd97 BP |
461 | |
462 | \constfunc{bool}{Found}{\param{const wxString\& }{name}, \param{wxString* }{value}} | |
463 | ||
a9c95884 | 464 | Returns \true if an option taking a string value was found and stores the |
f6bcfd97 BP |
465 | value in the provided pointer (which should not be NULL). |
466 | ||
f6bcfd97 BP |
467 | \constfunc{bool}{Found}{\param{const wxString\& }{name}, \param{long* }{value}} |
468 | ||
a9c95884 | 469 | Returns \true if an option taking an integer value was found and stores |
f6bcfd97 BP |
470 | the value in the provided pointer (which should not be NULL). |
471 | ||
f6bcfd97 BP |
472 | \constfunc{bool}{Found}{\param{const wxString\& }{name}, \param{wxDateTime* }{value}} |
473 | ||
a9c95884 | 474 | Returns \true if an option taking a date value was found and stores the |
f6bcfd97 BP |
475 | value in the provided pointer (which should not be NULL). |
476 | ||
ff1ce997 | 477 | |
f6bcfd97 BP |
478 | \membersection{wxCmdLineParser::GetParamCount}\label{wxcmdlineparsergetparamcount} |
479 | ||
480 | \constfunc{size\_t}{GetParamCount}{\void} | |
481 | ||
482 | Returns the number of parameters found. This function makes sense mostly if you | |
483 | had used {\tt wxCMD\_LINE\_PARAM\_MULTIPLE} flag. | |
484 | ||
ff1ce997 | 485 | |
f6bcfd97 BP |
486 | \membersection{wxCmdLineParser::GetParam}\label{wxcmdlineparsergetparam} |
487 | ||
488 | \constfunc{wxString}{GetParam}{\param{size\_t }{n = 0u}} | |
489 | ||
a9c95884 | 490 | Returns the value of Nth parameter (as string only). |
f6bcfd97 BP |
491 | |
492 | \wxheading{See also} | |
493 | ||
494 | \helpref{GetParamCount}{wxcmdlineparsergetparamcount} | |
495 |