summaryrefslogtreecommitdiff
path: root/matlab/lib/+Ice/stringToProtocolVersion.m
blob: 888863b4d2d60fd451db98f0a3afeee5b41802c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function r = stringToProtocolVersion(s)
    % stringToProtocolVersion  Converts a string to a protocol version.
    %
    % Parameters:
    %   s (char) - The string to convert.
    %
    % Returns (Ice.ProtocolVersion) - The converted protocol version.

    % Copyright (c) ZeroC, Inc. All rights reserved.

    tokens = regexp(s, '^([0-9]+)\.([0-9]+)$', 'tokens');
    if isempty(tokens)
        throw(MException('Ice:ArgumentException', 'expecting a version in X.Y format'));
    end
    r = Ice.ProtocolVersion(str2num(tokens{1}{1}), str2num(tokens{1}{2}));
end