Home > vbmeg > functions > common > utility > vb_version.m

vb_version

PURPOSE ^

This function is to know vbmeg version information.

SYNOPSIS ^

function [varargout] = vb_version(varargin)

DESCRIPTION ^

 This function is to know vbmeg version information.
 Usage: [major, minor, alpha_beta, revision] = vb_version;
        [comparative_result] = vb_version(comparative_operator, ver_str);
        [comparative_result] = vb_version(ver_str);

 --- Format1
 [major, minor, alpha_beta, revision] = vb_version;

 example:
     vbmeg version : 0.5-0.a.0
      major= 0.5, minor = 0, alpha_beta = 'a', revision = 0

 --- Format2
 [comparative_result] = vb_version(comparative_operator, ver_str);

 [IN]
   comparative_operator : '==' or '~=' or '<' or '<=' or '>' or '>='
   ver_str              : version string formatted as below.
                          'major-minor.alpha_veta.revision'
                          ex.'0.5-0.a.0'
 [OUT]
   comparative_result : true or false.

 EXAMPLES
   If the VBMEG version is '0.5-1.a.0', and the user supplied version is '0.5':
   result = vb_version('==', '0.5');
   return result == true  : major numbers are same.

   If the VBMEG version is '0.5-9.a.0', and the user supplied version is '0.5-8':
   result = vb_version('>', '0.5-8');
   return result == true

   If the VBMEG version is '0.4-3.a.0', and the user supplied version is '0.4-2.b.1':
   result = vb_version('<', '0.4-2.b.1');
   return result == false

 --- Format3
  [comparative_result] = vb_version(ver_str);

 [IN]
   ver_str              : version string formatted as below.
                          'major-minor.alpha_veta.revision'
                          ex.'0.5-0.a.0'
 [OUT]
   comparative_result : true or false.

   This is the same with result = vb_version('==', ver_str);

 [history]
 2010-12-07 taku-y
  [internal change] vb_version_cmp is used.

 Copyright (C) 2011, ATR All Rights Reserved.
 License : New BSD License(see VBMEG_LICENSE.txt)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [varargout] = vb_version(varargin)
0002 % This function is to know vbmeg version information.
0003 % Usage: [major, minor, alpha_beta, revision] = vb_version;
0004 %        [comparative_result] = vb_version(comparative_operator, ver_str);
0005 %        [comparative_result] = vb_version(ver_str);
0006 %
0007 % --- Format1
0008 % [major, minor, alpha_beta, revision] = vb_version;
0009 %
0010 % example:
0011 %     vbmeg version : 0.5-0.a.0
0012 %      major= 0.5, minor = 0, alpha_beta = 'a', revision = 0
0013 %
0014 % --- Format2
0015 % [comparative_result] = vb_version(comparative_operator, ver_str);
0016 %
0017 % [IN]
0018 %   comparative_operator : '==' or '~=' or '<' or '<=' or '>' or '>='
0019 %   ver_str              : version string formatted as below.
0020 %                          'major-minor.alpha_veta.revision'
0021 %                          ex.'0.5-0.a.0'
0022 % [OUT]
0023 %   comparative_result : true or false.
0024 %
0025 % EXAMPLES
0026 %   If the VBMEG version is '0.5-1.a.0', and the user supplied version is '0.5':
0027 %   result = vb_version('==', '0.5');
0028 %   return result == true  : major numbers are same.
0029 %
0030 %   If the VBMEG version is '0.5-9.a.0', and the user supplied version is '0.5-8':
0031 %   result = vb_version('>', '0.5-8');
0032 %   return result == true
0033 %
0034 %   If the VBMEG version is '0.4-3.a.0', and the user supplied version is '0.4-2.b.1':
0035 %   result = vb_version('<', '0.4-2.b.1');
0036 %   return result == false
0037 %
0038 % --- Format3
0039 %  [comparative_result] = vb_version(ver_str);
0040 %
0041 % [IN]
0042 %   ver_str              : version string formatted as below.
0043 %                          'major-minor.alpha_veta.revision'
0044 %                          ex.'0.5-0.a.0'
0045 % [OUT]
0046 %   comparative_result : true or false.
0047 %
0048 %   This is the same with result = vb_version('==', ver_str);
0049 %
0050 % [history]
0051 % 2010-12-07 taku-y
0052 %  [internal change] vb_version_cmp is used.
0053 %
0054 % Copyright (C) 2011, ATR All Rights Reserved.
0055 % License : New BSD License(see VBMEG_LICENSE.txt)
0056 
0057 switch(nargin)
0058     case 0 % [major, minor, revision] = vb_version;
0059         [ret] = inner_get_version;
0060         varargout{1} = ret{1};
0061         varargout{2} = ret{2};
0062         varargout{3} = ret{3};
0063         varargout{4} = ret{4};
0064     case 1 % [comparative_result] = vb_version('0.5-0.a.0');
0065         input_str = varargin{1};
0066         if ~ischar(input_str)
0067             error('version string should be string.');
0068         end
0069         %[result] = compare_version('==', input_str);
0070         [result] = vb_version_cmp(inner_get_version(true), '==', ...
0071                                   input_str);
0072         varargout{1} = result;
0073     case 2 % [comparative_result] = vb_version('==', '0.5-0.a.0');
0074         comparative_operator = varargin{1};
0075         input_str = varargin{2};
0076         if ~ischar(input_str)
0077             error('version string should be string.');
0078         end
0079         %[result] = compare_version(comparative_operator, input_str);
0080         [result] = vb_version_cmp(inner_get_version(true), ...
0081                                   comparative_operator, input_str);
0082         varargout{1} = result;
0083 end
0084 
0085 
0086 %%%%%%%%%%%%%%%%%%%
0087 % inner functions
0088 %
0089 function [ret] = inner_get_version(isstr)
0090 
0091 if nargin==0, isstr = false; end
0092 
0093 ret = cell(4,1);
0094 ret{1} = 3.0;      % major version
0095 ret{2} = 0;        % minor version
0096 ret{3} = 'a';      % alpha beta information
0097 ret{4} = 1;        % revision
0098 
0099 if isstr
0100   ret = sprintf('%.1f-%d.%c.%d', ret{1}, ret{2}, ret{3}, ret{4});
0101 end
0102 
0103 return;

Generated on Mon 22-May-2023 06:53:56 by m2html © 2005