Index: main/general/inst/@inputParser/addOptional.m
===================================================================
--- main/general/inst/@inputParser/addOptional.m	(revision 12474)
+++ main/general/inst/@inputParser/addOptional.m	(working copy)
@@ -1,63 +0,0 @@
-## Copyright (C) 2011 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {@var{parser} =} addOptional (@var{parser}, @var{argname}, @var{default})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addOptional (@var{argname}, @var{default})
-## @deftypefnx {Function File} {@var{parser} =} addOptional (@var{parser}, @var{argname}, @var{default}, @var{validator})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addOptional (@var{argname}, @var{default}, @var{validator})
-## Add new optional argument to the object @var{parser} of the class inputParser
-## to implement an ordered arguments type of API 
-##
-## @var{argname} must be a string with the name of the new argument. The order
-## in which new arguments are added with @command{addOptional}, represents the
-## expected order of arguments.
-##
-## @var{default} will be the value used when the argument is not specified.
-##
-## @var{validator} is an optional anonymous function to validate the given values
-## for the argument with name @var{argname}. Alternatively, a function name
-## can be used.
-##
-## See @command{help inputParser} for examples.
-##
-## @emph{Note}: if a string argument does not validate, it will be considered a
-## ParamValue key. If an optional argument is not given a validator, anything
-## will be valid, and so any string will be considered will be the value of the
-## optional argument (in @sc{matlab}, if no validator is given and argument is
-## a string it will also be considered a ParamValue key).
-##
-## @seealso{inputParser, @@inputParser/addParamValue, @@inputParser/addSwitch,
-## @@inputParser/addParamValue, @@inputParser/addRequired, @@inputParser/parse}
-## @end deftypefn
-
-function inPar = addOptional (inPar, name, def, val)
-
-  ## check @inputParser/subsref for the actual code
-  if (nargin == 3)
-    inPar = subsref (inPar, substruct(
-                                      '.' , 'addOptional',
-                                      '()', {name, def}
-                                      ));
-  elseif (nargin == 4)
-    inPar = subsref (inPar, substruct(
-                                      '.' , 'addOptional',
-                                      '()', {name, def, val}
-                                      ));
-  else
-    print_usage;
-  endif
-
-endfunction
Index: main/general/inst/@inputParser/addParamValue.m
===================================================================
--- main/general/inst/@inputParser/addParamValue.m	(revision 12474)
+++ main/general/inst/@inputParser/addParamValue.m	(working copy)
@@ -1,55 +0,0 @@
-## Copyright (C) 2011 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {@var{parser} =} addParamValue (@var{parser}, @var{argname}, @var{default})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addParamValue (@var{argname}, @var{default})
-## @deftypefnx {Function File} {@var{parser} =} addParamValue (@var{parser}, @var{argname}, @var{default}, @var{validator})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addParamValue (@var{argname}, @var{default}, @var{validator})
-## Add new parameter to the object @var{parser} of the class inputParser to implement
-## a name/value pair type of API.
-##
-## @var{argname} must be a string with the name of the new parameter.
-##
-## @var{default} will be the value used when the parameter is not specified.
-##
-## @var{validator} is an optional function handle to validate the given values
-## for the parameter with name @var{argname}. Alternatively, a function name
-## can be used.
-##
-## See @command{help inputParser} for examples.
-##
-## @seealso{inputParser, @@inputParser/addOptional, @@inputParser/addSwitch,
-## @@inputParser/addParamValue, @@inputParser/addRequired, @@inputParser/parse}
-## @end deftypefn
-
-function inPar = addParamValue (inPar, name, def, val)
-
-  ## check @inputParser/subsref for the actual code
-  if (nargin == 3)
-    inPar = subsref (inPar, substruct(
-                                      '.' , 'addParamValue',
-                                      '()', {name, def}
-                                      ));
-  elseif (nargin == 4)
-    inPar = subsref (inPar, substruct(
-                                      '.' , 'addParamValue',
-                                      '()', {name, def, val}
-                                      ));
-  else
-    print_usage;
-  endif
-
-endfunction
Index: main/general/inst/@inputParser/addRequired.m
===================================================================
--- main/general/inst/@inputParser/addRequired.m	(revision 12474)
+++ main/general/inst/@inputParser/addRequired.m	(working copy)
@@ -1,60 +0,0 @@
-## Copyright (C) 2011 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {@var{parser} =} addRequired (@var{parser}, @var{argname})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addRequired (@var{argname})
-## @deftypefnx {Function File} {@var{parser} =} addRequired (@var{parser}, @var{argname}, @var{validator})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addRequired (@var{argname}, @var{validator})
-## Add new mandatory argument to the object @var{parser} of inputParser class.
-##
-## This method belongs to the inputParser class and implements an ordered
-## arguments type of API.
-##
-## @var{argname} must be a string with the name of the new argument. The order
-## in which new arguments are added with @command{addrequired}, represents the
-## expected order of arguments.
-##
-## @var{validator} is an optional function handle to validate the given values
-## for the argument with name @var{argname}. Alternatively, a function name
-## can be used.
-##
-## See @command{help inputParser} for examples.
-##
-## @emph{Note}: this can be used together with the other type of arguments but
-## it must be the first (see @command{@@inputParser}).
-##
-## @seealso{inputParser, @@inputParser/addOptional, @@inputParser/addParamValue
-## @@inputParser/addParamValue, @@inputParser/addSwitch, @@inputParser/parse}
-## @end deftypefn
-
-function inPar = addRequired (inPar, name, val)
-
-  ## check @inputParser/subsref for the actual code
-  if (nargin == 2)
-    inPar = subsref (inPar, substruct(
-                                      '.' , 'addRequired',
-                                      '()', {name}
-                                      ));
-  elseif (nargin == 3)
-    inPar = subsref (inPar, substruct(
-                                      '.' , 'addRequired',
-                                      '()', {name, val}
-                                      ));
-  else
-    print_usage;
-  endif
-
-endfunction
Index: main/general/inst/@inputParser/addSwitch.m
===================================================================
--- main/general/inst/@inputParser/addSwitch.m	(revision 12474)
+++ main/general/inst/@inputParser/addSwitch.m	(working copy)
@@ -1,48 +0,0 @@
-## Copyright (C) 2011-2012 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {@var{parser} =} addSwitch (@var{parser}, @var{argname})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.addSwitch (@var{argname})
-## Add new switch type of argument to the object @var{parser} of inputParser class.
-##
-## This method belongs to the inputParser class and implements a switch
-## arguments type of API.
-##
-## @var{argname} must be a string with the name of the new argument. Arguments
-## of this type can be specified at the end, after @code{Required} and @code{Optional},
-## and mixed between the @code{ParamValue}. They default to false. If one of the
-## arguments supplied is a string like @var{argname}, then after parsing the value
-## of @var{parse}.Results.@var{argname} will be true.
-##
-## See @command{help inputParser} for examples.
-##
-## @seealso{inputParser, @@inputParser/addOptional, @@inputParser/addParamValue
-## @@inputParser/addParamValue, @@inputParser/addRequired, @@inputParser/parse}
-## @end deftypefn
-
-function inPar = addSwitch (inPar, name)
-
-  ## check @inputParser/subsref for the actual code
-  if (nargin == 2)
-    inPar = subsref (inPar, substruct(
-                                      '.' , 'addSwitch',
-                                      '()', {name}
-                                      ));
-  else
-    print_usage;
-  endif
-
-endfunction
Index: main/general/inst/@inputParser/createCopy.m
===================================================================
--- main/general/inst/@inputParser/createCopy.m	(revision 12474)
+++ main/general/inst/@inputParser/createCopy.m	(working copy)
@@ -1,38 +0,0 @@
-## Copyright (C) 2011 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {@var{new_parser} =} createCopy (@var{parser})
-## Creates a copy @var{new_parser} of the object @var{parser} of the inputParser
-## class.
-##
-## @seealso{inputParser, @@inputParser/addOptional, @@inputParser/addParamValue
-## @@inputParser/addParamValue, @@inputParser/addRequired, @@inputParser/addSwitch,
-## @@inputParser/parse}
-## @end deftypefn
-
-function outPar = createCopy (inPar)
-
-  if ( nargin != 1 )
-    print_usage;
-  elseif ( !isa (inPar, 'inputParser') )
-    error ("object must be of the inputParser class but '%s' was used", class (inPar) );
-  endif
-
-  ## yes, it's a ridiculous function but exists for MatLab compatibility. In there
-  ## the inputParser class is a 'handle class' and this would just return a reference
-  outPar = inPar;
-
-endfunction
Index: main/general/inst/@inputParser/display.m
===================================================================
--- main/general/inst/@inputParser/display.m	(revision 12474)
+++ main/general/inst/@inputParser/display.m	(working copy)
@@ -1,58 +0,0 @@
-## Copyright (C) 2011-2012 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-function display (inPar)
-
-  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
Index: main/general/inst/@inputParser/inputParser.m
===================================================================
--- main/general/inst/@inputParser/inputParser.m	(revision 12474)
+++ main/general/inst/@inputParser/inputParser.m	(working copy)
@@ -1,224 +0,0 @@
-## Copyright (C) 2011-2012 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {@var{parser} =} inputParser ()
-## Create object @var{parser} of the inputParser class.
-##
-## This class is designed to allow easy parsing of function arguments. This class
-## supports four types of arguments:
-##
-## @enumerate
-## @item mandatory (see @command{@@inputParser/addRequired});
-## @item optional (see @command{@@inputParser/addOptional});
-## @item named (see @command{@@inputParser/addParamValue});
-## @item switch (see @command{@@inputParser/addSwitch}).
-## @end enumerate
-##
-## After defining the function API with this methods, the supplied arguments can
-## be parsed with the @command{@@inputParser/parse} method and the parsing results
-## accessed with the @command{Results} accessor.
-##
-## @deftypefnx {Accessor method} parser.Parameters
-## Return list of parameters name already defined.
-##
-## @deftypefnx {Accessor method} parser.Results
-## Return structure with argument names as fieldnames and corresponding values.
-##
-## @deftypefnx {Accessor method} parser.Unmatched
-## Return structure similar to @command{Results} for unmatched parameters. See
-## the @command{KeepUnmatched} property.
-##
-## @deftypefnx {Accessor method} parser.UsingDefaults
-## Return cell array with the names of arguments that are using default values.
-##
-## @deftypefnx {Class property} parser.CaseSensitive = @var{boolean}
-## Set whether matching of argument names should be case sensitive. Defaults to false.
-##
-## @deftypefnx {Class property} parser.FunctionName = @var{name}
-## Set function name to be used on error messages. Defauls to empty string.
-##
-## @deftypefnx {Class property} parser.KeepUnmatched = @var{boolean}
-## Set whether an error should be given for non-defined arguments. Defaults to
-## false. If set to true, the extra arguments can be accessed through
-## @code{Unmatched} after the @code{parse} method. Note that since @command{Switch}
-## and @command{ParamValue} arguments can be mixed, it is not possible to know
-## the unmatched type. If argument is found unmatched it is assumed to be of the
-## @command{ParamValue} type and it is expected to be followed by a value.
-##
-## @deftypefnx {Class property} parser.StructExpand = @var{boolean}
-## Set whether a structure can be passed to the function instead of parameter
-## value pairs. Defaults to true. Not implemented yet.
-##
-## The following example shows how to use this class:
-##
-## @example
-## @group
-## function check (pack, path, mat, varargin)
-##     p = inputParser;                             # create object
-##     p.FunctionName = "check";                    # set function name
-##     p = p.addRequired ("pack", @@ischar);         # create mandatory argument
-##
-##     p = p.addOptional ("path", pwd(), @@ischar);  # create optional argument
-##
-##     ## one can create a function handle to anonymous functions for validators
-##     val_mat = @@(x)isvector(x) && all( x <= 1) && all(x >= 0);
-##     p = p.addOptional ("mat", [0 0], val_mat);
-##
-##     ## create two ParamValue type of arguments
-##     val_type = @@(x) ischar(x) && any(strcmp(x, @{"linear", "quadratic"@});
-##     p = p.addParamValue ("type", "linear", @@val_type);
-##     val_verb = @@(x) ischar(x) && any(strcmp(x, @{"low", "medium", "high"@});
-##     p = p.addParamValue ("tolerance", "low", @@val_verb);
-##
-##     ## create a switch type of argument
-##     p = p.addSwitch ("verbose");
-##
-##     p = p.parse (pack, path, mat, varargin@{:@});
-##
-##     ## the rest of the function can access the input by accessing p.Results
-##     ## for example, to access the value of tolerance, use p.Results.tolerance
-## endfunction
-##
-## check ("mech");            # valid, will use defaults for other arguments
-## check ();                  # error since at least one argument is mandatory
-## check (1);                 # error since !ischar
-## check ("mech", "~/dev");   # valid, will use defaults for other arguments
-##
-## check ("mech", "~/dev", [0 1 0 0], "type", "linear");  # valid
-##
-## ## the following is also valid. Note how the Switch type of argument can be
-## ## mixed into or before the ParamValue (but still after Optional)
-## check ("mech", "~/dev", [0 1 0 0], "verbose", "tolerance", "high");
-##
-## ## the following returns an error since not all optional arguments, `path' and
-## ## `mat', were given before the named argument `type'.
-## check ("mech", "~/dev", "type", "linear");
-## @end group
-## @end example
-##
-## @emph{Note 1}: a function can have any mixture of the four API types but they
-## must appear in a specific order. @command{Required} arguments must be the very
-## first which can be followed by @command{Optional} arguments. Only the
-## @command{ParamValue} and @command{Switch} arguments can be mixed together but
-## must be at the end.
-##
-## @emph{Note 2}: if both @command{Optional} and @command{ParamValue} arguments
-## are mixed in a function API, once a string Optional argument fails to validate
-## against, it will be considered the end of @command{Optional} arguments and the
-## first key for a @command{ParamValue} and @command{Switch} arguments.
-##
-## @seealso{@@inputParser/addOptional, @@inputParser/addSwitch,
-## @@inputParser/addParamValue, @@inputParser/addRequired,
-## @@inputParser/createCopy, @@inputParser/parse}
-## @end deftypefn
-
-function inPar = inputParser
-
-  if (nargin != 0)
-    print_usage;
-  endif
-
-  inPar = struct;
-
-  ## these are not to be accessed by users. Each will have a field whose names
-  ## are the argnames which will also be a struct with fieldnames 'validator'
-  ## and 'default'
-  inPar.ParamValue    = struct;
-  inPar.Optional      = struct;
-  inPar.Required      = struct;
-  inPar.Switch        = struct;
-
-  ## this will be filled when the methodd parse is used and will be a struct whose
-  ## fieldnames are the argnames that return their value
-  inPar.Results       = struct;
-
-  ## an 1xN cell array with argnames. It is read only by the user and its order
-  ## showws the order that they were added to the object (which is the order they
-  ## will be expected)
-  inPar.Parameters    = {};
-
-  inPar.CaseSensitive = false;
-  inPar.FunctionName  = '';      # name of the function for the error message
-  inPar.KeepUnmatched = false;
-  inPar.StructExpand  = true;
-  inPar.Unmatched     = struct;
-  inPar.UsingDefaults = {};
-
-  inPar = class (inPar, 'inputParser');
-
-endfunction
-
-%!shared p, out
-%! p = inputParser;
-%! p = p.addRequired   ("req1", @(x) ischar (x));
-%! p = p.addOptional   ("op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
-%! p = p.addOptional   ("op2", 78, @(x) (x) > 50);
-%! p = p.addSwitch     ("verbose");
-%! p = p.addParamValue ("line", "tree", @(x) ischar (x) && any (strcmp (x, {"tree", "circle"})));
-%! ## check normal use, only required are given
-%! out = p.parse ("file");
-%!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
-%!        {"file"          , "val"          , 78             , false              , "tree"});
-%!assert (out.UsingDefaults, {"op1", "op2", "verbose", "line"});
-%! ## check normal use, but give values different than defaults
-%! out = p.parse ("file", "foo", 80, "line", "circle", "verbose");
-%!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
-%!        {"file"          , "foo"          , 80             , true              , "circle"});
-%! ## check optional is skipped and considered ParamValue if unvalidated string
-%! out = p.parse ("file", "line", "circle");
-%!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
-%!        {"file"          , "val"          , 78             , false              , "circle"});
-%! ## check case insensitivity
-%! out = p.parse ("file", "foo", 80, "LiNE", "circle", "vERbOSe");
-%!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
-%!        {"file"          , "foo"          , 80             , true              , "circle"});
-%! ## check KeepUnmatched
-%! p.KeepUnmatched = true;
-%! out = p.parse ("file", "foo", 80, "line", "circle", "verbose", "extra", 50);
-%!assert (out.Unmatched.extra, 50)
-%! ## check error when missing required
-%!error(p.parse())
-%! ## check error when given required do not validate
-%!error(p.parse(50))
-%! ## check error when given optional do not validate
-%!error(p.parse("file", "no-val"))
-%! ## check error when given ParamValue do not validate
-%!error(p.parse("file", "foo", 51, "line", "round"))
-
-## check alternative method (obj), ...) API
-%!shared p, out
-%! p = inputParser;
-%! p = addRequired   (p, "req1", @(x) ischar (x));
-%! p = addOptional   (p, "op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
-%! p = addOptional   (p, "op2", 78, @(x) (x) > 50);
-%! p = addSwitch     (p, "verbose");
-%! p = addParamValue (p, "line", "tree", @(x) ischar (x) && any (strcmp (x, {"tree", "circle"})));
-%! ## check normal use, only required are given
-%! out = parse (p, "file");
-%!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
-%!        {"file"          , "val"          , 78             , false              , "tree"});
-%!assert (out.UsingDefaults, {"op1", "op2", "verbose", "line"});
-%! ## check normal use, but give values different than defaults
-%! out = parse (p, "file", "foo", 80, "line", "circle", "verbose");
-%!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
-%!        {"file"          , "foo"          , 80             , true              , "circle"});
-
-## if we were matlab compatible...
-%!shared p, out
-%! p = inputParser;
-%! p = p.addOptional   ("op1", "val");
-%! p = p.addParamValue ("line", "tree");
-%!xtest assert (getfield (p.parse("line", "circle"), "Results"), struct ("op1", "val", "line", "circle"));
Index: main/general/inst/@inputParser/parse.m
===================================================================
--- main/general/inst/@inputParser/parse.m	(revision 12474)
+++ main/general/inst/@inputParser/parse.m	(working copy)
@@ -1,37 +0,0 @@
-## Copyright (C) 2011 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-## -*- texinfo -*-
-## @deftypefn {Function File} {@var{parser} =} parse (@var{parser}, @var{varargin})
-## @deftypefnx {Function File} {@var{parser} =} @var{parser}.parse (@var{varargin})
-## Parses and validates list of arguments according to object @var{parser} of the
-## class inputParser.
-##
-## After parsing, the results can be accessed with the @command{Results}
-## accessor. See @command{help inputParser} for a more complete description.
-##
-## @seealso{inputParser, @@inputParser/addOptional, @@inputParser/addParamValue
-## @@inputParser/addParamValue, @@inputParser/addRequired, @@inputParser/addSwitch}
-## @end deftypefn
-
-function inPar = parse (inPar, varargin)
-
-  ## check @inputParser/subsref for the actual code
-  inPar = subsref (inPar, substruct(
-                                    '.' , 'parse',
-                                    '()', varargin
-                                    ));
-
-endfunction
Index: main/general/inst/@inputParser/subsasgn.m
===================================================================
--- main/general/inst/@inputParser/subsasgn.m	(revision 12474)
+++ main/general/inst/@inputParser/subsasgn.m	(working copy)
@@ -1,37 +0,0 @@
-## Copyright (C) 2011 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-function inPar = subsasgn (inPar, idx, rhs)
-
-  if ( idx.type != '.' )
-    error ("invalid index for class %s", class (inPar) );
-  endif
-
-  switch idx.subs
-    case {'CaseSensitive', 'KeepUnmatched', 'StructExpand'}
-      if ( !islogical (rhs) )
-        error("Property '%s' of the class inputParser must be logical", idx.subs)
-      endif
-      inPar.(idx.subs) = rhs;
-    case 'FunctionName'
-      if ( !ischar (rhs) )
-        error("Property 'FunctionName' of the class inputParser can only be set to a string")
-      endif
-      inPar.(idx.subs) = sprintf("%s : ", rhs);
-    otherwise
-      error ("invalid index for assignment of class %s", class (inPar) );
-  endswitch
-
-endfunction
Index: main/general/inst/@inputParser/subsref.m
===================================================================
--- main/general/inst/@inputParser/subsref.m	(revision 12474)
+++ main/general/inst/@inputParser/subsref.m	(working copy)
@@ -1,336 +0,0 @@
-## Copyright (C) 2011-2012 Carnë Draug <carandraug+dev@gmail.com>
-##
-## 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
-## Foundation; either version 3 of the License, or (at your option) any later
-## version.
-##
-## This program is distributed in the hope that it will be useful, but WITHOUT
-## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-## details.
-##
-## You should have received a copy of the GNU General Public License along with
-## this program; if not, see <http://www.gnu.org/licenses/>.
-
-function inPar = subsref (inPar, idx)
-
-  if ( !isa (inPar, 'inputParser') )
-    error ("object must be of the inputParser class but '%s' was used", class (inPar) );
-  elseif ( idx(1).type != '.' )
-    error ("invalid index for class %s", class (inPar) );
-  endif
-
-  ## the following at the end may allow to use the obj.method notation one day
-  ## jwe is very against this ugly hack
-  ## what would happen if the user has the obj inside a struct? Bad things!
-#  ori = inputname(1);
-#  assignin('caller', ori, inPar);
-
-  method = idx(1).subs;
-
-  switch method
-  case 'Results'
-    inPar = retrieve_results (inPar, idx)
-  case 'Parameters'
-    inPar = inPar.Parameters;
-  case 'parse'
-    inPar = parse_args (inPar, idx);
-  case 'Unmatched'
-  case 'UsingDefaults'
-  case {'addOptional', 'addParamValue', 'addRequired', 'addSwitch'}
-    inPar = check_methods (inPar, idx);
-  otherwise
-    error ("invalid index for reference of class %s", class (inPar) );
-  endswitch
-
-  ## TODO we should make inPar an object of the inputParser class again. At
-  ## least after running parse it becomes just a structure again. While that is
-  ## bad, at least allows for easy access to the Results and Unmatched fields
-  ## without extra coding.
-#  inPar = class (inPar, 'inputParser');
-
-endfunction
-
-function out = retrieve_results (inPar, idx)
-
-  if ( numel(idx) != 2 || idx(2).type != '.' )
-    print_usage ("@inputParser/Results");
-  endif
-
-  out = inPar.Results.(idx(2).subs);
-
-endfunction
-
-
-## when parsing options, here's the principle: Required options have to be the
-## first ones. They are followed by Optional if any. In the end come the
-## ParamValue mixed with Switch. Any other order makes no sense
-function inPar = parse_args (inPar, idx)
-
-  ## syntax is inPar.parse (arguments)
-  if ( numel(idx) != 2 || idx(2).type != '()' )
-    print_usage ("@inputParser/parse");
-  endif
-
-  ## this makes it easier to read but may be memory instensive
-  args = idx(2).subs;
-
-  ## make copy of ordered list of Parameters to keep the original intact and readable
-  inPar.copy = inPar.Parameters;
-
-  if ( numel (fieldnames (inPar.Required)) > numel (args) )
-    error("%sNot enough arguments", inPar.FunctionName);
-  endif
-
-  ## we take names out of 'copy' and values out of 'args', evaluate them and
-  ## store them into 'Results'
-  for i = 1 : numel (fieldnames (inPar.Required))
-    [name, inPar.copy] = shift (inPar.copy);
-    [value, args]      = shift (args);
-    if ( !feval (inPar.Required.(name).validator, value) )
-      error_invalid (inPar.FunctionName, name, inPar.Required.(name).validator);
-    endif
-    inPar.Results.(name) = value;
-  endfor
-
-  ## loop a maximum #times of the number of Optional, similarly to the required
-  ## loop. Once ran out of 'args', move their name into usingDefaults, place
-  ## their default values into 'Results', and break
-
-  ## because if an argument is string and does not validate, should be considered
-  ## a ParamValue key
-  found_possible_key = false;
-
-  for i = 1 : numel (fieldnames (inPar.Optional))
-    if ( !numel (args) || found_possible_key)
-      ## loops the number of Optional options minus the number of them already processed
-      for n = 1 : (numel (fieldnames (inPar.Optional)) - i + 1 )
-        [name, inPar.copy]   = shift (inPar.copy);
-        inPar.UsingDefaults  = push (inPar.UsingDefaults, name);
-        inPar.Results.(name) = inPar.Optional.(name).default;
-      endfor
-      break
-    endif
-    [name, inPar.copy] = shift (inPar.copy);
-    [value, args]      = shift (args);
-    if ( !feval (inPar.Optional.(name).validator, value) )
-      if (ischar (value) )
-        ## maybe the other optional are not defined, this can be Paramvalue
-        ## place this one on defaults and go back to the top with note to clean loop
-        inPar.UsingDefaults  = push (inPar.UsingDefaults, name);
-        inPar.Results.(name) = inPar.Optional.(name).default;
-        found_possible_key   = true;
-        args = unshift (args, value);
-        continue
-      else
-        error_invalid (inPar.FunctionName, name, inPar.Optional.(name).validator);
-      endif
-    else
-      inPar.Results.(name) = value;
-    endif
-  endfor
-
-  ## loop a maximum #times of the number of ParamValue, taking pairs of keys and
-  ## values out 'args'. We no longer expect an order so we need the index in
-  ## 'copy' to remove it from there. Once ran out of 'args', move their name
-  ## into usingDefaults, place their default values into 'Results', and break
-  for i = 1 : (numel (fieldnames (inPar.ParamValue)) + numel (fieldnames (inPar.Switch)))
-    if ( !numel (args) )
-      ## loops the number of times left in 'copy' since these are the last type
-      for n = 1 : numel (inPar.copy)
-        [name, inPar.copy]   = shift (inPar.copy);
-        inPar.UsingDefaults  = push (inPar.UsingDefaults, name);
-        if (isfield (inPar.ParamValue, name))
-          inPar.Results.(name) = inPar.ParamValue.(name).default;
-        else
-          inPar.Results.(name) = inPar.Switch.(name).default;
-        endif
-      endfor
-      break
-    endif
-    [key, args] = shift (args);
-    if ( !ischar (key) )
-      error("%sParameter/Switch names must be strings", inPar.FunctionName);
-    endif
-    if (inPar.CaseSensitive)
-      index = find( strcmp(inPar.copy, key));
-    else
-      index = find( strcmpi(inPar.copy, key));
-    endif
-    ## we can't use isfield here to support case insensitive
-    if (any (strcmpi (fieldnames (inPar.Switch), key)))
-      value  = true;
-      method = "Switch";
-    else
-      ## then it must be a ParamValue (even if unmatched), shift its value
-      if (numel (args) < 1)
-        error ("%sparameter '%s' does not have a value", inPar.FunctionName, key);
-      endif
-      [value, args] = shift (args);
-      method = "ParamValue";
-    endif
-
-    ## empty index means no match so either return error or move them into 'Unmatched'
-    if (!isempty (index))
-      [name, inPar.copy] = shift (inPar.copy, index);
-      if ( !feval (inPar.(method).(name).validator, value))
-        error_invalid (inPar.FunctionName, key, inPar.(method).(name).validator);
-      endif
-      ## we use the name shifted from 'copy' instead of the key from 'args' in case
-      ## the key is in the wrong case
-      inPar.Results.(name) = value;
-    elseif (isempty (index) && inPar.KeepUnmatched )
-      inPar.Unmatched.(key) = value;
-      i = i - 1; # this time didn't count, go back one
-    else
-      error ("%sargument '%s' did not match any valid parameter of the parser", inPar.FunctionName, key);
-    endif
-  endfor
-
-  ## if there's leftovers they must be unmatched. Note that some unmatched can
-  ## have already been processed in the ParamValue loop
-  if ( numel (args) && inPar.KeepUnmatched )
-    for i = 1 : ( numel(args) / 2 )
-      [key, args]           = shift (args);
-      [value, args]         = shift (args);
-      inPar.Unmatched.(key) = value;
-    endfor
-  elseif ( numel (args) )
-    error("%sfound unmatched parameters at end of arguments list", inPar.FunctionName);
-  endif
-
-  ## remove copied field, keep it clean
-  inPar = rmfield (inPar, 'copy');
-
-endfunction
-
-
-function inPar = check_methods (inPar, idx)
-
-  ## this makes it easier to read but is more memory intensive?
-  method  = idx(1).subs;
-  args    = idx(2).subs;
-  func    = sprintf ("@inputParser/%s", method);
-
-  if ( idx(2).type != '()' )
-    print_usage (func);
-  endif
-  def_val      = @() true;
-  [name, args] = shift (args);
-  ## a validator is optional but that complicates handling all the parsing with
-  ## few functions and conditions. If not specified @() true will always return
-  ## true. Simply using true is not enough because if the argument is zero it
-  ## return false and if it's too large, takes up memory
-  switch method
-  case {'addOptional', 'addParamValue'}
-    if     ( numel (args) == 1 )
-      args{2} = def_val;
-    elseif ( numel (args) == 2 )
-      args{2} = validate_validator (args{2});
-    else
-      print_usage(func);
-    endif
-    [def, val] = args{:};
-  case {'addRequired'}
-    if     ( numel (args) == 0 )
-      val = def_val;
-    elseif ( numel (args) == 1 )
-      val = validate_validator (args{1});
-    else
-      print_usage(func);
-    endif
-    def = false;
-  case {'addSwitch'}
-    if ( numel (args) == 0 )
-      val = def_val;
-      def = false;
-    else
-      print_usage(func);
-    endif
-  otherwise
-    error ("invalid index for reference of class %s", class (inPar) );
-  endswitch
-
-  inPar = validate_args (method(4:end), inPar, name, val, def);
-
-endfunction
-
-## because we are nice we also support using the name of a function and not only
-## a function handle
-function val = validate_validator (val)
-  if ( ischar (val) )
-    val = str2func (val);
-  elseif ( !isa (val, 'function_handle') )
-    error ("validator must be a function handle or the name of a valid function");
-  end
-endfunction
-
-## to have a single function that handles them all, something must be done with
-## def value, because addRequire does not have those. That's why the order of
-## the last two args is different from the rest and why 'def' has a default value
-function inPar = validate_args (method, inPar, name, val, def = false)
-
-  if ( !strcmp (class (inPar), 'inputParser') )
-    error ("object must be of the inputParser class but '%s' was used", class (inPar) );
-  elseif ( !isvarname (name) )
-    error ("invalid variable name in argname");
-  endif
-
-  ## because the order arguments are specified are the order they are expected,
-  ## can't have ParamValue/Switch before Optional, and Optional before Required
-  n_optional  = numel (fieldnames (inPar.Optional));
-  n_params    = numel (fieldnames (inPar.ParamValue));
-  n_switch    = numel (fieldnames (inPar.Switch));
-  if     ( strcmp (method, 'Required') && ( n_optional || n_params || n_switch) )
-    error ("Can't specify 'Required' arguments after Optional, ParamValue or Switch");
-  elseif ( strcmp (method, 'Optional') && ( n_params || n_switch) )
-    error ("Can't specify 'Optional' arguments after ParamValue or Switch");
-  endif
-
-  ## even if CaseSensitive is turned on, we still shouldn't have two args with
-  ## the same. What if they decide to change in the middle of specifying them?
-  if ( any (strcmpi (inPar.Parameters, name)) )
-    error ("argname '%s' has already been specified", name);
-  else
-    inPar.Parameters = push (inPar.Parameters, name);
-    inPar.(method).(name).default = def;
-    inPar.(method).(name).validator = val;
-  endif
-
-  ## make sure that the given default value is actually valid
-  ## TODO make sure that when using the default, it's only validated once
-  if ( isa (val, 'function_handle') && !strcmpi (method, 'Required') && !feval (val, def) )
-    error ("default value for '%s' failed validation with '%s'", name, func2str (val) );
-  endif
-
-endfunction
-
-## this is just for consistency of error message
-function error_invalid (prefix, name, val)
-  error("%sargument '%s' failed validation %s", prefix, name, func2str (val));
-endfunction
-
-################################################################################
-## very auxiliary functions
-################################################################################
-
-function [out, in] = shift (in, idx = 1)
-  out     = in{idx};
-  in(idx) = [];
-endfunction
-
-function [in] = unshift (in, add)
-  if ( !iscell (add) )
-    add = {add};
-  endif
-  in (numel(add) + 1 : end + numel(add)) = in;
-  in (1:numel(add)) = add;
-endfunction
-
-function [in] = push (in, add)
-  if ( !iscell (add) )
-    add = {add};
-  endif
-  in( end+1 : end+numel(add) ) = add;
-endfunction
Index: main/general/inst/inputParser/@_inputParser_/_inputParser_.m
===================================================================
--- main/general/inst/inputParser/@_inputParser_/_inputParser_.m	(revision 12474)
+++ main/general/inst/inputParser/@_inputParser_/_inputParser_.m	(working copy)
@@ -67,7 +67,7 @@
 ## @example
 ## @group
 ## function check (pack, path, mat, varargin)
