reporting: preserve case when assigning method options while allowing user to enter any case

time-shift
Houtan Bastani 2013-05-13 17:47:11 +02:00
parent 333d515fe9
commit f03bf0a615
7 changed files with 35 additions and 21 deletions

View File

@ -73,13 +73,15 @@ elseif nargin > 1
'pairs.']); 'pairs.']);
end end
optNames = lower(fieldnames(o)); optNames = fieldnames(o);
% overwrite default values % overwrite default values
for pair = reshape(varargin, 2, []) for pair = reshape(varargin, 2, [])
field = lower(pair{1}); field = lower(pair{1});
if any(strmatch(field, optNames, 'exact')) ind = strmatch(field, lower(optNames), 'exact');
o.(field) = pair{2}; assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else else
error('@graph.graph: %s is not a recognized option.', field); error('@graph.graph: %s is not a recognized option.', field);
end end

View File

@ -48,13 +48,15 @@ elseif nargin > 1
'pairs.']); 'pairs.']);
end end
optNames = lower(fieldnames(o)); optNames = fieldnames(o);
% overwrite default values % overwrite default values
for pair = reshape(varargin, 2, []) for pair = reshape(varargin, 2, [])
field = lower(pair{1}); field = lower(pair{1});
if any(strmatch(field, optNames, 'exact')) ind = strmatch(field, lower(optNames), 'exact');
o.(field) = pair{2}; assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else else
error('@page.page: %s is not a recognized option.', field); error('@page.page: %s is not a recognized option.', field);
end end

View File

@ -54,13 +54,15 @@ elseif nargin > 1
'pairs']); 'pairs']);
end end
optNames = lower(fieldnames(o)); optNames = fieldnames(o);
% overwrite default values % overwrite default values
for pair = reshape(varargin, 2, []) for pair = reshape(varargin, 2, [])
field = lower(pair{1}); field = lower(pair{1});
if any(strmatch(field, optNames, 'exact')) ind = strmatch(field, lower(optNames), 'exact');
o.(field) = pair{2}; assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else else
error('@report.report: %s is not a recognized option.', ... error('@report.report: %s is not a recognized option.', ...
field); field);

View File

@ -36,13 +36,15 @@ elseif nargin > 1
'pairs.']); 'pairs.']);
end end
optNames = lower(fieldnames(o)); optNames = fieldnames(o);
% overwrite default values % overwrite default values
for pair = reshape(varargin, 2, []) for pair = reshape(varargin, 2, [])
field = lower(pair{1}); field = lower(pair{1});
if any(strmatch(field, optNames, 'exact')) ind = strmatch(field, lower(optNames), 'exact');
o.(field) = pair{2}; assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else else
error('@section.section: %s is not a recognized option.', ... error('@section.section: %s is not a recognized option.', ...
field); field);

View File

@ -61,13 +61,15 @@ elseif nargin > 1
'pairs.']); 'pairs.']);
end end
optNames = lower(fieldnames(o)); optNames = fieldnames(o);
% overwrite default values % overwrite default values
for pair = reshape(varargin, 2, []) for pair = reshape(varargin, 2, [])
field = lower(pair{1}); field = lower(pair{1});
if any(strmatch(field, optNames, 'exact')) ind = strmatch(field, lower(optNames), 'exact');
o.(field) = pair{2}; assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else else
error('@series.series: %s is not a recognized option.', field); error('@series.series: %s is not a recognized option.', field);
end end

View File

@ -58,13 +58,15 @@ elseif nargin > 1
'pairs.']); 'pairs.']);
end end
optNames = lower(fieldnames(o)); optNames = fieldnames(o);
% overwrite default values % overwrite default values
for pair = reshape(varargin, 2, []) for pair = reshape(varargin, 2, [])
field = lower(pair{1}); field = lower(pair{1});
if any(strmatch(field, optNames, 'exact')) ind = strmatch(field, lower(optNames), 'exact');
o.(field) = pair{2}; assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else else
error('%s is not a recognized option to the Table constructor.', ... error('%s is not a recognized option to the Table constructor.', ...
field); field);

View File

@ -44,13 +44,15 @@ elseif nargin > 1
'pairs.']); 'pairs.']);
end end
optNames = lower(fieldnames(o)); optNames = fieldnames(o);
% overwrite default values % overwrite default values
for pair = reshape(varargin, 2, []) for pair = reshape(varargin, 2, [])
field = lower(pair{1}); field = lower(pair{1});
if any(strmatch(field, optNames, 'exact')) ind = strmatch(field, lower(optNames), 'exact');
o.(field) = pair{2}; assert(isempty(ind) || length(ind) == 1);
if ~isempty(ind)
o.(optNames{ind}) = pair{2};
else else
error('@vspace.vspace: %s is not a recognized option.', field); error('@vspace.vspace: %s is not a recognized option.', field);
end end