diff --git a/matlab/reporting/@table/table.m b/matlab/reporting/@table/table.m index 95fb4fcfe30116825be3ae85a69e8d5f88fa2927..f9573c3a1ead3eef78c00adf1efb292d7c8979b6 100644 --- a/matlab/reporting/@table/table.m +++ b/matlab/reporting/@table/table.m @@ -39,9 +39,8 @@ o.hlines = false; o.vlines = false; o.data = ''; -o.datatitles = ''; -o.seriestouse = 'all'; -o.range = ''; +o.seriestouse = ''; +o.range = {}; o.precision = 1; if nargin == 1 @@ -69,6 +68,42 @@ elseif nargin > 1 end end +% Check options provided by user +assert(ischar(o.title), '@table.table: title must be a string'); +assert(ischar(o.footnote), '@table.table: footnote must be a string'); +assert(ischar(o.config), '@table.table: config file must be a string'); +assert(islogical(o.hlines), '@table.table: hlines must be true or false'); +assert(islogical(o.vlines), '@table.table: vlines must be true or false'); +assert(isint(o.precision), '@table.table: precision must be an int'); +assert(isempty(o.range) || (iscell(o.range) && length(o.range) == 2 && ... + ischar(o.range{1}) && ischar(o.range{2})), ... + ['@table.table: range is specified as ''{''1999q1'',''999q2''}''.']); + +assert(~isempty(o.data), '@table.table: must provide data'); +msg = ['@table.table: data must either be a dynSeries or a cell array of ' ... + 'dynSeries']; +if length(o.data) == 1 + assert(isa(o.data, 'dynSeries'), msg); +else + assert(iscell(o.data), msg); + for i=1:length(o.data) + assert(isa(o.data{i}, 'dynSeries'), msg); + end +end + +msg = ['@table.table: series to use must either be a string or a cell array ' ... + 'of strings']; +if ~isempty(o.seriestouse) + if length(o.seriestouse) == 1 + assert(ischar(o.seriestouse), msg); + else + assert(iscell(o.seriestouse), msg); + for i=1:length(o.seriestouse) + assert(ischar(o.seriestouse{i}), msg); + end + end +end + % Create table object o = class(o, 'table'); end \ No newline at end of file diff --git a/matlab/reporting/@table/write.m b/matlab/reporting/@table/write.m index f5c47d60106a7dfd9a614ec05e68a80e75b29b76..51673fa21ab17f41bf7ac5a77a0ebf576d29a0ba 100644 --- a/matlab/reporting/@table/write.m +++ b/matlab/reporting/@table/write.m @@ -34,7 +34,7 @@ if isempty(o.data) return end -if strcmpi(o.seriestouse, 'all') +if isempty(o.seriestouse) ds = o.data; else ds = o.data{o.seriestouse{:}};