annotate scripts/set/private/validargs.m @ 11523:fd0a3ac60b0e

update copyright notices
author John W. Eaton <jwe@octave.org>
date Fri, 14 Jan 2011 05:47:45 -0500
parents 5edee330d4cb
children c792872f8942
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10088
diff changeset
1 ## Copyright (C) 2000-2011 Paul Kienzle
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 10088
diff changeset
2 ## Copyright (C) 2009-2010 Jaroslav Hajek
10088
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
3 ##
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
4 ## This file is part of Octave.
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
5 ##
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
6 ## Octave is free software; you can redistribute it and/or modify it
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
7 ## under the terms of the GNU General Public License as published by
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
8 ## the Free Software Foundation; either version 3 of the License, or (at
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
9 ## your option) any later version.
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
10 ##
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
11 ## Octave is distributed in the hope that it will be useful, but
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
12 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
14 ## General Public License for more details.
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
15 ##
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
16 ## You should have received a copy of the GNU General Public License
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
17 ## along with Octave; see the file COPYING. If not, see
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
18 ## <http://www.gnu.org/licenses/>.
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
19
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
20 ## Validate arguments for binary set operation.
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
21 function [x, y] = validargs (caller, x, y, byrows_arg)
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
22
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
23 if (nargin == 3)
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
24 icx = iscellstr (x);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
25 icy = iscellstr (y);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
26 if (icx || icy)
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
27 if (icx && ischar (y))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
28 y = cellstr (y);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
29 elseif (icy && ischar (x))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
30 x = cellstr (x);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
31 elseif (! (icx && icy))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
32 error ("%s: cell array of strings cannot be combined with a nonstring value", caller);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
33 endif
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
34 elseif (! (ismatrix (x) && ismatrix (y)))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 error ("%s: input arguments must be arrays or cell arrays of strings", caller);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36 endif
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
37 elseif (nargin == 4)
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38 if (strcmpi (byrows_arg, "rows"))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
39 if (iscell (x) || iscell (y))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
40 error ("%s: cells not supported with ""rows""");
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
41 elseif (! (ismatrix (x) && ismatrix (y)))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
42 error ("%s: input arguments must be arrays or cell arrays of strings", caller);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43 else
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44 if (ndims (x) > 2 || ndims (y) > 2)
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45 error ("%s: need 2-dimensional matrices for ""rows""", caller);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 elseif (columns (x) != columns (y) && ! (isempty (x) || isempty (y)))
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47 error ("%s: number of columns must match", caller);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
48 endif
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
49 endif
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50 else
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51 error ("%s: invalid option: %s", caller, byrows_arg);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
52 endif
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
53 else
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 print_usage (caller);
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55 endif
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56
5edee330d4cb better argument checking and handling in set functions
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57 endfunction