1function [properties, remArgs] = createProperties(varargin)
2    % createProperties  Creates a property set, optionally initialized from an
3    %   argument vector and default properties.
4    %
5    % Examples:
6    %   props = Ice.createProperties();
7    %   [props, remArgs] = Ice.createProperties(args);
8    %   props = Ice.createProperties(defaults);
9    %   [props, remArgs] = Ice.createProperties(args, defaults);
10    %
11    % Parameters:
12    %   args (cell array of char) - A command-line argument vector, possibly
13    %     containing options to set properties. If the command-line options include
14    %     a --Ice.Config option, the corresponding configuration files are parsed.
15    %     If the same property is set in a configuration file and in the argument
16    %     vector, the argument vector takes precedence.
17    %   defaults (Ice.Properties) - A property set used to initialize the default
18    %     state of the new property set. Settings in configuration files and the
19    %     argument vector override these defaults.
20    %
21    % Returns:
22    %   properties (Ice.Properties) - A new property set initialized with the property
23    %     settings that were removed from the argument vector and the default property set.
24    %   remArgs (cell array of char) - Contains the remaining command-line arguments
25    %     that were not used to set properties.
26
27    % Copyright (c) ZeroC, Inc. All rights reserved.
28
29    if length(varargin) >= 1 && ~isempty(varargin{1})
30        args = varargin{1};
31    else
32        args = {};
33    end
34    if length(varargin) >= 2 && ~isempty(varargin{2})
35        if ~isa(varargin{2}, 'Ice.Properties')
36            throw(MException('Ice:ArgumentException', 'expecting Ice.Properties object'));
37        end
38        defaults = varargin{2}.impl_;
39    else
40        defaults = libpointer('voidPtr');
41    end
42    impl = libpointer('voidPtr');
43    remArgs = IceInternal.Util.callWithResult('Ice_createProperties', args, defaults, impl);
44    properties = Ice.Properties(impl);
45end
46