view m-toolbox/classes/+utils/@helper/saveobj.m @ 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +0100
parents f0afece42f48
children
line wrap: on
line source

function varargout = saveobj(a, pl)
% SAVEOBJ saves an object to a file.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% DESCRIPTION: SAVEOBJ saves an object to a file.
%
% CALL:      saveobj(obj, pl)
%
% INPUTS:     obj  - an object (for example, an AO)
%             pl   - parameter list with a 'filename' parameter
%
% Supported file types are '.mat' and '.xml'.
% 
% OUTPUTS:
%
% VERSION: $Id: saveobj.m,v 1.3 2010/09/17 14:12:31 ingo Exp $
%
% HISTORY: 28-08-2007 M Hewitson
%             Creation
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% get filename
filename = find(pl, 'filename');

% Inspect filename
[path,name,ext] = fileparts(filename);

switch ext
  case '.mat'

    save(filename, 'a');

  case '.xml'

    % convert object to xml
    xml = com.mathworks.xml.XMLUtils.createDocument('ltpda_object');
    parent = xml.getDocumentElement;

    utils.xml.xmlwrite(a, xml, parent, '');    % Save the XML document.
    xmlwrite(filename, xml);

  otherwise
    error('### unknown file extension.');
end