Skip to content

Commit

Permalink
Added logicals handling. Fixed some small issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
ptomask committed Dec 29, 2011
1 parent f88029d commit ec249e9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
9 changes: 9 additions & 0 deletions ReadYamlRaw.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@
result = scan_string(r);
elseif isa(r, 'double')
result = scan_numeric(r);
elseif isa(r, 'logical')
result = scan_logical(r);
elseif isa(r, 'java.util.Date')
result = scan_datetime(r);
elseif isa(r, 'java.util.List')
Expand All @@ -116,6 +118,13 @@
result = double(r);
end

%--------------------------------------------------------------------------
% Transforms Java boolean to MATLAB logical
%
function result = scan_logical(r)
result = logical(r);
end

%--------------------------------------------------------------------------
% Transforms Java Date class to MATLAB DateTime class
%
Expand Down
20 changes: 19 additions & 1 deletion WriteYaml.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
result = scan_struct(r);
elseif isnumeric(r)
result = scan_numeric(r);
elseif islogical(r)
result = scan_logical(r);
elseif isa(r,'DateTime')
result = scan_datetime(r);
else
Expand All @@ -78,11 +80,27 @@
end
end

%--------------------------------------------------------------------------
%
%

function result = scan_logical(r)
if isempty(r)
result = java.util.ArrayList();
else
result = java.lang.Boolean(r);
end
end

%--------------------------------------------------------------------------
%
%
function result = scan_char(r)
result = java.lang.String(r);
if isempty(r)
result = java.util.ArrayList();
else
result = java.lang.String(r);
end
end

%--------------------------------------------------------------------------
Expand Down
9 changes: 8 additions & 1 deletion makematrices.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
%
function result = ismatrixrow(cellvec)
result = ...
(isnumeric_all(cellvec) || isstruct_all(cellvec)) && ...
(isnumeric_all(cellvec) || islogical_all(cellvec) || isstruct_all(cellvec)) && ...
issingle_all(cellvec) && ...
iscompatible_all(cellvec);
end
Expand All @@ -131,6 +131,13 @@
result = all(cellfun(@isnumeric, cellvec));
end

%--------------------------------------------------------------------------
%
%
function result = islogical_all(cellvec)
result = all(cellfun(@islogical, cellvec));
end

%--------------------------------------------------------------------------
%
%
Expand Down

0 comments on commit ec249e9

Please sign in to comment.