comparison m-toolbox/classes/+utils/@helper/ver2num.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % VER2NUM converts a version string into a number.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % FUNCTION: ver2num
5 %
6 % DESCRIPTION: VER2NUM converts a version string into a number.
7 %
8 % CALL: ver_num = ver2num(ver_str);
9 %
10 % INPUTS: ver_str = major[.minor[.revision]] -> 1 or 1.2 or 1.2.3
11 %
12 % OUTPUT: ver_num = major * 1 + minor * 0.01 + revision * 0.0001
13 %
14 % EXAMPLES: '1' --> 1
15 % '1.2' --> 1.02
16 % '1.2.3' --> 1.0203
17 % '1.12.13' --> 1.1213
18 %
19 % VERSION: $Id: ver2num.m,v 1.2 2009/01/25 16:00:40 mauro Exp $
20 %
21 % HISTORY: 07-07-2008 Diepholz
22 % Creation
23 %
24 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25
26 function ver_num = ver2num(ver_str)
27
28 ver_num = getVerParts(ver_str) * [1; .01; .0001];
29
30 function parts = getVerParts(ver_str)
31
32 parts = sscanf(ver_str, '%d.%d.%d')';
33 if length(parts) < 3
34 parts(3) = 0; % zero-fills to 3 elements
35 end
36