2019-08-27 17:38:20 +02:00
classdef report < handle
% report Class
%
2022-04-15 14:16:13 +02:00
% Copyright © 2013-2022 Dynare Team
2019-08-27 17:38:20 +02:00
%
% 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
2021-06-09 17:15:17 +02:00
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
2019-08-27 17:38:20 +02:00
properties ( Access = private )
pages = { }
2013-02-12 14:23:41 +01:00
end
2019-08-27 17:38:20 +02:00
properties ( SetAccess = private )
2019-11-06 17:12:43 +01:00
directory = ' .' % Directory in which to write/compile the report. Default: '.'
title = ' ' % Report Title. Default: none.
orientation = ' portrait' % Paper orientation: Default: `portrait'.
paper = ' a4' % Paper size. Default: `a4'.
margin = 2.5 % The margin size. Default: 2.5.
marginUnit = ' cm' % Units associated with the margin. Default: `cm'.
fileName = ' report' % The file name to use when saving this report. Default: report.tex.
showDate = true % Display the date and time when the report was compiled. Default: true.
compiler = ' ' % The full path to the LATEX compiler on your system
showOutput = true % Print report creation progress to screen. Shows you the page number as it is created and as it is written. This is useful to see where a potential error occurs in report creation. Default: true.
header = ' ' % The valid LATEX code to be included in the report before \begin{document}. Default: empty.
reportDirName = ' tmpRepDir' % The name of the folder in which to store the component parts of the report (preamble, document, end). Default: tmpRepDir.
2019-11-29 11:42:28 +01:00
maketoc = false % Whether or not to make a table of contents. Default: false.
2019-08-27 17:38:20 +02:00
end
methods
function o = report ( varargin)
%function o = report(varargin)
% Report Class Constructor
%
% INPUTS
% 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)
%
% OUTPUTS
% o [report] report object
%
% SPECIAL REQUIREMENTS
% none
if nargin == 0
return
elseif nargin == 1
assert ( isa ( varargin { 1 } , ' report' ) , ...
' @report.report: with one arg, you must pass a report object' ) ;
o = varargin { 1 } ;
return
end
2013-02-12 14:23:41 +01:00
2019-08-27 17:38:20 +02:00
if round ( nargin / 2 ) ~= nargin / 2
error ( ' @report.report: options must be supplied in name/value pairs' ) ;
end
2013-02-15 16:52:35 +01:00
2019-08-27 17:38:20 +02:00
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
2022-04-15 14:16:13 +02:00
if isoctave
warnstate = warning ( ' off' , ' Octave:classdef-to-struct' ) ;
end
2019-08-27 17:38:20 +02:00
optNames = fieldnames ( o ) ;
2022-04-15 14:16:13 +02:00
if isoctave
warning ( warnstate ) ;
end
2013-02-12 14:23:41 +01:00
2019-08-27 17:38:20 +02:00
% overwrite default values
for pair = reshape ( varargin , 2 , [ ] )
ind = find ( strcmpi ( optNames , pair { 1 } ) ) ;
assert ( isempty ( ind ) || length ( ind ) == 1 ) ;
if ~ isempty ( ind )
o . ( optNames { ind } ) = pair { 2 } ;
else
error ( ' @report.report: %s is not a recognized option.' , pair { 1 } ) ;
end
end
2013-03-15 17:03:50 +01:00
2019-08-27 17:38:20 +02:00
% Check options provided by user
2019-09-02 16:25:13 +02:00
assert ( ischar ( o . directory ) , ' @report.report: directory must be a string' ) ;
2019-08-27 17:38:20 +02:00
assert ( ischar ( o . title ) , ' @report.report: title must be a string' ) ;
assert ( ischar ( o . fileName ) , ' @report.report: fileName must be a string' ) ;
assert ( ischar ( o . compiler ) , ' @report.report: compiler file must be a string' ) ;
assert ( islogical ( o . showDate ) , ' @report.report: showDate must be either true or false' ) ;
assert ( islogical ( o . showOutput ) , ' @report.report: showOutput must be either true or false' ) ;
assert ( isfloat ( o . margin ) && o . margin > 0 , ' @report.report: margin must be a float > 0.' ) ;
assert ( ischar ( o . header ) , ' @report.report: header must be a string' ) ;
2019-11-06 17:12:43 +01:00
assert ( ischar ( o . reportDirName ) , ' @report.report: reportDirName must be a string' ) ;
2019-08-27 17:38:20 +02:00
valid_margin_unit = { ' cm' , ' in' } ;
assert ( any ( strcmp ( o . marginUnit , valid_margin_unit ) ) , ...
[ ' @report.report: marginUnit must be one of ' addCommasToCellStr ( valid_margin_unit ) ] ) ;
2013-03-15 17:03:50 +01:00
2019-08-27 17:38:20 +02:00
valid_paper = { ' a4' , ' letter' } ;
assert ( any ( strcmp ( o . paper , valid_paper ) ) , ...
[ ' @report.report: paper must be one of ' addCommasToCellStr ( valid_paper ) ] ) ;
2013-03-15 17:03:50 +01:00
2019-08-27 17:38:20 +02:00
valid_orientation = { ' portrait' , ' landscape' } ;
assert ( any ( strcmp ( o . orientation , valid_orientation ) ) , ...
[ ' @report.report: orientation must be one of ' addCommasToCellStr ( valid_orientation ) ] ) ;
2019-11-28 18:13:10 +01:00
assert ( islogical ( o . maketoc ) , ' @report.report: maketock must be logical' ) ;
2019-08-27 17:38:20 +02:00
end
o = addPage ( o , varargin )
o = addSection ( o , varargin )
o = addGraph ( o , varargin )
o = addTable ( o , varargin )
o = addVspace ( o , varargin )
o = addParagraph ( o , varargin )
o = addSeries ( o , varargin )
o = addData ( o , varargin )
o = compile ( o , varargin )
o = write ( o )
end
methods ( Hidden = true )
n = numPages ( o )
end
2015-07-16 16:55:29 +02:00
end