view m-toolbox/classes/+utils/@prog/obj2binary.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 (2011-12-07)
parents
f0afece42f48
children
line source
+ − % OBJ2BINARY Converts an object to binary representation
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ − %
+ − % DESCRIPTION: Converts an object to binary representation.
+ − %
+ − % CALL: bin = utils.prog.obj2binary(obj)
+ − %
+ − % INPUTS: obj - the object to be converted
+ − %
+ − % OUTPUTS: bin - the converted object
+ − %
+ − % VERSION: $Id: obj2binary.m,v 1.2 2010/05/18 18:27:35 nicolodi Exp $
+ − %
+ − %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ −
+ − function bin = obj2binary(objs)
+ −
+ − % get tmp filename
+ − fname = [tempname '.mat'];
+ −
+ − % Convert the objects into a struct if the MATLAB version is less than
+ − % R2008b because MATLAB have a internal bug with saving user defined
+ − % objects.
+ − v = ver('MATLAB');
+ − if utils.helper.ver2num(v.Version) < utils.helper.ver2num('7.7')
+ − warning('off', 'all')
+ − objs = utils.prog.rstruct(objs);
+ − warning('on', 'all')
+ − end
+ − save(fname, 'objs');
+ −
+ − fd = fopen(fname, 'r');
+ − bin = fread(fd, inf, 'int8=>int8');
+ − fclose(fd);
+ − delete(fname);
+ − end