view m-toolbox/classes/+utils/@helper/ver2num.m @ 39:11e3ed9d2115 database-connection-manager

Implement databases listing in database connection dialog
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% VER2NUM converts a version string into a number.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FUNCTION:    ver2num
%
% DESCRIPTION: VER2NUM converts a version string into a number.
%
% CALL:        ver_num = ver2num(ver_str);
%
% INPUTS:      ver_str = major[.minor[.revision]] -> 1 or 1.2 or 1.2.3
%
% OUTPUT:      ver_num = major * 1 + minor * 0.01 + revision * 0.0001
%
% EXAMPLES:    '1'       --> 1
%              '1.2'     --> 1.02
%              '1.2.3'   --> 1.0203
%              '1.12.13' --> 1.1213
%
% VERSION:     $Id: ver2num.m,v 1.2 2009/01/25 16:00:40 mauro Exp $
%
% HISTORY:     07-07-2008 Diepholz
%                 Creation
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function ver_num = ver2num(ver_str)

ver_num = getVerParts(ver_str) * [1; .01; .0001];

function parts = getVerParts(ver_str)

parts = sscanf(ver_str, '%d.%d.%d')';
if length(parts) < 3
  parts(3) = 0; % zero-fills to 3 elements
end