reporting (WIP)
parent
4fa141762d
commit
78f8f04598
|
@ -1,5 +1,5 @@
|
||||||
function ss = addSection(ss, varargin)
|
function e = addGraph(e, varargin)
|
||||||
% function ss = addSection(ss, varargin)
|
% function e = addGraph(e, varargin)
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
% Copyright (C) 2013 Dynare Team
|
||||||
%
|
%
|
||||||
|
@ -20,8 +20,8 @@ function ss = addSection(ss, varargin)
|
||||||
|
|
||||||
assert(nargin >= 1 && nargin <= 3)
|
assert(nargin >= 1 && nargin <= 3)
|
||||||
if nargin == 1
|
if nargin == 1
|
||||||
ss.objArray = ss.objArray.addObj(section());
|
e.objArray = e.objArray.addObj(graph());
|
||||||
else
|
else
|
||||||
ss.objArray = ss.objArray.addObj(varargin{:});
|
e.objArray = e.objArray.addObj(varargin{:});
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,27 @@
|
||||||
|
function e = addTable(e, varargin)
|
||||||
|
% function e = addTable(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/>.
|
||||||
|
|
||||||
|
assert(nargin >= 1 && nargin <= 3)
|
||||||
|
if nargin == 1
|
||||||
|
e.objArray = e.objArray.addObj(table());
|
||||||
|
else
|
||||||
|
e.objArray = e.objArray.addObj(varargin{:});
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,36 @@
|
||||||
|
function display(o)
|
||||||
|
%function display(o)
|
||||||
|
% Display a Elements object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% none
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
name = 'report.page.section.elements';
|
||||||
|
disp(' ');
|
||||||
|
disp([name ' = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp(getElements(o));
|
||||||
|
end
|
|
@ -0,0 +1,42 @@
|
||||||
|
function e = elements(varargin)
|
||||||
|
%function e = elements(varargin)
|
||||||
|
% Elements Class Constructor
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% Optional elements object
|
||||||
|
%
|
||||||
|
% OUTPUTS
|
||||||
|
% elements 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/>.
|
||||||
|
|
||||||
|
switch nargin
|
||||||
|
case 0
|
||||||
|
e = class(struct, 'elements', objArray());
|
||||||
|
case 1
|
||||||
|
assert(isa(varargin{1}, 'elements'), ...
|
||||||
|
['With one arg to elements constructor, you must pass an ' ...
|
||||||
|
'elements object or a char.']);
|
||||||
|
e = varargin{1};
|
||||||
|
otherwise
|
||||||
|
error('Elements constructor: invalid number of arguments');
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
function e = getSections(ss, varargin)
|
function e = getElements(ps, varargin)
|
||||||
% function e = getSections(ss, varargin)
|
% function e = getElements(ps, varargin)
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
% Copyright (C) 2013 Dynare Team
|
||||||
%
|
%
|
||||||
|
@ -18,5 +18,5 @@ function e = getSections(ss, varargin)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
e = ss.objArray.getObjs(varargin{:});
|
e = ps.objArray.getObjs(varargin{:});
|
||||||
end
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
function ns = numSections(ss)
|
function n = numElements(o)
|
||||||
% function ns = numSections(ss)
|
% function n = numElements(o)
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
% Copyright (C) 2013 Dynare Team
|
||||||
%
|
%
|
||||||
|
@ -18,5 +18,5 @@ function ns = numSections(ss)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
ns = ss.objArray.numObjs();
|
n = o.objArray.numObjs();
|
||||||
end
|
end
|
|
@ -0,0 +1,39 @@
|
||||||
|
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.objArray(index) = V;
|
||||||
|
otherwise
|
||||||
|
error('Elements subsasign 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(['Elements Class: unknown field or method: ' S(1).subs]);
|
||||||
|
end
|
||||||
|
case '()'
|
||||||
|
A = getElements(A, S(1).subs{:});
|
||||||
|
case '{}'
|
||||||
|
error(['Elements Class: ' S(1).type ' indexing not supported.']);
|
||||||
|
otherwise
|
||||||
|
error('Elements Class: subsref.m impossible case')
|
||||||
|
end
|
||||||
|
|
||||||
|
S = shiftS(S);
|
||||||
|
if length(S) >= 1
|
||||||
|
A = subsref(A, S);
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,46 @@
|
||||||
|
function display(o)
|
||||||
|
%function display(o)
|
||||||
|
% Display a Graph object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% none
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
name = 'report.page.section.graph';
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.caption = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.caption '''']);
|
||||||
|
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.footnote = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.footnote '''']);
|
||||||
|
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.filename = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.filename '''']);
|
||||||
|
end
|
|
@ -0,0 +1,66 @@
|
||||||
|
function o = graph(varargin)
|
||||||
|
%function o = graph(varargin)
|
||||||
|
% Graph Class Constructor
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% 0 args => empty graph
|
||||||
|
% 1 arg (graph 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.caption = '';
|
||||||
|
o.footnote = '';
|
||||||
|
o.filename = '';
|
||||||
|
o.data = '';
|
||||||
|
o.config = '';
|
||||||
|
|
||||||
|
if nargin == 1
|
||||||
|
assert(isa(varargin{1}, 'graph'),['With one arg to Graph constructor, ' ...
|
||||||
|
'you must pass a graph object']);
|
||||||
|
o = varargin{1};
|
||||||
|
return;
|
||||||
|
elseif nargin > 1
|
||||||
|
if round(nargin/2) ~= nargin/2
|
||||||
|
error(['Options to Graph constructor 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('%s is not a recognized option to the Graph constructor.', ...
|
||||||
|
field);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Create graph object
|
||||||
|
o = class(o, 'graph');
|
||||||
|
end
|
|
@ -0,0 +1,42 @@
|
||||||
|
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 '.'
|
||||||
|
switch S.subs
|
||||||
|
case fieldnames(A)
|
||||||
|
B.(S.subs) = V;
|
||||||
|
otherwise
|
||||||
|
error(['field ' S.subs 'does not exist in the page class'])
|
||||||
|
end
|
||||||
|
otherwise
|
||||||
|
error('report subsasign syntax error')
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,46 @@
|
||||||
|
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(['Graph Class: unknown field or method: ' S(1).subs]);
|
||||||
|
end
|
||||||
|
case {'()', '{}'}
|
||||||
|
error(['Graph Class: ' S(1).type ' indexing not supported.']);
|
||||||
|
otherwise
|
||||||
|
error('Graph Class: subsref.m impossible case')
|
||||||
|
end
|
||||||
|
|
||||||
|
S = shiftS(S);
|
||||||
|
if length(S) >= 1
|
||||||
|
A = subsref(A, S);
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,40 @@
|
||||||
|
function write(o, fid, texIndent)
|
||||||
|
%function write(o, fid)
|
||||||
|
% Write a Page object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% none
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(fid > 0);
|
||||||
|
assert(isnumeric(texIndent));
|
||||||
|
|
||||||
|
fprintf(fid, '%d\% Page Object\n', texIndent);
|
||||||
|
fprintf(fid, '%d\newpage\n', texIndent);
|
||||||
|
|
||||||
|
o.sections.write(fid, texIndent+2);
|
||||||
|
|
||||||
|
fprintf(fid, '%d\% End Page Object\n', texIndent);
|
||||||
|
end
|
|
@ -8,7 +8,7 @@ function p = addSection(p, varargin)
|
||||||
% 3 args => add section at index
|
% 3 args => add section at index
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% updated report object
|
% updated page object
|
||||||
%
|
%
|
||||||
% SPECIAL REQUIREMENTS
|
% SPECIAL REQUIREMENTS
|
||||||
% none
|
% none
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function p = page(varargin)
|
function o = page(varargin)
|
||||||
%function p = page(varargin)
|
%function o = page(varargin)
|
||||||
% Page Class Constructor
|
% Page Class Constructor
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
|
@ -29,17 +29,36 @@ function p = page(varargin)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
p = struct;
|
o = struct;
|
||||||
p.sections = sections();
|
o.caption = '';
|
||||||
|
o.orientation = 'portrait';
|
||||||
|
o.sections = sections();
|
||||||
|
|
||||||
switch nargin
|
if nargin == 1
|
||||||
case 0
|
assert(isa(varargin{1}, 'page'),['With one arg to Page constructor, ' ...
|
||||||
p = class(p, 'page');
|
'you must pass a page object']);
|
||||||
case 1
|
o = varargin{1};
|
||||||
assert(isa(varargin{1}, 'page'), ['Page constructor: the only valid ' ...
|
return;
|
||||||
'arguments are page objects']);
|
elseif nargin > 1
|
||||||
p = varargin{1};
|
if round(nargin/2) ~= nargin/2
|
||||||
otherwise
|
error(['Options to Page constructor must be supplied in name/value ' ...
|
||||||
error('Page constructor: invalid number of arguments');
|
'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('%s is not a recognized option to the Page constructor.', ...
|
||||||
|
field);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Create page object
|
||||||
|
o = class(o, 'page');
|
||||||
end
|
end
|
||||||
end
|
|
|
@ -23,6 +23,13 @@ switch S(1).type
|
||||||
switch S(1).subs
|
switch S(1).subs
|
||||||
case fieldnames(A)
|
case fieldnames(A)
|
||||||
A = A.(S(1).subs);
|
A = A.(S(1).subs);
|
||||||
|
case {'write'}
|
||||||
|
if areParensNext(S)
|
||||||
|
write(A, S(2).subs{:})
|
||||||
|
S = shiftS(S);
|
||||||
|
else
|
||||||
|
assert(false);
|
||||||
|
end
|
||||||
case methods(A)
|
case methods(A)
|
||||||
if areParensNext(S)
|
if areParensNext(S)
|
||||||
A = feval(S(1).subs, A, S(2).subs{:});
|
A = feval(S(1).subs, A, S(2).subs{:});
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
function write(o, fid, indent)
|
||||||
|
%function write(o, fid, indent)
|
||||||
|
% Write a Page object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% fid - int, file id
|
||||||
|
% indent - char, number of spaces to indent tex code
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(fid ~= -1);
|
||||||
|
|
||||||
|
fprintf(fid, '\n%s%% Page Object\n', indent);
|
||||||
|
if strcmpi(o.orientation, 'landscape')
|
||||||
|
fprintf(fid, '%s\\begin{landscape}\n', indent);
|
||||||
|
end
|
||||||
|
o.sections.write(fid, addIndentation(indent));
|
||||||
|
if strcmpi(o.orientation, 'landscape')
|
||||||
|
fprintf(fid, '%s\\end{landscape}\n', indent);
|
||||||
|
end
|
||||||
|
fprintf(fid, '%s\\clearpage\n', indent);
|
||||||
|
fprintf(fid, '%s%% End Page Object\n\n', indent);
|
||||||
|
end
|
|
@ -34,6 +34,6 @@ switch S.type
|
||||||
assert(isnumeric(index));
|
assert(isnumeric(index));
|
||||||
B.objArray(index) = V;
|
B.objArray(index) = V;
|
||||||
otherwise
|
otherwise
|
||||||
error('objArray subsasign syntax error')
|
error('Pages subsasign syntax error');
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -23,6 +23,13 @@ switch S(1).type
|
||||||
switch S(1).subs
|
switch S(1).subs
|
||||||
case fieldnames(A)
|
case fieldnames(A)
|
||||||
A = A.(S(1).subs);
|
A = A.(S(1).subs);
|
||||||
|
case {'write'}
|
||||||
|
if areParensNext(S)
|
||||||
|
write(A, S(2).subs{:})
|
||||||
|
S = shiftS(S);
|
||||||
|
else
|
||||||
|
assert(false);
|
||||||
|
end
|
||||||
case methods(A)
|
case methods(A)
|
||||||
if areParensNext(S)
|
if areParensNext(S)
|
||||||
A = feval(S(1).subs, A, S(2).subs{:});
|
A = feval(S(1).subs, A, S(2).subs{:});
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
function write(o, fid, indent)
|
||||||
|
%function write(o, fid, indent)
|
||||||
|
% Write Pages object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% fid - int, file id
|
||||||
|
% indent - char, number of spaces to indent tex code
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(fid ~= -1);
|
||||||
|
fprintf(fid, '\n%s%% Pages Object\n', indent);
|
||||||
|
nps = numPages(o);
|
||||||
|
for i=1:nps
|
||||||
|
o.objArray(i).write(fid, addIndentation(indent));
|
||||||
|
end
|
||||||
|
fprintf(fid, '%s%% End Pages Object\n\n', indent);
|
||||||
|
end
|
|
@ -33,14 +33,32 @@ disp(' ');
|
||||||
disp([name '.title = ']);
|
disp([name '.title = ']);
|
||||||
disp(' ');
|
disp(' ');
|
||||||
disp([' ''' o.title '''']);
|
disp([' ''' o.title '''']);
|
||||||
|
|
||||||
|
disp(' ')
|
||||||
|
disp([name '.paper = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.paper '''']);
|
||||||
|
|
||||||
disp(' ')
|
disp(' ')
|
||||||
disp([name '.orientation = ']);
|
disp([name '.orientation = ']);
|
||||||
disp(' ');
|
disp(' ');
|
||||||
disp([' ''' o.orientation '''']);
|
disp([' ''' o.orientation '''']);
|
||||||
|
|
||||||
|
disp(' ')
|
||||||
|
disp([name '.filename = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.filename '''']);
|
||||||
|
|
||||||
|
disp(' ')
|
||||||
|
disp([name '.config = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.config '''']);
|
||||||
|
|
||||||
disp(' ')
|
disp(' ')
|
||||||
disp([name '.numPages() = ']);
|
disp([name '.numPages() = ']);
|
||||||
disp(' ');
|
disp(' ');
|
||||||
disp([' ' num2str(numPages(o))]);
|
disp([' ' num2str(numPages(o))]);
|
||||||
|
|
||||||
disp(' ');
|
disp(' ');
|
||||||
disp([name '.pages = ']);
|
disp([name '.pages = ']);
|
||||||
disp(' ');
|
disp(' ');
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
function orientation = validateOrientation(orientation)
|
function validateOrientation(orientation)
|
||||||
%function orientation = validateOrientation(orientation)
|
%function validateOrientation(orientation)
|
||||||
% Validate orientation string
|
% Validate orientation string
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
|
@ -28,8 +28,6 @@ function orientation = validateOrientation(orientation)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
assert(any(strcmpi(orientation, {'portrait', 'landscape'})), ...
|
assert(any(strcmpi(orientation, {'portrait', 'landscape'})), ['Valid ' ...
|
||||||
['Valid orientation arguments are: ''portrait'' and ' ...
|
'orientation arguments are: ''portrait'' and ''landscape''.']);
|
||||||
'''landscape''.']);
|
|
||||||
orientation = lower(orientation);
|
|
||||||
end
|
end
|
|
@ -0,0 +1,33 @@
|
||||||
|
function validatePaper(paper)
|
||||||
|
%function validatePaper(paper)
|
||||||
|
% Validate paper string
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% char : paper size
|
||||||
|
%
|
||||||
|
% OUTPUTS
|
||||||
|
% char : lowercase paper
|
||||||
|
%
|
||||||
|
% 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(any(strcmpi(paper, {'a4', 'letter'})), ['Valid paper arguments ' ...
|
||||||
|
'are: ''a4'' and ''letter''.']);
|
||||||
|
end
|
|
@ -1,13 +1,10 @@
|
||||||
function r = report(varargin)
|
function o = report(varargin)
|
||||||
%function r = report(varargin)
|
%function o = report(varargin)
|
||||||
% Report Class Constructor
|
% Report Class Constructor
|
||||||
%
|
%
|
||||||
% INPUTS
|
% INPUTS
|
||||||
% 0 args => no title, portrait orientation
|
% 1 report class object => make a copy
|
||||||
% 1 arg (report class) => copy class
|
% Otherwise, option/value pairs (see structure below for options)
|
||||||
% 1 arg (not report class) => title
|
|
||||||
% 2 args (1st not report class) => title, orientation
|
|
||||||
% 3 args (1st not report class) => title, orientation, configuraiton
|
|
||||||
%
|
%
|
||||||
% OUTPUTS
|
% OUTPUTS
|
||||||
% none
|
% none
|
||||||
|
@ -33,51 +30,44 @@ function r = report(varargin)
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
% default values
|
% default values
|
||||||
r = struct;
|
o = struct;
|
||||||
r.title = '';
|
o.title = '';
|
||||||
r.orientation = 'portrait';
|
o.orientation = 'portrait';
|
||||||
r.pages = pages();
|
o.paper = 'a4';
|
||||||
r.config = '';
|
o.pages = pages();
|
||||||
|
o.filename = 'report.tex';
|
||||||
|
o.config = '';
|
||||||
|
|
||||||
% Check arguments
|
|
||||||
if nargin == 1
|
if nargin == 1
|
||||||
assert(isa(varargin{1}, 'report') || ischar(varargin{1}), ...
|
assert(isa(varargin{1}, 'report'),['With one arg to Report constructor, ' ...
|
||||||
['With one arg to report constructor, you must pass either '...
|
'you must pass a report object']);
|
||||||
'a report object or a char.']);
|
r = varargin{1};
|
||||||
end
|
return;
|
||||||
|
elseif nargin > 1
|
||||||
|
if round(nargin/2) ~= nargin/2
|
||||||
|
error(['Options to Report constructor must be supplied in name/value ' ...
|
||||||
|
'pairs.']);
|
||||||
|
end
|
||||||
|
|
||||||
if nargin > 1
|
optNames = lower(fieldnames(o));
|
||||||
assert(~isa(varargin{1}, 'report'), ...
|
|
||||||
['With multiple args to report constructor, first argument ' ...
|
% overwrite default values
|
||||||
'cannot be a report object.']);
|
for pair = reshape(varargin, 2, [])
|
||||||
for i=1:nargin
|
field = lower(pair{1});
|
||||||
assert(ischar(varargin{i}), ...
|
if any(strmatch(field, optNames, 'exact'))
|
||||||
['With muliple args to report constructor, all '...
|
if strcmp(field, 'orientation')
|
||||||
'arguments must be char.']);
|
validateOrientation(pair{2});
|
||||||
|
elseif strcmp(field, 'paper')
|
||||||
|
validatePaper(pair{2});
|
||||||
|
end
|
||||||
|
o.(field) = pair{2};
|
||||||
|
else
|
||||||
|
error('%s is not a recognized option to the Report constructor.', ...
|
||||||
|
field);
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
% Initialize fields
|
|
||||||
switch nargin
|
|
||||||
case 0
|
|
||||||
case 1
|
|
||||||
if isa(varargin{1}, 'report')
|
|
||||||
r = varargin{1};
|
|
||||||
return
|
|
||||||
else
|
|
||||||
r.title = varargin{1};
|
|
||||||
end
|
|
||||||
case 2
|
|
||||||
r.title = varargin{1};
|
|
||||||
r.orientation = validateOrientation(varargin{2});
|
|
||||||
case 3
|
|
||||||
r.title = varargin{1};
|
|
||||||
r.orientation = validateOrientation(varargin{2});
|
|
||||||
r.config = varargin{3};
|
|
||||||
otherwise
|
|
||||||
error('Report constructor: invalid number of arguments');
|
|
||||||
end
|
|
||||||
|
|
||||||
% Create report object
|
% Create report object
|
||||||
r = class(r, 'report');
|
o = class(o, 'report');
|
||||||
end
|
end
|
|
@ -23,6 +23,13 @@ switch S(1).type
|
||||||
switch S(1).subs
|
switch S(1).subs
|
||||||
case fieldnames(A)
|
case fieldnames(A)
|
||||||
A = A.(S(1).subs);
|
A = A.(S(1).subs);
|
||||||
|
case {'write'}
|
||||||
|
if areParensNext(S)
|
||||||
|
write(A, S(2).subs{:})
|
||||||
|
S = shiftS(S);
|
||||||
|
else
|
||||||
|
write(A);
|
||||||
|
end
|
||||||
case methods(A)
|
case methods(A)
|
||||||
if areParensNext(S)
|
if areParensNext(S)
|
||||||
A = feval(S(1).subs, A, S(2).subs{:});
|
A = feval(S(1).subs, A, S(2).subs{:});
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
function write(o)
|
||||||
|
%function write(o)
|
||||||
|
% Write Report object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% none
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
[fid, msg] = fopen(o.filename, 'w');
|
||||||
|
if fid == -1
|
||||||
|
error(msg);
|
||||||
|
end
|
||||||
|
|
||||||
|
fprintf(fid, '%% Report Object\n');
|
||||||
|
fprintf(fid, '\\documentclass[11pt]{article}\n');
|
||||||
|
|
||||||
|
fprintf(fid, '\\usepackage[%spaper,margin=2.5cm', o.paper);
|
||||||
|
if strcmpi(o.orientation, 'landscape')
|
||||||
|
fprintf(fid, ',landscape');
|
||||||
|
end
|
||||||
|
fprintf(fid, ']{geometry}\n');
|
||||||
|
fprintf(fid, '\\usepackage{graphicx}\n');
|
||||||
|
fprintf(fid, '\\usepackage{pdflscape}\n')
|
||||||
|
fprintf(fid, '\\begin{document}\n');
|
||||||
|
|
||||||
|
o.pages.write(fid, addIndentation(''));
|
||||||
|
|
||||||
|
fprintf(fid, '\\end{document}\n');
|
||||||
|
fprintf(fid, '%% End Report Object\n');
|
||||||
|
status = fclose(fid);
|
||||||
|
if status == -1
|
||||||
|
error('Error closing %s\n', o.filename);
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,39 @@
|
||||||
|
function o = addGraph(o, varargin)
|
||||||
|
%function o = addGraph(o, varargin)
|
||||||
|
% Add a graph to the Cell Array of graphs in the report
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% 1 args => add empty graph
|
||||||
|
% 2 args => add given graph
|
||||||
|
% 3 args => add graph at index
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(isa(o, 'section'), 'First argument must be a section object');
|
||||||
|
if nargin == 1
|
||||||
|
o.elements = o.elements.addGraph();
|
||||||
|
elseif nargin == 2 || nargin == 3
|
||||||
|
o.elements = o.elements.addGraph(varargin{:});
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,39 @@
|
||||||
|
function o = addTable(o, varargin)
|
||||||
|
%function o = addTable(o, varargin)
|
||||||
|
% Add a table to the Cell Array of tables in the report
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% 1 args => add empty table
|
||||||
|
% 2 args => add given table
|
||||||
|
% 3 args => add table at index
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(isa(o, 'section'), 'First argument must be a section object');
|
||||||
|
if nargin == 1
|
||||||
|
o.elements = o.elements.addTable();
|
||||||
|
elseif nargin == 2 || nargin == 3
|
||||||
|
o.elements = o.elements.addTable(varargin{:});
|
||||||
|
end
|
||||||
|
end
|
|
@ -30,5 +30,13 @@ function display(o)
|
||||||
|
|
||||||
name = 'report.page.section';
|
name = 'report.page.section';
|
||||||
disp(' ');
|
disp(' ');
|
||||||
disp([name '.x = ']);
|
disp([name '.align = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.align '''']);
|
||||||
|
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.elements = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp(o.elements.getElements());
|
||||||
|
|
||||||
end
|
end
|
|
@ -0,0 +1,22 @@
|
||||||
|
function n = numElements(o)
|
||||||
|
% function n = numElements(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.numElements();
|
||||||
|
end
|
|
@ -1,5 +1,7 @@
|
||||||
function s = section(varargin)
|
function o = section(varargin)
|
||||||
%function s = section(varargin)
|
%function o = section(varargin)
|
||||||
|
|
||||||
|
% Section produces a latex minipage
|
||||||
|
|
||||||
% Copyright (C) 2013 Dynare Team
|
% Copyright (C) 2013 Dynare Team
|
||||||
%
|
%
|
||||||
|
@ -18,15 +20,39 @@ function s = section(varargin)
|
||||||
% You should have received a copy of the GNU General Public License
|
% You should have received a copy of the GNU General Public License
|
||||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
switch nargin
|
o = struct;
|
||||||
case 0
|
o.align = 't';
|
||||||
s = class(struct, 'section', objArray());
|
o.elements = elements();
|
||||||
case 1
|
o.rows = 1;
|
||||||
assert(isa(varargin{1}, 'section'), ['Section constructor: the only ' ...
|
o.cols = 1;
|
||||||
'valid arguments are section objects']);
|
|
||||||
s = varargin{1};
|
|
||||||
otherwise
|
if nargin == 1
|
||||||
error('Section constructor: invalid number of arguments');
|
assert(isa(varargin{1}, 'section'),['With one arg to Section constructor, ' ...
|
||||||
end
|
'you must pass a section object']);
|
||||||
|
o = varargin{1};
|
||||||
|
return;
|
||||||
|
elseif nargin > 1
|
||||||
|
if round(nargin/2) ~= nargin/2
|
||||||
|
error(['Options to Section constructor 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('%s is not a recognized option to the Section constructor.', ...
|
||||||
|
field);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Create section object
|
||||||
|
o = class(o, 'section');
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,13 @@ switch S(1).type
|
||||||
switch S(1).subs
|
switch S(1).subs
|
||||||
case fieldnames(A)
|
case fieldnames(A)
|
||||||
A = A.(S(1).subs);
|
A = A.(S(1).subs);
|
||||||
|
case {'write'}
|
||||||
|
if areParensNext(S)
|
||||||
|
write(A, S(2).subs{:})
|
||||||
|
S = shiftS(S);
|
||||||
|
else
|
||||||
|
assert(false);
|
||||||
|
end
|
||||||
case methods(A)
|
case methods(A)
|
||||||
if areParensNext(S)
|
if areParensNext(S)
|
||||||
A = feval(S(1).subs, A, S(2).subs{:});
|
A = feval(S(1).subs, A, S(2).subs{:});
|
||||||
|
@ -34,7 +41,7 @@ switch S(1).type
|
||||||
error(['Section Class: unknown field or method: ' S(1).subs]);
|
error(['Section Class: unknown field or method: ' S(1).subs]);
|
||||||
end
|
end
|
||||||
case '()'
|
case '()'
|
||||||
A = getSections(A, S(1).subs{:});
|
A = getElements(A, S(1).subs{:});
|
||||||
case '{}'
|
case '{}'
|
||||||
error(['Section Class: ' S(1).type ' indexing not supported.']);
|
error(['Section Class: ' S(1).type ' indexing not supported.']);
|
||||||
otherwise
|
otherwise
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
function write(o, fid, indent)
|
||||||
|
%function write(o, fid, indent)
|
||||||
|
% Write Section object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% fid - int, file id
|
||||||
|
% indent - char, number of spaces to indent tex code
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(fid ~= -1);
|
||||||
|
|
||||||
|
fprintf(fid, '\n%s%% Section Object\n', indent);
|
||||||
|
fprintf(fid, '%s\\noindent\\begin{minipage}[%s]{0.32\\hsize}\n', indent, o.align);
|
||||||
|
|
||||||
|
ne = numElements(o);
|
||||||
|
for i=1:ne
|
||||||
|
o.elements(i).write(fid, addIndentation(indent));
|
||||||
|
end
|
||||||
|
|
||||||
|
fprintf(fid, '%s\\end{minipage}\n', indent);
|
||||||
|
fprintf(fid, '%s%% End Section Object\n\n', indent);
|
||||||
|
end
|
|
@ -32,7 +32,7 @@ switch S.type
|
||||||
case '()'
|
case '()'
|
||||||
index = S.subs{:};
|
index = S.subs{:};
|
||||||
assert(isnumeric(index));
|
assert(isnumeric(index));
|
||||||
B(index) = V;
|
B.objArray(index) = V;
|
||||||
otherwise
|
otherwise
|
||||||
error('objArray subsasign syntax error')
|
error('objArray subsasign syntax error')
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,6 +23,13 @@ switch S(1).type
|
||||||
switch S(1).subs
|
switch S(1).subs
|
||||||
case fieldnames(A)
|
case fieldnames(A)
|
||||||
A = A.(S(1).subs);
|
A = A.(S(1).subs);
|
||||||
|
case {'write'}
|
||||||
|
if areParensNext(S)
|
||||||
|
write(A, S(2).subs{:})
|
||||||
|
S = shiftS(S);
|
||||||
|
else
|
||||||
|
assert(false);
|
||||||
|
end
|
||||||
case methods(A)
|
case methods(A)
|
||||||
if areParensNext(S)
|
if areParensNext(S)
|
||||||
A = feval(S(1).subs, A, S(2).subs{:});
|
A = feval(S(1).subs, A, S(2).subs{:});
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
function write(o, fid, indent)
|
||||||
|
%function write(o, fid, indent)
|
||||||
|
% Write Sections object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% fid - int, file id
|
||||||
|
% indent - char, number of spaces to indent tex code
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(fid ~= -1);
|
||||||
|
fprintf(fid, '\n%s%% Sections Object\n', indent);
|
||||||
|
nps = numSections(o);
|
||||||
|
for i=1:nps
|
||||||
|
o.objArray(i).write(fid, indent);
|
||||||
|
end
|
||||||
|
fprintf(fid, '%s%% End Sections Object\n\n', indent);
|
||||||
|
end
|
|
@ -0,0 +1,57 @@
|
||||||
|
function display(o)
|
||||||
|
%function display(o)
|
||||||
|
% Display a Table object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% none
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
name = 'report.page.section.table';
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.caption = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.caption '''']);
|
||||||
|
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.footnote = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.footnote '''']);
|
||||||
|
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.hlines = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.hlines '''']);
|
||||||
|
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.vlines = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.vlines '''']);
|
||||||
|
|
||||||
|
disp(' ');
|
||||||
|
disp([name '.data = ']);
|
||||||
|
disp(' ');
|
||||||
|
disp([' ''' o.data '''']);
|
||||||
|
|
||||||
|
end
|
|
@ -0,0 +1,42 @@
|
||||||
|
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 '.'
|
||||||
|
switch S.subs
|
||||||
|
case fieldnames(A)
|
||||||
|
B.(S.subs) = V;
|
||||||
|
otherwise
|
||||||
|
error(['field ' S.subs 'does not exist in the page class'])
|
||||||
|
end
|
||||||
|
otherwise
|
||||||
|
error('report subsasign syntax error')
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,46 @@
|
||||||
|
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(['Table Class: unknown field or method: ' S(1).subs]);
|
||||||
|
end
|
||||||
|
case {'()', '{}'}
|
||||||
|
error(['Table Class: ' S(1).type ' indexing not supported.']);
|
||||||
|
otherwise
|
||||||
|
error('Table Class: subsref.m impossible case')
|
||||||
|
end
|
||||||
|
|
||||||
|
S = shiftS(S);
|
||||||
|
if length(S) >= 1
|
||||||
|
A = subsref(A, S);
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,66 @@
|
||||||
|
function o = table(varargin)
|
||||||
|
%function o = table(varargin)
|
||||||
|
% Table Class Constructor
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% 0 args => empty table
|
||||||
|
% 1 arg (table 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.caption = '';
|
||||||
|
o.footnote = '';
|
||||||
|
o.hlines = false;
|
||||||
|
o.vlines = false;
|
||||||
|
o.data = '';
|
||||||
|
|
||||||
|
if nargin == 1
|
||||||
|
assert(isa(varargin{1}, 'table'),['With one arg to Table constructor, ' ...
|
||||||
|
'you must pass a table object']);
|
||||||
|
o = varargin{1};
|
||||||
|
return;
|
||||||
|
elseif nargin > 1
|
||||||
|
if round(nargin/2) ~= nargin/2
|
||||||
|
error(['Options to Table constructor 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('%s is not a recognized option to the Table constructor.', ...
|
||||||
|
field);
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Create table object
|
||||||
|
o = class(o, 'table');
|
||||||
|
end
|
|
@ -0,0 +1,40 @@
|
||||||
|
function write(o, fid, texIndent)
|
||||||
|
%function write(o, fid)
|
||||||
|
% Write a Page object
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% none
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
assert(fid > 0);
|
||||||
|
assert(isnumeric(texIndent));
|
||||||
|
|
||||||
|
fprintf(fid, '%d\% Page Object\n', texIndent);
|
||||||
|
fprintf(fid, '%d\newpage\n', texIndent);
|
||||||
|
|
||||||
|
o.sections.write(fid, texIndent+2);
|
||||||
|
|
||||||
|
fprintf(fid, '%d\% End Page Object\n', texIndent);
|
||||||
|
end
|
|
@ -0,0 +1,31 @@
|
||||||
|
function spaces=addIndentation(spaces)
|
||||||
|
% Return new level of indentation for latex output
|
||||||
|
%
|
||||||
|
% INPUTS
|
||||||
|
% spaces - char, current level of indentation
|
||||||
|
%
|
||||||
|
% OUTPUTS
|
||||||
|
% spaces - char, new level of indentation
|
||||||
|
%
|
||||||
|
% 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/>.
|
||||||
|
|
||||||
|
spaces = [spaces ' '];
|
||||||
|
end
|
Loading…
Reference in New Issue