From: <car...@us...> - 2012-05-14 07:11:05
|
Revision: 10430 http://octave.svn.sourceforge.net/octave/?rev=10430&view=rev Author: carandraug Date: 2012-05-14 07:10:59 +0000 (Mon, 14 May 2012) Log Message: ----------- inputParser: proper and pretty display method for class Modified Paths: -------------- trunk/octave-forge/main/general/inst/@inputParser/display.m Modified: trunk/octave-forge/main/general/inst/@inputParser/display.m =================================================================== --- trunk/octave-forge/main/general/inst/@inputParser/display.m 2012-05-12 19:04:36 UTC (rev 10429) +++ trunk/octave-forge/main/general/inst/@inputParser/display.m 2012-05-14 07:10:59 UTC (rev 10430) @@ -1,4 +1,4 @@ -## Copyright (C) 2011 Carnë Draug <car...@gm...> +## Copyright (C) 2011-2012 Carnë Draug <car...@gm...> ## ## This program is free software; you can redistribute it and/or modify it under ## the terms of the GNU General Public License as published by the Free Software @@ -15,10 +15,44 @@ function display (inPar) - fields = fieldnames (inPar); - for i = 1 : numel(fields) - printf ("%s\n", fields{i}); - inPar.(fields{i}) - end + if (inPar.FunctionName) + name = inPar.FunctionName(1:end-3); + else + name = ""; + endif + required = arg_list (inPar.Required); + optional = arg_list (inPar.Optional); + paramvalue = arg_list (inPar.ParamValue); + switches = arg_list (inPar.Switch); + + printf ("Input Parser object with:\n"); + printf ("CaseSensitive: %s\n", binstr (inPar.CaseSensitive)); + printf ("StructExpand : %s\n", binstr (inPar.StructExpand)); + printf ("KeepUnmatched: %s\n", binstr (inPar.KeepUnmatched)); + printf ("FunctionName : '%s'\n", name); + printf ("\n"); + printf ("Required arguments : %s\n", required); + printf ("Optional arguments : %s\n", optional); + printf ("ParamValue arguments: %s\n", paramvalue); + printf ("Switch arguments : %s\n", switches); + endfunction + +function [str] = binstr (bin) + if (bin) + str = "true"; + else + str = "false"; + endif +endfunction + +function [str] = arg_list (args) + str = strcat ("'", fieldnames (args), {"', "}); + if (!isempty (str)) + str = cstrcat (str{:}); + str = str(1:end-2); # remove the last comma and space + else + str = ""; + endif +endfunction This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |