time | Calls | line |
---|
< 0.001 | 45 | 1 | classdef VarOptsInputs < matlab.io.internal.FunctionInterface ...
|
| | 2 | & matlab.io.internal.shared.TreatAsMissingInput ...
|
| | 3 | & matlab.io.internal.shared.CommonVarOpts
|
| | 4 | %
|
| | 5 |
|
| | 6 | % Copyright 2018-2019 The MathWorks, Inc.
|
| | 7 |
|
| | 8 | properties (Access = {?matlab.io.internal.shared.NumericVarOptsInputs,...
|
| | 9 | ?matlab.io.internal.functions.ReadMatrixWithImportOptions,...
|
| | 10 | ?matlab.io.VariableImportOptions,...
|
| | 11 | ?matlab.io.internal.functions.DetectImportOptions,...
|
| | 12 | ?matlab.io.internal.FastVarOpts,...
|
| | 13 | ?matlab.io.internal.builders.Builder})
|
| | 14 | Name_ = '';
|
| | 15 | Type_ = '';
|
| | 16 | FillValue_;
|
| | 17 | end
|
| | 18 |
|
| | 19 | properties (Parameter)
|
| | 20 | %NAME
|
| | 21 | % Name of the variable to be imported. Must be a valid identifier.
|
| | 22 | %
|
| | 23 | % See also matlab.io.VariableImportOptions
|
| | 24 | Name
|
| | 25 |
|
| | 26 | %TYPE
|
| | 27 | % The input type of the variable when imported.
|
| | 28 | %
|
| | 29 | % See also matlab.io.VariableImportOptions
|
| | 30 | Type
|
| | 31 |
|
| | 32 | %FILLVALUE
|
| | 33 | % Used as a replacement value when ErrorRule = 'fill' or
|
| | 34 | % MissingRule = 'fill'. The valid types depend on the value of TYPE.
|
| | 35 | %
|
| | 36 | % See also matlab.io.VariableImportOptions
|
| | 37 | % matlab.io.spreadsheet.SpreadsheetImportOptions/MissingRule
|
| | 38 | % matlab.io.spreadsheet.SpreadsheetImportOptions/ImportErrorRule
|
| | 39 | % matlab.io.VariableImportOptions/Type
|
| | 40 | FillValue
|
| | 41 | end
|
| | 42 | % get/set functions
|
| | 43 | methods
|
| | 44 | function obj = set.Name(obj,rhs)
|
| | 45 | rhs = convertCharsToStrings(rhs);
|
| | 46 | if ~(isstring(rhs) && isscalar(rhs))
|
| | 47 | error(message('MATLAB:textio:textio:InvalidStringProperty','Name'));
|
| | 48 | end
|
| | 49 |
|
| | 50 | % Make sure that the Variable Options name is non-empty and
|
| | 51 | % not greater than namelengthmax.
|
| | 52 | stringLength = strlength(rhs);
|
| | 53 | if stringLength == 0 || stringLength > namelengthmax
|
| | 54 | error(message('MATLAB:table:VariableNameNotValidIdentifier', rhs));
|
| | 55 | end
|
| | 56 |
|
| | 57 | obj.Name_ = char(rhs);
|
| | 58 | end
|
| | 59 |
|
| | 60 | function val = get.Name(opts)
|
| | 61 | val = opts.Name_;
|
| | 62 | end
|
| | 63 |
|
| | 64 | function obj = set.Type(obj,val)
|
| | 65 | val = convertStringsToChars(val);
|
| | 66 | obj.Type_ = setType(obj,val);
|
| | 67 | end
|
| | 68 |
|
| | 69 | function val = get.Type(obj)
|
| | 70 | val = getType(obj,obj.Type_);
|
| | 71 | end
|
| | 72 |
|
| | 73 | function obj = set.FillValue(obj,val)
|
| | 74 | obj.FillValue_ = setFillValue(obj,val);
|
| | 75 | end
|
| | 76 |
|
| | 77 | function val = get.FillValue(obj)
|
| | 78 | % Converts to the correct type
|
| | 79 | val = getFillValue(obj,obj.FillValue_);
|
| | 80 | end
|
| | 81 | end
|
| | 82 |
|
| | 83 | methods (Hidden, Sealed)
|
| | 84 | function opts = setNames(opts,names)
|
| | 85 | % avoid validating names
|
| | 86 | if ~isempty(names)
|
| | 87 | ids = ~strcmp(names,{opts.Name_});
|
| | 88 | for id = find(ids)
|
| | 89 | opts(id).Name_ = names{id};
|
| | 90 | end
|
| | 91 | end
|
| | 92 | end
|
| | 93 |
|
| | 94 | function names = getNames(opts)
|
| | 95 | % avoid validating names
|
| | 96 | names = {opts.Name_};
|
| | 97 | end
|
| | 98 | end
|
| | 99 |
|
| | 100 | methods (Abstract,Access = protected)
|
| | 101 | type = setType(obj,val);
|
| | 102 | type = getType(obj,val);
|
| | 103 | val = setFillValue(obj,val);
|
| | 104 | val = getFillValue(obj,val);
|
| | 105 | end
|
| | 106 |
|
| | 107 | methods (Static)
|
| | 108 | function validateFixedType(name,type,rhs)
|
| | 109 | import matlab.io.internal.supportedTypeNames
|
| | 110 | rhs = convertCharsToStrings(rhs);
|
| | 111 | if ~isstring(rhs) || ~any(strcmp(supportedTypeNames,rhs))
|
| | 112 | error(message('MATLAB:textio:io:NotDataType'));
|
| | 113 | end
|
| | 114 | newMsg = [getString(message('MATLAB:textio:io:StaticOptionsType',type)), ...
|
| | 115 | '\n\n',getString(message('MATLAB:textio:io:Setdatatype')), '\n', ...
|
| | 116 | getString(message('MATLAB:textio:io:SetvartypeSyntax',name,rhs))];
|
| | 117 | throw(MException('MATLAB:textio:io:StaticOptionsType',newMsg));
|
| | 118 | end
|
| | 119 | end
|
| | 120 | end
|
| | 121 |
|