]> Creatis software - CreaPhase.git/blob - octave_packages/general-1.3.1/@inputParser/addSwitch.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / general-1.3.1 / @inputParser / addSwitch.m
1 ## Copyright (C) 2011-2012 CarnĂ« Draug <carandraug+dev@gmail.com>
2 ##
3 ## This program is free software; you can redistribute it and/or modify it under
4 ## the terms of the GNU General Public License as published by the Free Software
5 ## Foundation; either version 3 of the License, or (at your option) any later
6 ## version.
7 ##
8 ## This program is distributed in the hope that it will be useful, but WITHOUT
9 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
11 ## details.
12 ##
13 ## You should have received a copy of the GNU General Public License along with
14 ## this program; if not, see <http://www.gnu.org/licenses/>.
15
16 ## -*- texinfo -*-
17 ## @deftypefn {Function File} {@var{parser} =} addSwitch (@var{parser}, @var{argname})
18 ## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addSwitch (@var{argname})
19 ## Add new switch type of argument to the object @var{parser} of inputParser class.
20 ##
21 ## This method belongs to the inputParser class and implements a switch
22 ## arguments type of API.
23 ##
24 ## @var{argname} must be a string with the name of the new argument. Arguments
25 ## of this type can be specified at the end, after @code{Required} and @code{Optional},
26 ## and mixed between the @code{ParamValue}. They default to false. If one of the
27 ## arguments supplied is a string like @var{argname}, then after parsing the value
28 ## of @var{parse}.Results.@var{argname} will be true.
29 ##
30 ## See @command{help inputParser} for examples.
31 ##
32 ## @seealso{inputParser, @@inputParser/addOptional, @@inputParser/addParamValue
33 ## @@inputParser/addParamValue, @@inputParser/addRequired, @@inputParser/parse}
34 ## @end deftypefn
35
36 function inPar = addSwitch (inPar, name)
37
38   ## check @inputParser/subsref for the actual code
39   if (nargin == 2)
40     inPar = subsref (inPar, substruct(
41                                       '.' , 'addSwitch',
42                                       '()', {name}
43                                       ));
44   else
45     print_usage;
46   endif
47
48 endfunction