Mercurial > hg > ltpda
view m-toolbox/classes/@param/string.m @ 13:e05504b18072 database-connection-manager
Move more functions to utils.repository
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
% STRING writes a command string that can be used to recreate the input param object. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % DESCRIPTION: STRING writes a command string that can be used to recreate the % input param object. % % CALL: cmd = string(param_obj) % % INPUT: param_obj - parameter object % % OUTPUT: cmd - command string to create the input object % % VERSION: $Id: string.m,v 1.13 2011/02/18 16:48:53 ingo Exp $ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function varargout = string(varargin) objs = [varargin{:}]; cmd = ''; for ii = 1:numel(objs) key = objs(ii).key; val = objs(ii).getVal; if ischar(val) val_str = ['''' strrep(val, '''', '''''') '''']; elseif isnumeric(val) val_str = mat2str(val); elseif isa(val, 'ltpda_obj') val_str = string(val); elseif iscell(val) val_str = utils.prog.mcell2str(val); else error('### Unknown object [%s]', class(val)); end cmd = [cmd 'param(''' key ''', ' val_str ') ']; end %%% Wrap the command only in bracket if the there are more than one object if numel(objs) > 1 cmd = ['[' cmd(1:end-1) ']']; end %%% Prepare output varargout{1} = cmd; end