File tree Expand file tree Collapse file tree 1 file changed +7
-52
lines changed Expand file tree Collapse file tree 1 file changed +7
-52
lines changed Original file line number Diff line number Diff line change 179179 error ("weboptions: invalid number of arguments");
180180 endif
181181
182- h = cell2struct (varargin(2 : 2 : end), varargin(1 : 2 : end), 2 );
183-
184- for fieldname = fieldnames (h)'
185-
186- switch (fieldname{1 })
187-
188- case "CharacterEncoding "
189- f.CharacterEncoding = h.CharacterEncoding;
190-
191- case "UserAgent "
192- f.UserAgent = h.UserAgent;
193-
194- case "Timeout "
195- f.Timeout = h.Timeout;
196-
197- case "Username "
198- f.Username = h.Username;
199-
200- case "Password "
201- f.Password = h.Password;
202-
203- case "KeyName "
204- f.KeyName = h.KeyName;
205-
206- case "KeyValue "
207- f.KeyValue = h.KeyValue;
208-
209- case "HeaderFields "
210- f.HeaderFields = h.HeaderFields;
211-
212- case "ContentType "
213- f.ContentType = h.ContentType;
214-
215- case "ContentReader "
216- f.ContentReader = h.ContentReader;
217-
218- case "MediaType "
219- f.MediaType = h.MediaType;
220-
221- case "RequestMethod "
222- f.RequestMethod = h.RequestMethod;
223-
224- case "ArrayFormat "
225- f.ArrayFormat = h.ArrayFormat;
226-
227- case "CertificateFilename "
228- f.CertificateFilename = h.CertificateFilename;
229-
230- otherwise
231- error ("weboptions: Undefined field '%s'", field);
232-
233- endswitch
182+ propnames = properties (f);
183+ for i = 1 : 2 : numel (varargin )
184+ idx = find (strcmpi (varargin{i}, propnames), 1 );
185+ if (isempty (idx))
186+ error ("weboptions: Undefined field '%s'", varargin{i});
187+ endif
188+ f. (propnames{idx}) = varargin{i+ 1 };
234189 endfor
235190
236191 endfunction
You can’t perform that action at this time.
0 commit comments