]> Creatis software - CreaPhase.git/blob - octave_packages/general-1.3.1/@inputParser/display.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / general-1.3.1 / @inputParser / display.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 function display (inPar)
17
18   if (inPar.FunctionName)
19     name = inPar.FunctionName(1:end-3);
20   else
21     name = "";
22   endif
23
24   required    = arg_list (inPar.Required);
25   optional    = arg_list (inPar.Optional);
26   paramvalue  = arg_list (inPar.ParamValue);
27   switches    = arg_list (inPar.Switch);
28
29   printf ("Input Parser object with:\n");
30   printf ("CaseSensitive: %s\n", binstr (inPar.CaseSensitive));
31   printf ("StructExpand : %s\n", binstr (inPar.StructExpand));
32   printf ("KeepUnmatched: %s\n", binstr (inPar.KeepUnmatched));
33   printf ("FunctionName : '%s'\n", name);
34   printf ("\n");
35   printf ("Required arguments  : %s\n", required);
36   printf ("Optional arguments  : %s\n", optional);
37   printf ("ParamValue arguments: %s\n", paramvalue);
38   printf ("Switch arguments    : %s\n", switches);
39
40 endfunction
41
42 function [str] = binstr (bin)
43   if (bin)
44     str = "true";
45   else
46     str = "false";
47   endif
48 endfunction
49
50 function [str] = arg_list (args)
51   str = strcat ("'", fieldnames (args), {"', "});
52   if (!isempty (str))
53     str = cstrcat (str{:});
54     str = str(1:end-2);     # remove the last comma and space
55   else
56     str = "";
57   endif
58 endfunction