2013-02-15 16:52:35 +01:00
|
|
|
function o = report(varargin)
|
|
|
|
%function o = report(varargin)
|
2013-02-12 14:23:41 +01:00
|
|
|
% Report Class Constructor
|
|
|
|
%
|
|
|
|
% INPUTS
|
2013-03-13 18:02:29 +01:00
|
|
|
% varargin 0 args : empty report object
|
|
|
|
% 1 arg : must be report object (return a copy of arg)
|
|
|
|
% > 1 args: option/value pairs (see structure below for options)
|
2013-02-12 14:23:41 +01:00
|
|
|
%
|
|
|
|
% OUTPUTS
|
2013-03-13 18:02:29 +01:00
|
|
|
% o [report] report object
|
2013-02-12 14:23:41 +01:00
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS
|
|
|
|
% none
|
|
|
|
|
|
|
|
% Copyright (C) 2013 Dynare Team
|
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare 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.
|
|
|
|
%
|
|
|
|
% Dynare 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 Dynare. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
% default values
|
2013-02-15 16:52:35 +01:00
|
|
|
o = struct;
|
|
|
|
o.title = '';
|
|
|
|
o.orientation = 'portrait';
|
|
|
|
o.paper = 'a4';
|
2013-03-15 17:03:50 +01:00
|
|
|
o.margin = 2.5;
|
2013-05-13 17:06:48 +02:00
|
|
|
o.marginUnit = 'cm';
|
2013-02-15 16:52:35 +01:00
|
|
|
o.pages = pages();
|
|
|
|
o.filename = 'report.tex';
|
2013-05-13 16:28:02 +02:00
|
|
|
o.showDate = true;
|
2013-04-10 18:08:14 +02:00
|
|
|
o.compiler = '';
|
2013-02-12 14:23:41 +01:00
|
|
|
|
|
|
|
if nargin == 1
|
2013-03-08 19:25:24 +01:00
|
|
|
assert(isa(varargin{1}, 'report'), ['@report.report: with one arg, ' ...
|
2013-02-15 16:52:35 +01:00
|
|
|
'you must pass a report object']);
|
|
|
|
r = varargin{1};
|
|
|
|
return;
|
|
|
|
elseif nargin > 1
|
|
|
|
if round(nargin/2) ~= nargin/2
|
2013-03-08 19:25:24 +01:00
|
|
|
error(['@report.report: options must be supplied in name/value ' ...
|
|
|
|
'pairs']);
|
2013-02-12 14:23:41 +01:00
|
|
|
end
|
|
|
|
|
2013-05-13 17:47:11 +02:00
|
|
|
optNames = fieldnames(o);
|
2013-02-15 16:52:35 +01:00
|
|
|
|
|
|
|
% overwrite default values
|
|
|
|
for pair = reshape(varargin, 2, [])
|
2013-05-14 17:22:24 +02:00
|
|
|
ind = strmatch(lower(pair{1}), lower(optNames), 'exact');
|
2013-05-13 17:47:11 +02:00
|
|
|
assert(isempty(ind) || length(ind) == 1);
|
|
|
|
if ~isempty(ind)
|
|
|
|
o.(optNames{ind}) = pair{2};
|
2013-02-12 14:23:41 +01:00
|
|
|
else
|
2013-05-14 17:22:24 +02:00
|
|
|
error('@report.report: %s is not a recognized option.', pair{1});
|
2013-02-12 14:23:41 +01:00
|
|
|
end
|
2013-02-15 16:52:35 +01:00
|
|
|
end
|
2013-02-12 14:23:41 +01:00
|
|
|
end
|
|
|
|
|
2013-03-15 17:03:50 +01:00
|
|
|
% Check options provided by user
|
|
|
|
assert(ischar(o.title), '@report.report: title must be a string');
|
|
|
|
assert(ischar(o.filename), '@report.report: filename must be a string');
|
2013-04-10 18:08:14 +02:00
|
|
|
assert(ischar(o.compiler), '@report.report: compiler file must be a string');
|
2013-05-13 16:28:02 +02:00
|
|
|
assert(islogical(o.showDate), '@report.report: showDate must be either true or false');
|
2013-03-15 17:03:50 +01:00
|
|
|
assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
|
|
|
|
|
|
|
|
valid_margin_unit = {'cm', 'in'};
|
2013-05-13 17:06:48 +02:00
|
|
|
assert(any(strcmp(o.marginUnit, valid_margin_unit)), ...
|
|
|
|
['@report.report: marginUnit must be one of ' strjoin(valid_margin_unit, ' ')]);
|
2013-03-15 17:03:50 +01:00
|
|
|
|
|
|
|
valid_paper = {'a4', 'letter'};
|
|
|
|
assert(any(strcmp(o.paper, valid_paper)), ...
|
|
|
|
['@report.report: paper must be one of ' strjoin(valid_paper, ' ')]);
|
|
|
|
|
|
|
|
valid_orientation = {'portrait', 'landscape'};
|
|
|
|
assert(any(strcmp(o.orientation, valid_orientation)), ...
|
|
|
|
['@report.report: orientation must be one of ' strjoin(valid_orientation, ' ')]);
|
|
|
|
|
2013-02-12 14:23:41 +01:00
|
|
|
% Create report object
|
2013-02-15 16:52:35 +01:00
|
|
|
o = class(o, 'report');
|
2013-02-12 14:23:41 +01:00
|
|
|
end
|