-##     p = inputParser;                             # create object
+##     p = _inputParser_;                             # create object
 ##     p.FunctionName = "check";                    # set function name
 ##     p = p.addRequired ("pack", @@ischar);         # create mandatory argument
 ##
@@ -125,7 +125,7 @@
 ## @@inputParser/createCopy, @@inputParser/parse}
 ## @end deftypefn
 
-function inPar = inputParser
+function inPar = _inputParser_
 
   if (nargin != 0)
     print_usage;
@@ -157,12 +157,12 @@
   inPar.Unmatched     = struct;
   inPar.UsingDefaults = {};
 
-  inPar = class (inPar, 'inputParser');
+  inPar = class (inPar, '_inputParser_');
 
 endfunction
 
 %!shared p, out
-%! p = inputParser;
+%! p = _inputParser_;
 %! p = p.addRequired   ("req1", @(x) ischar (x));
 %! p = p.addOptional   ("op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
 %! p = p.addOptional   ("op2", 78, @(x) (x) > 50);
@@ -200,7 +200,7 @@
 
 ## check alternative method (obj), ...) API
 %!shared p, out
-%! p = inputParser;
+%! p = _inputParser_;
 %! p = addRequired   (p, "req1", @(x) ischar (x));
 %! p = addOptional   (p, "op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
 %! p = addOptional   (p, "op2", 78, @(x) (x) > 50);
@@ -218,7 +218,7 @@
 
 ## if we were matlab compatible...
 %!shared p, out
-%! p = inputParser;
+%! p = _inputParser_;
 %! p = p.addOptional   ("op1", "val");
 %! p = p.addParamValue ("line", "tree");
 %!xtest assert (getfield (p.parse("line", "circle"), "Results"), struct ("op1", "val", "line", "circle"));
Index: main/general/inst/inputParser/@_inputParser_/subsref.m
===================================================================
--- main/general/inst/inputParser/@_inputParser_/subsref.m	(revision 12474)
+++ main/general/inst/inputParser/@_inputParser_/subsref.m	(working copy)
@@ -15,54 +15,31 @@
 
 function inPar = subsref (inPar, idx)
 
-  if ( !isa (inPar, 'inputParser') )
+  if ( !isa (inPar, '_inputParser_') )
     error ("object must be of the inputParser class but '%s' was used", class (inPar) );
   elseif ( idx(1).type != '.' )
     error ("invalid index for class %s", class (inPar) );
   endif
 
-  ## the following at the end may allow to use the obj.method notation one day
-  ## jwe is very against this ugly hack
-  ## what would happen if the user has the obj inside a struct? Bad things!
-#  ori = inputname(1);
-#  assignin('caller', ori, inPar);
-
   method = idx(1).subs;
 
   switch method
-  case 'Results'
-    inPar = retrieve_results (inPar, idx)
-  case 'Parameters'
-    inPar = inPar.Parameters;
   case 'parse'
     inPar = parse_args (inPar, idx);
-  case 'Unmatched'
-  case 'UsingDefaults'
+  case 'createCopy'
+    inPar = inPar;
   case {'addOptional', 'addParamValue', 'addRequired', 'addSwitch'}
     inPar = check_methods (inPar, idx);
   otherwise
-    error ("invalid index for reference of class %s", class (inPar) );
+    inPar = subsref(struct(inPar), idx);
+    return;
   endswitch
 
-  ## TODO we should make inPar an object of the inputParser class again. At
-  ## least after running parse it becomes just a structure again. While that is
-  ## bad, at least allows for easy access to the Results and Unmatched fields
-  ## without extra coding.
-#  inPar = class (inPar, 'inputParser');
+  inPar = class (inPar, '_inputParser_');
 
 endfunction
 
-function out = retrieve_results (inPar, idx)
 
-  if ( numel(idx) != 2 || idx(2).type != '.' )
-    print_usage ("@inputParser/Results");
-  endif
-
-  out = inPar.Results.(idx(2).subs);
-
-endfunction
-
-
 ## when parsing options, here's the principle: Required options have to be the
 ## first ones. They are followed by Optional if any. In the end come the
 ## ParamValue mixed with Switch. Any other order makes no sense
@@ -70,7 +47,7 @@
 
   ## syntax is inPar.parse (arguments)
   if ( numel(idx) != 2 || idx(2).type != '()' )
-    print_usage ("@inputParser/parse");
+    print_usage ("@_inputParser_/parse");
   endif
 
   ## this makes it easier to read but may be memory instensive
@@ -211,7 +188,7 @@
   ## this makes it easier to read but is more memory intensive?
   method  = idx(1).subs;
   args    = idx(2).subs;
-  func    = sprintf ("@inputParser/%s", method);
+  func    = sprintf ("@_inputParser_/%s", method);
 
   if ( idx(2).type != '()' )
     print_usage (func);
@@ -271,7 +248,7 @@
 ## the last two args is different from the rest and why 'def' has a default value
 function inPar = validate_args (method, inPar, name, val, def = false)
 
-  if ( !strcmp (class (inPar), 'inputParser') )
+  if ( !strcmp (class (inPar), '_inputParser_') )
     error ("object must be of the inputParser class but '%s' was used", class (inPar) );
   elseif ( !isvarname (name) )
     error ("invalid variable name in argname");
Index: main/general/inst/inputParser/@_inputParser_
===================================================================
--- main/general/inst/inputParser/@_inputParser_	(revision 0)
+++ main/general/inst/inputParser/@_inputParser_	(working copy)

Property changes on: main/general/inst/inputParser/@_inputParser_
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,7 ##
+*.oct
+*.octlink
+octave-core
+autom4te.cache
+configure
+*.pdf
+*.tar.gz
Index: main/general/inst/inputParser/@inputParser/display.m
===================================================================
--- main/general/inst/inputParser/@inputParser/display.m	(revision 12474)
+++ main/general/inst/inputParser/@inputParser/display.m	(working copy)
@@ -15,44 +15,8 @@
 
 function display (inPar)
 
-  if (inPar.FunctionName)
-    name = inPar.FunctionName(1:end-3);
-  else
-    name = "";
-  endif
+  _inPar_ = _inputParserStore_ ('pull', inPar.counter);
+  display (_inPar_)
 
-  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
Index: main/general/inst/inputParser/@inputParser/inputParser.m
===================================================================
--- main/general/inst/inputParser/@inputParser/inputParser.m	(revision 12474)
+++ main/general/inst/inputParser/@inputParser/inputParser.m	(working copy)
@@ -69,24 +69,24 @@
 ## function check (pack, path, mat, varargin)
 ##     p = inputParser;                             # create object
 ##     p.FunctionName = "check";                    # set function name
-##     p = p.addRequired ("pack", @@ischar);         # create mandatory argument
+##     p.addRequired ("pack", @@ischar);         # create mandatory argument
 ##
-##     p = p.addOptional ("path", pwd(), @@ischar);  # create optional argument
+##     p.addOptional ("path", pwd(), @@ischar);  # create optional argument
 ##
 ##     ## one can create a function handle to anonymous functions for validators
 ##     val_mat = @@(x)isvector(x) && all( x <= 1) && all(x >= 0);
-##     p = p.addOptional ("mat", [0 0], val_mat);
+##     p.addOptional ("mat", [0 0], val_mat);
 ##
 ##     ## create two ParamValue type of arguments
 ##     val_type = @@(x) ischar(x) && any(strcmp(x, @{"linear", "quadratic"@});
-##     p = p.addParamValue ("type", "linear", @@val_type);
+##     p.addParamValue ("type", "linear", @@val_type);
 ##     val_verb = @@(x) ischar(x) && any(strcmp(x, @{"low", "medium", "high"@});
-##     p = p.addParamValue ("tolerance", "low", @@val_verb);
+##     p.addParamValue ("tolerance", "low", @@val_verb);
 ##
 ##     ## create a switch type of argument
-##     p = p.addSwitch ("verbose");
+##     p.addSwitch ("verbose");
 ##
-##     p = p.parse (pack, path, mat, varargin@{:@});
+##     p.parse (pack, path, mat, varargin@{:@});
 ##
 ##     ## the rest of the function can access the input by accessing p.Results
 ##     ## for example, to access the value of tolerance, use p.Results.tolerance
@@ -125,49 +125,24 @@
 ## @@inputParser/createCopy, @@inputParser/parse}
 ## @end deftypefn
 
-function inPar = inputParser
-
-  if (nargin != 0)
-    print_usage;
-  endif
-
-  inPar = struct;
-
-  ## these are not to be accessed by users. Each will have a field whose names
-  ## are the argnames which will also be a struct with fieldnames 'validator'
-  ## and 'default'
-  inPar.ParamValue    = struct;
-  inPar.Optional      = struct;
-  inPar.Required      = struct;
-  inPar.Switch        = struct;
-
-  ## this will be filled when the methodd parse is used and will be a struct whose
-  ## fieldnames are the argnames that return their value
-  inPar.Results       = struct;
-
-  ## an 1xN cell array with argnames. It is read only by the user and its order
-  ## showws the order that they were added to the object (which is the order they
-  ## will be expected)
-  inPar.Parameters    = {};
-
-  inPar.CaseSensitive = false;
-  inPar.FunctionName  = '';      # name of the function for the error message
-  inPar.KeepUnmatched = false;
-  inPar.StructExpand  = true;
-  inPar.Unmatched     = struct;
-  inPar.UsingDefaults = {};
-
+function inPar = inputParser (varargin)
+  #mlock()
+  persistent counter = 1;
+  #counter # DEBUG
+  _inPar_ = _inputParser_ (varargin{:});
+  _inputParserStore_ ('push', counter, _inPar_);
+  inPar = struct('counter',counter);
   inPar = class (inPar, 'inputParser');
-
+  counter = counter + 1;
 endfunction
 
 %!shared p, out
 %! p = inputParser;
-%! p = p.addRequired   ("req1", @(x) ischar (x));
-%! p = p.addOptional   ("op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
-%! p = p.addOptional   ("op2", 78, @(x) (x) > 50);
-%! p = p.addSwitch     ("verbose");
-%! p = p.addParamValue ("line", "tree", @(x) ischar (x) && any (strcmp (x, {"tree", "circle"})));
+%! p.addRequired   ("req1", @(x) ischar (x));
+%! p.addOptional   ("op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
+%! p.addOptional   ("op2", 78, @(x) (x) > 50);
+%! p.addSwitch     ("verbose");
+%! p.addParamValue ("line", "tree", @(x) ischar (x) && any (strcmp (x, {"tree", "circle"})));
 %! ## check normal use, only required are given
 %! out = p.parse ("file");
 %!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
@@ -201,11 +176,11 @@
 ## check alternative method (obj), ...) API
 %!shared p, out
 %! p = inputParser;
-%! p = addRequired   (p, "req1", @(x) ischar (x));
-%! p = addOptional   (p, "op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
-%! p = addOptional   (p, "op2", 78, @(x) (x) > 50);
-%! p = addSwitch     (p, "verbose");
-%! p = addParamValue (p, "line", "tree", @(x) ischar (x) && any (strcmp (x, {"tree", "circle"})));
+%! addRequired   (p, "req1", @(x) ischar (x));
+%! addOptional   (p, "op1", "val", @(x) ischar (x) && any (strcmp (x, {"val", "foo"})));
+%! addOptional   (p, "op2", 78, @(x) (x) > 50);
+%! addSwitch     (p, "verbose");
+%! addParamValue (p, "line", "tree", @(x) ischar (x) && any (strcmp (x, {"tree", "circle"})));
 %! ## check normal use, only required are given
 %! out = parse (p, "file");
 %!assert ({out.Results.req1, out.Results.op1, out.Results.op2, out.Results.verbose, out.Results.line}, 
@@ -219,6 +194,7 @@
 ## if we were matlab compatible...
 %!shared p, out
 %! p = inputParser;
-%! p = p.addOptional   ("op1", "val");
-%! p = p.addParamValue ("line", "tree");
+%! p.addOptional   ("op1", "val");
+%! p.addParamValue ("line", "tree");
 %!xtest assert (getfield (p.parse("line", "circle"), "Results"), struct ("op1", "val", "line", "circle"));
+
Index: main/general/inst/inputParser/@inputParser/subsasgn.m
===================================================================
--- main/general/inst/inputParser/@inputParser/subsasgn.m	(revision 12474)
+++ main/general/inst/inputParser/@inputParser/subsasgn.m	(working copy)
@@ -15,23 +15,10 @@
 
 function inPar = subsasgn (inPar, idx, rhs)
 
-  if ( idx.type != '.' )
-    error ("invalid index for class %s", class (inPar) );
-  endif
+  _inPar_ = _inputParserStore_ ('pull', inPar.counter);
 
-  switch idx.subs
-    case {'CaseSensitive', 'KeepUnmatched', 'StructExpand'}
-      if ( !islogical (rhs) )
-        error("Property '%s' of the class inputParser must be logical", idx.subs)
-      endif
-      inPar.(idx.subs) = rhs;
-    case 'FunctionName'
-      if ( !ischar (rhs) )
-        error("Property 'FunctionName' of the class inputParser can only be set to a string")
-      endif
-      inPar.(idx.subs) = sprintf("%s : ", rhs);
-    otherwise
-      error ("invalid index for assignment of class %s", class (inPar) );
-  endswitch
+  _inPar_ = subsasgn (_inPar_, idx, rhs);
 
+  _inputParserStore_ ('push', inPar.counter, _inPar_);
+
 endfunction
Index: main/general/inst/inputParser/@inputParser/subsref.m
===================================================================
--- main/general/inst/inputParser/@inputParser/subsref.m	(revision 12474)
+++ main/general/inst/inputParser/@inputParser/subsref.m	(working copy)
@@ -15,322 +15,26 @@
 
 function inPar = subsref (inPar, idx)
 
-  if ( !isa (inPar, 'inputParser') )
-    error ("object must be of the inputParser class but '%s' was used", class (inPar) );
-  elseif ( idx(1).type != '.' )
-    error ("invalid index for class %s", class (inPar) );
-  endif
+  _inPar_ = _inputParserStore_ ('pull', inPar.counter);
 
-  ## the following at the end may allow to use the obj.method notation one day
-  ## jwe is very against this ugly hack
-  ## what would happen if the user has the obj inside a struct? Bad things!
-#  ori = inputname(1);
-#  assignin('caller', ori, inPar);
+  _inPar_ = subsref (_inPar_, idx);
 
-  method = idx(1).subs;
-
-  switch method
-  case 'Results'
-    inPar = retrieve_results (inPar, idx)
-  case 'Parameters'
-    inPar = inPar.Parameters;
-  case 'parse'
-    inPar = parse_args (inPar, idx);
-  case 'Unmatched'
-  case 'UsingDefaults'
-  case {'addOptional', 'addParamValue', 'addRequired', 'addSwitch'}
-    inPar = check_methods (inPar, idx);
-  otherwise
-    error ("invalid index for reference of class %s", class (inPar) );
-  endswitch
-
-  ## TODO we should make inPar an object of the inputParser class again. At
-  ## least after running parse it becomes just a structure again. While that is
-  ## bad, at least allows for easy access to the Results and Unmatched fields
-  ## without extra coding.
-#  inPar = class (inPar, 'inputParser');
-
-endfunction
-
-function out = retrieve_results (inPar, idx)
-
-  if ( numel(idx) != 2 || idx(2).type != '.' )
-    print_usage ("@inputParser/Results");
+  if ~isa(_inPar_, '_inputParser_')
+    inPar = _inPar_;
+    return;
   endif
 
-  out = inPar.Results.(idx(2).subs);
-
-endfunction
-
-
-## when parsing options, here's the principle: Required options have to be the
-## first ones. They are followed by Optional if any. In the end come the
-## ParamValue mixed with Switch. Any other order makes no sense
-function inPar = parse_args (inPar, idx)
-
-  ## syntax is inPar.parse (arguments)
-  if ( numel(idx) != 2 || idx(2).type != '()' )
-    print_usage ("@inputParser/parse");
-  endif
-
-  ## this makes it easier to read but may be memory instensive
-  args = idx(2).subs;
-
-  ## make copy of ordered list of Parameters to keep the original intact and readable
-  inPar.copy = inPar.Parameters;
-
-  if ( numel (fieldnames (inPar.Required)) > numel (args) )
-    error("%sNot enough arguments", inPar.FunctionName);
-  endif
-
-  ## we take names out of 'copy' and values out of 'args', evaluate them and
-  ## store them into 'Results'
-  for i = 1 : numel (fieldnames (inPar.Required))
-    [name, inPar.copy] = shift (inPar.copy);
-    [value, args]      = shift (args);
-    if ( !feval (inPar.Required.(name).validator, value) )
-      error_invalid (inPar.FunctionName, name, inPar.Required.(name).validator);
-    endif
-    inPar.Results.(name) = value;
-  endfor
-
-  ## loop a maximum #times of the number of Optional, similarly to the required
-  ## loop. Once ran out of 'args', move their name into usingDefaults, place
-  ## their default values into 'Results', and break
-
-  ## because if an argument is string and does not validate, should be considered
-  ## a ParamValue key
-  found_possible_key = false;
-
-  for i = 1 : numel (fieldnames (inPar.Optional))
-    if ( !numel (args) || found_possible_key)
-      ## loops the number of Optional options minus the number of them already processed
-      for n = 1 : (numel (fieldnames (inPar.Optional)) - i + 1 )
-        [name, inPar.copy]   = shift (inPar.copy);
-        inPar.UsingDefaults  = push (inPar.UsingDefaults, name);
-        inPar.Results.(name) = inPar.Optional.(name).default;
-      endfor
-      break
-    endif
-    [name, inPar.copy] = shift (inPar.copy);
-    [value, args]      = shift (args);
-    if ( !feval (inPar.Optional.(name).validator, value) )
-      if (ischar (value) )
-        ## maybe the other optional are not defined, this can be Paramvalue
-        ## place this one on defaults and go back to the top with note to clean loop
-        inPar.UsingDefaults  = push (inPar.UsingDefaults, name);
-        inPar.Results.(name) = inPar.Optional.(name).default;
-        found_possible_key   = true;
-        args = unshift (args, value);
-        continue
-      else
-        error_invalid (inPar.FunctionName, name, inPar.Optional.(name).validator);
-      endif
-    else
-      inPar.Results.(name) = value;
-    endif
-  endfor
-
-  ## loop a maximum #times of the number of ParamValue, taking pairs of keys and
-  ## values out 'args'. We no longer expect an order so we need the index in
-  ## 'copy' to remove it from there. Once ran out of 'args', move their name
-  ## into usingDefaults, place their default values into 'Results', and break
-  for i = 1 : (numel (fieldnames (inPar.ParamValue)) + numel (fieldnames (inPar.Switch)))
-    if ( !numel (args) )
-      ## loops the number of times left in 'copy' since these are the last type
-      for n = 1 : numel (inPar.copy)
-        [name, inPar.copy]   = shift (inPar.copy);
-        inPar.UsingDefaults  = push (inPar.UsingDefaults, name);
-        if (isfield (inPar.ParamValue, name))
-          inPar.Results.(name) = inPar.ParamValue.(name).default;
-        else
-          inPar.Results.(name) = inPar.Switch.(name).default;
-        endif
-      endfor
-      break
-    endif
-    [key, args] = shift (args);
-    if ( !ischar (key) )
-      error("%sParameter/Switch names must be strings", inPar.FunctionName);
-    endif
-    if (inPar.CaseSensitive)
-      index = find( strcmp(inPar.copy, key));
-    else
-      index = find( strcmpi(inPar.copy, key));
-    endif
-    ## we can't use isfield here to support case insensitive
-    if (any (strcmpi (fieldnames (inPar.Switch), key)))
-      value  = true;
-      method = "Switch";
-    else
-      ## then it must be a ParamValue (even if unmatched), shift its value
-      if (numel (args) < 1)
-        error ("%sparameter '%s' does not have a value", inPar.FunctionName, key);
-      endif
-      [value, args] = shift (args);
-      method = "ParamValue";
-    endif
-
-    ## empty index means no match so either return error or move them into 'Unmatched'
-    if (!isempty (index))
-      [name, inPar.copy] = shift (inPar.copy, index);
-      if ( !feval (inPar.(method).(name).validator, value))
-        error_invalid (inPar.FunctionName, key, inPar.(method).(name).validator);
-      endif
-      ## we use the name shifted from 'copy' instead of the key from 'args' in case
-      ## the key is in the wrong case
-      inPar.Results.(name) = value;
-    elseif (isempty (index) && inPar.KeepUnmatched )
-      inPar.Unmatched.(key) = value;
-      i = i - 1; # this time didn't count, go back one
-    else
-      error ("%sargument '%s' did not match any valid parameter of the parser", inPar.FunctionName, key);
-    endif
-  endfor
-
-  ## if there's leftovers they must be unmatched. Note that some unmatched can
-  ## have already been processed in the ParamValue loop
-  if ( numel (args) && inPar.KeepUnmatched )
-    for i = 1 : ( numel(args) / 2 )
-      [key, args]           = shift (args);
-      [value, args]         = shift (args);
-      inPar.Unmatched.(key) = value;
-    endfor
-  elseif ( numel (args) )
-    error("%sfound unmatched parameters at end of arguments list", inPar.FunctionName);
-  endif
-
-  ## remove copied field, keep it clean
-  inPar = rmfield (inPar, 'copy');
-
-endfunction
-
-
-function inPar = check_methods (inPar, idx)
-
-  ## this makes it easier to read but is more memory intensive?
-  method  = idx(1).subs;
-  args    = idx(2).subs;
-  func    = sprintf ("@inputParser/%s", method);
-
-  if ( idx(2).type != '()' )
-    print_usage (func);
-  endif
-  def_val      = @() true;
-  [name, args] = shift (args);
-  ## a validator is optional but that complicates handling all the parsing with
-  ## few functions and conditions. If not specified @() true will always return
-  ## true. Simply using true is not enough because if the argument is zero it
-  ## return false and if it's too large, takes up memory
-  switch method
-  case {'addOptional', 'addParamValue'}
-    if     ( numel (args) == 1 )
-      args{2} = def_val;
-    elseif ( numel (args) == 2 )
-      args{2} = validate_validator (args{2});
-    else
-      print_usage(func);
-    endif
-    [def, val] = args{:};
-  case {'addRequired'}
-    if     ( numel (args) == 0 )
-      val = def_val;
-    elseif ( numel (args) == 1 )
-      val = validate_validator (args{1});
-    else
-      print_usage(func);
-    endif
-    def = false;
-  case {'addSwitch'}
-    if ( numel (args) == 0 )
-      val = def_val;
-      def = false;
-    else
-      print_usage(func);
-    endif
-  otherwise
-    error ("invalid index for reference of class %s", class (inPar) );
-  endswitch
-
-  inPar = validate_args (method(4:end), inPar, name, val, def);
-
-endfunction
-
-## because we are nice we also support using the name of a function and not only
-## a function handle
-function val = validate_validator (val)
-  if ( ischar (val) )
-    val = str2func (val);
-  elseif ( !isa (val, 'function_handle') )
-    error ("validator must be a function handle or the name of a valid function");
-  end
-endfunction
-
-## to have a single function that handles them all, something must be done with
-## def value, because addRequire does not have those. That's why the order of
-## the last two args is different from the rest and why 'def' has a default value
-function inPar = validate_args (method, inPar, name, val, def = false)
-
-  if ( !strcmp (class (inPar), 'inputParser') )
-    error ("object must be of the inputParser class but '%s' was used", class (inPar) );
-  elseif ( !isvarname (name) )
-    error ("invalid variable name in argname");
-  endif
-
-  ## because the order arguments are specified are the order they are expected,
-  ## can't have ParamValue/Switch before Optional, and Optional before Required
-  n_optional  = numel (fieldnames (inPar.Optional));
-  n_params    = numel (fieldnames (inPar.ParamValue));
-  n_switch    = numel (fieldnames (inPar.Switch));
-  if     ( strcmp (method, 'Required') && ( n_optional || n_params || n_switch) )
-    error ("Can't specify 'Required' arguments after Optional, ParamValue or Switch");
-  elseif ( strcmp (method, 'Optional') && ( n_params || n_switch) )
-    error ("Can't specify 'Optional' arguments after ParamValue or Switch");
-  endif
-
-  ## even if CaseSensitive is turned on, we still shouldn't have two args with
-  ## the same. What if they decide to change in the middle of specifying them?
-  if ( any (strcmpi (inPar.Parameters, name)) )
-    error ("argname '%s' has already been specified", name);
+  method = idx(1).subs;
+  if strcmpi(method, 'createCopy')
+    counter = getfield(inputParser(), 'counter');
   else
-    inPar.Parameters = push (inPar.Parameters, name);
-    inPar.(method).(name).default = def;
-    inPar.(method).(name).validator = val;
+    counter = inPar.counter;
   endif
+  
+  _inputParserStore_ ('push', counter, _inPar_);
 
-  ## make sure that the given default value is actually valid
-  ## TODO make sure that when using the default, it's only validated once
-  if ( isa (val, 'function_handle') && !strcmpi (method, 'Required') && !feval (val, def) )
-    error ("default value for '%s' failed validation with '%s'", name, func2str (val) );
-  endif
-
+  inPar = struct('counter',counter);
+  inPar = class (inPar, 'inputParser');
+  
 endfunction
 
-## this is just for consistency of error message
-function error_invalid (prefix, name, val)
-  error("%sargument '%s' failed validation %s", prefix, name, func2str (val));
-endfunction
-
-################################################################################
-## very auxiliary functions
-################################################################################
-
-function [out, in] = shift (in, idx = 1)
-  out     = in{idx};
-  in(idx) = [];
-endfunction
-
-function [in] = unshift (in, add)
-  if ( !iscell (add) )
-    add = {add};
-  endif
-  in (numel(add) + 1 : end + numel(add)) = in;
-  in (1:numel(add)) = add;
-endfunction
-
-function [in] = push (in, add)
-  if ( !iscell (add) )
-    add = {add};
-  endif
-  in( end+1 : end+numel(add) ) = add;
-endfunction
Index: main/general/inst/inputParser/@inputParser
===================================================================
--- main/general/inst/inputParser/@inputParser	(revision 0)
+++ main/general/inst/inputParser/@inputParser	(working copy)

Property changes on: main/general/inst/inputParser/@inputParser
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,7 ##
+*.oct
+*.octlink
+octave-core
+autom4te.cache
+configure
+*.pdf
+*.tar.gz
Index: main/general/inst/inputParser/common/_inputParserStore_.m
===================================================================
--- main/general/inst/inputParser/common/_inputParserStore_.m	(revision 0)
+++ main/general/inst/inputParser/common/_inputParserStore_.m	(working copy)
@@ -0,0 +1,11 @@
+function out = _inputParserStore_ (command, counter, in)
+  #mlock()
+  persistent temp = {};
+  #counter
+  #temp
+  switch command
+  case 'push',  temp{counter} = in;
+  case 'pull',  out = temp{counter};
+  endswitch
+endfunction
+
