view m-toolbox/classes/+utils/@prog/struct2obj.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +0100
parents f0afece42f48
children
line wrap: on
line source

% STRUCT2OBJ converts the input structure into the given object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: STRUCT2OBJ converts the input structure into the given object.
%
% CALL:        obj  = struct2obj(s, class)
%
% INPUTS:      s     - the structure to convert
%              class - the class of the object to convert to
%
%
% OUTPUTS:     obj - the converted object
%
% VERSION:     $Id: struct2obj.m,v 1.2 2008/07/03 18:20:25 ingo Exp $
%
% HISTORY: 09-05-07 M Hewitson
%             Creation
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function varargout = struct2obj(varargin)

% Get inputs
if isstruct(varargin{1})
  s = varargin{1};
else
  error('### Incorrect usage. The first argument should be a structure.');
end
if ischar(varargin{2})
  cl = varargin{2};
else
  error('### Incorrect usage. The second argument should be a class name (string).');
end

% Make an empty object
eobj = eval(cl);
% Get the specification of the required type
fnames = fieldnames(eobj);

% Loop over fields and try to set them from the structure


% Set output
varargout{1} = [];