reporting: @vspace
parent
09d6d0d855
commit
2673729a2d
|
@ -0,0 +1,22 @@
|
|||
function e = addVspace(e, varargin)
|
||||
% function e = addVspace(e, varargin)
|
||||
|
||||
% 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/>.
|
||||
|
||||
e.objArray = e.objArray.addObj(vspace(varargin{:}));
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
function n = numVspace(o)
|
||||
% function n = numVspace(o)
|
||||
|
||||
% 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/>.
|
||||
|
||||
objs = o.objArray.getObjs();
|
||||
n = 0;
|
||||
for i=1:length(objs)
|
||||
if isa(objs{i}, 'vspace')
|
||||
n = n+1;
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
function o = addVspace(o, varargin)
|
||||
%function o = addVspace(o, varargin)
|
||||
% Add a vspace to the Cell Array of vspaces in the report
|
||||
%
|
||||
% INPUTS
|
||||
% 1 args => add empty vspace
|
||||
% 2 args => add given vspace
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
o.elements = o.elements.addVspace(varargin{:});
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
function n = numVspace(o)
|
||||
% function n = numVspace(o)
|
||||
|
||||
% 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/>.
|
||||
|
||||
n = o.elements.numVspace();
|
||||
end
|
|
@ -38,13 +38,24 @@ for i=1:o.cols
|
|||
end
|
||||
fprintf(fid, '}\n');
|
||||
ne = numElements(o);
|
||||
nvspace = numVspace(o);
|
||||
nlcounter = 0;
|
||||
for i=1:ne
|
||||
if isa(o.elements(i), 'vspace')
|
||||
assert(rem(nlcounter, o.cols) == 0, ['@section.write: must place ' ...
|
||||
'vspace command after a linebreak in the table ' ...
|
||||
'or series of charts']);
|
||||
o.elements(i).write(fid);
|
||||
if rem(i, o.cols)
|
||||
fprintf(fid, '\\\\\n');
|
||||
else
|
||||
o.elements(i).write(fid);
|
||||
nlcounter = nlcounter + 1;
|
||||
if rem(nlcounter, o.cols)
|
||||
fprintf(fid, ' & ');
|
||||
else
|
||||
fprintf(fid, '\\\\\n');
|
||||
end
|
||||
end
|
||||
end
|
||||
fprintf(fid, '\\end{tabular}}\n');
|
||||
fprintf(fid, '%% End Section Object\n\n');
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
function B = subsasgn(A, S, V)
|
||||
% function B = subsasgn(A, S, V)
|
||||
|
||||
% 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/>.
|
||||
|
||||
B = A;
|
||||
if length(S) > 1
|
||||
for i=1:(length(S)-1)
|
||||
B = subsref(B, S(i));
|
||||
end
|
||||
B = subsasgn(B, S(end), V);
|
||||
B = subsasgn(A, S(1:(end-1)), B);
|
||||
return
|
||||
end
|
||||
|
||||
switch S.type
|
||||
case '()'
|
||||
index = S.subs{:};
|
||||
assert(isnumeric(index));
|
||||
B{index} = V;
|
||||
case '.'
|
||||
switch S.subs
|
||||
case fieldnames(A)
|
||||
B.(S.subs) = V;
|
||||
otherwise
|
||||
error(['@vspace.subsasgn: field ' S.subs 'does not exist']);
|
||||
end
|
||||
otherwise
|
||||
error('@vspace.subsasgn: syntax error');
|
||||
end
|
||||
end
|
|
@ -0,0 +1,48 @@
|
|||
function A = subsref(A, S)
|
||||
%function A = subsref(A, S)
|
||||
|
||||
% 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/>.
|
||||
|
||||
switch S(1).type
|
||||
case '.'
|
||||
switch S(1).subs
|
||||
case fieldnames(A)
|
||||
A = A.(S(1).subs);
|
||||
case methods(A)
|
||||
if areParensNext(S)
|
||||
A = feval(S(1).subs, A, S(2).subs{:});
|
||||
S = shiftS(S);
|
||||
else
|
||||
A = feval(S(1).subs, A);
|
||||
end
|
||||
otherwise
|
||||
error(['@vspace.subsref: unknown field or method: ' S(1).subs]);
|
||||
end
|
||||
case '()'
|
||||
A = getSections(A, S(1).subs{:});
|
||||
case '{}'
|
||||
error(['@vspace.subsref: ' S(1).type ' indexing not supported.']);
|
||||
otherwise
|
||||
error('@vspace.subsref: impossible case')
|
||||
end
|
||||
|
||||
S = shiftS(S);
|
||||
if length(S) >= 1
|
||||
A = subsref(A, S);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,66 @@
|
|||
function o = vspace(varargin)
|
||||
%function o = vspace(varargin)
|
||||
% Vspace Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% 0 args => empty vspace
|
||||
% 1 arg (vspace class) => copy object
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
o = struct;
|
||||
o.number = 1;
|
||||
o.hline = 0;
|
||||
|
||||
if nargin == 1
|
||||
assert(isa(varargin{1}, 'vspace'), ['@vspace.vspace: with one arg to Vspace ' ...
|
||||
'constructor, you must pass a vspace object']);
|
||||
o = varargin{1};
|
||||
return;
|
||||
elseif nargin > 1
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error(['@vspace.vspace: options must be supplied in name/value ' ...
|
||||
'pairs.']);
|
||||
end
|
||||
|
||||
optNames = lower(fieldnames(o));
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
field = lower(pair{1});
|
||||
if any(strmatch(field, optNames, 'exact'))
|
||||
o.(field) = pair{2};
|
||||
else
|
||||
error('@vspace.vspace: %s is not a recognized option.', field);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
assert(isint(o.number), '@vspace.vspace: number must be an integer');
|
||||
assert(isint(o.hline), '@vspace.vspace: hline must be an integer');
|
||||
|
||||
% Create vspace object
|
||||
o = class(o, 'vspace');
|
||||
end
|
|
@ -0,0 +1,44 @@
|
|||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write a Vspace object
|
||||
%
|
||||
% INPUTS
|
||||
% o [vspace] vspace object
|
||||
% fid [integer] file id
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [vspace] vspace object
|
||||
%
|
||||
% 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/>.
|
||||
|
||||
assert(fid ~= -1);
|
||||
|
||||
for i=1:o.number
|
||||
fprintf(fid, ' \\par \\medskip ');
|
||||
end
|
||||
|
||||
if o.hline > 0
|
||||
fprintf(fid, '\\\\\n');
|
||||
for i=1:o.hline
|
||||
fprintf(fid, '\\midrule');
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue