Home > classes > @plist > string.m

string

PURPOSE ^

STRING converts a plist object to a command string which will recreate the plist object.

SYNOPSIS ^

function varargout = string(varargin)

DESCRIPTION ^

 STRING converts a plist object to a command string which will recreate the plist object.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: STRING converts a plist object to a command string which will
              recreate the plist object.

 CALL:        cmd = string(pl)

 M-FILE INFO: Get information about this methods by calling
              >> plist.getInfo('string')

              Get information about a specified set-plist by calling:
              >> plist.getInfo('string', 'set')

 VERSION:     $Id: string.m,v 1.21 2008/09/04 15:29:31 ingo Exp $

 HISTORY:     29-03-2007 M Hewitson
                 Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 % STRING converts a plist object to a command string which will recreate the plist object.
0002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0003 %
0004 % DESCRIPTION: STRING converts a plist object to a command string which will
0005 %              recreate the plist object.
0006 %
0007 % CALL:        cmd = string(pl)
0008 %
0009 % M-FILE INFO: Get information about this methods by calling
0010 %              >> plist.getInfo('string')
0011 %
0012 %              Get information about a specified set-plist by calling:
0013 %              >> plist.getInfo('string', 'set')
0014 %
0015 % VERSION:     $Id: string.m,v 1.21 2008/09/04 15:29:31 ingo Exp $
0016 %
0017 % HISTORY:     29-03-2007 M Hewitson
0018 %                 Creation
0019 %
0020 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0021 
0022 function varargout = string(varargin)
0023 
0024   %%% Check if this is a call for parameters
0025   if utils.helper.isinfocall(varargin{:})
0026     varargout{1} = getInfo(varargin{3});
0027     return
0028   end
0029 
0030   objs = utils.helper.collect_objects(varargin(:), 'plist');
0031 
0032   pstr = '';
0033 
0034   for ii = 1:numel(objs)
0035     pl   = objs(ii);
0036 
0037     if ~isempty(pl.params)
0038       pstr = [pstr 'plist('];
0039       for j=1:length(pl.params)
0040         p = pl.params(j);
0041         if ischar(p.val)
0042           pstr = [pstr ''''  p.key ''', ''' char(p.val) ''', '];
0043         elseif isnumeric(p.val)
0044           pstr = [pstr ''''  p.key ''', ' utils.helper.mat2str(p.val) ', '];
0045         elseif isa(p.val, 'ao')
0046           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0047         elseif isa(p.val, 'history')
0048           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0049         elseif isa(p.val, 'miir')
0050           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0051         elseif isa(p.val, 'mfir')
0052           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0053         elseif isa(p.val, 'specwin')
0054           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0055         elseif isa(p.val, 'pz') || isa(p.val, 'pole') || isa(p.val, 'zero') || isa(p.val, 'pzmodel')
0056           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0057         elseif isa(p.val, 'time')
0058           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0059         elseif isa(p.val, 'plist')
0060           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0061         elseif isa(p.val, 'timeformat')
0062           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0063         elseif isa(p.val, 'timespan')
0064           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0065         elseif isa(p.val, 'param')
0066           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0067         elseif isa(p.val, 'provenance')
0068           pstr = [pstr '''' p.key ''', ' string(p.val) ', '];
0069         elseif iscell(p.val)
0070           val_str = ['{ '];
0071           for ii = 1:numel(p.val)
0072             cell_val = p.val{ii};
0073             if ischar(cell_val)
0074               val_str = [val_str '''' p.val{ii} ''', ' ];
0075             elseif isnumeric(cell_val)
0076               val_str = [val_str utils.helper.mat2str(p.val{ii}) ', ' ];
0077             elseif isobject(cell_val)
0078               val_str = [val_str string(p.val{ii}) ', ' ];
0079             else
0080               error('### Unknown object in cell array');
0081             end
0082           end
0083           val_str = val_str(1:end-2);
0084           val_str = [val_str ' }'];
0085           pstr = [pstr '''' p.key ''', ' val_str ', '];
0086         elseif isa(p.val, 'cdata') || isa(p.val, 'fsdata') || ...
0087             isa(p.val, 'tsdata')|| isa(p.val, 'xydata') || ...
0088             isa(p.val, 'xyzdata')
0089           pstr = [pstr '''' p.key ''', ' class(p.val) '(), '];
0090         else
0091           error('!!! Can not handle the class [%s].', class(p.val));
0092         end
0093       end
0094 
0095       % close bracket
0096       if ~isempty(pstr)
0097         pstr = pstr(1:end-2);
0098       end
0099       pstr = [pstr '), '];
0100     else
0101       pstr = [pstr 'plist(), '];
0102     end
0103   end
0104 
0105   if numel(objs) > 1
0106     pstr = ['[ ' pstr(1:end-2) ' ]'];
0107   else
0108     pstr = pstr(1:end-2);
0109   end
0110 
0111   varargout{1} = pstr;
0112 end
0113 
0114 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0115 %                               Local Functions                               %
0116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0117 
0118 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0119 %
0120 % FUNCTION:    getInfo
0121 %
0122 % DESCRIPTION: Get Info Object
0123 %
0124 % HISTORY:     11-07-07 M Hewitson
0125 %                Creation.
0126 %
0127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0128 
0129 function ii = getInfo(varargin)
0130   if nargin == 1 && strcmpi(varargin{1}, 'None')
0131     sets = {};
0132     pl   = [];
0133   else
0134     sets = {'Default'};
0135     pl   = getDefaultPlist;
0136   end
0137   % Build info object
0138   ii = minfo(mfilename, 'plist', '', utils.const.categories.helper, '$Id: string.m,v 1.21 2008/09/04 15:29:31 ingo Exp $', sets, pl);
0139 end
0140 
0141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0142 %
0143 % FUNCTION:    getDefaultPlist
0144 %
0145 % DESCRIPTION: Get Default Plist
0146 %
0147 % HISTORY:     11-07-07 M Hewitson
0148 %                Creation.
0149 %
0150 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0151 
0152 function plo = getDefaultPlist()
0153   plo = plist();
0154 end
0155

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003