report.m 2.04 KB
Newer Older
Houtan Bastani's avatar
Houtan Bastani committed
1
2
function o = report(varargin)
%function o = report(varargin)
Houtan Bastani's avatar
Houtan Bastani committed
3
4
5
% Report Class Constructor
%
% INPUTS
Houtan Bastani's avatar
Houtan Bastani committed
6
7
%   1 report class object => make a copy
%   Otherwise, option/value pairs (see structure below for options)
Houtan Bastani's avatar
Houtan Bastani committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%
% OUTPUTS
%   none
%
% 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
Houtan Bastani's avatar
Houtan Bastani committed
33
34
35
36
o = struct;
o.title = '';
o.orientation = 'portrait';
o.paper = 'a4';
Houtan Bastani's avatar
Houtan Bastani committed
37
o.margin = '2.5cm';
Houtan Bastani's avatar
Houtan Bastani committed
38
39
40
o.pages = pages();
o.filename = 'report.tex';
o.config = '';
Houtan Bastani's avatar
Houtan Bastani committed
41
o.showdate = true;
Houtan Bastani's avatar
Houtan Bastani committed
42
43

if nargin == 1
44
    assert(isa(varargin{1}, 'report'), ['@report.report: with one arg, ' ...
Houtan Bastani's avatar
Houtan Bastani committed
45
46
47
48
49
                        'you must pass a report object']);
    r = varargin{1};
    return;
elseif nargin > 1
    if round(nargin/2) ~= nargin/2
50
51
        error(['@report.report: options must be supplied in name/value ' ...
               'pairs']);
Houtan Bastani's avatar
Houtan Bastani committed
52
53
    end

Houtan Bastani's avatar
Houtan Bastani committed
54
55
56
57
58
59
60
61
62
63
64
65
    optNames = lower(fieldnames(o));

    % overwrite default values
    for pair = reshape(varargin, 2, [])
        field = lower(pair{1});
        if any(strmatch(field, optNames, 'exact'))
            if strcmp(field, 'orientation')
                validateOrientation(pair{2});
            elseif strcmp(field, 'paper')
                validatePaper(pair{2});
            end
            o.(field) = pair{2};
Houtan Bastani's avatar
Houtan Bastani committed
66
        else
67
            error('@report.report: %s is not a recognized option.', ...
Houtan Bastani's avatar
Houtan Bastani committed
68
                  field);
Houtan Bastani's avatar
Houtan Bastani committed
69
        end
Houtan Bastani's avatar
Houtan Bastani committed
70
    end
Houtan Bastani's avatar
Houtan Bastani committed
71
72
73
end

% Create report object
Houtan Bastani's avatar
Houtan Bastani committed
74
o = class(o, 'report');
Houtan Bastani's avatar
Houtan Bastani committed
75
end