Newer
Older

jacques.grelet_ird.fr
committed
function val = subsref(hash, s)
% Subscripted assignment for object Hashtable
% Subscripted assignment for object dynaload
% overloading subscripted reference for objects
% Dot Notation vs. Function Notation
%
% ex: h = Hashtable('key', value)
% value = h.key
% value = h('key')
% if value is a structure, get field value:
% fvalue = h.key.field
% see help from substruct and subsref
%
% $Id$

jacques.grelet_ird.fr
committed
switch (length(s))
case 2
switch s(1).type
case '.'
% get object with key 's(1).subs' in hash
% ---------------------------------------
val = get(hash, s(1).subs);
% assume that val is a structure
% ------------------------------
if isstruct(val)
val = val.(s(2).subs);
else
error('object for key: %s not a valid struct object.', s(2).subs)
end
otherwise
error('Invalid type.')
end

jacques.grelet_ird.fr
committed

jacques.grelet_ird.fr
committed
case 1
switch s.type
case '()'
if (length(index.subs) ~= 1)
error('Only single indexing is supported.');
end
val = get(hash,s.subs{1});
case '.'
val = get(hash,s.subs);
otherwise
error('Invalid type.')