time | Calls | line |
---|
| | 212 | function [validNames, modified] = makeValidName(names, modException)
|
| | 213 | %MAKEVALIDNAME Construct valid table row names. The only row
|
| | 214 | % not allowed is ':' to avoid ambiguous subscripting.
|
| | 215 | %
|
| | 216 | % MODEXCEPTION controls warning or error response when NAMES
|
| | 217 | % contains invalid names. Valid values for MODEXCEPTION are
|
| | 218 | % 'silent' and 'error'.
|
| | 219 | import matlab.internal.datatypes.warningWithoutTrace;
|
| | 220 | import matlab.internal.tabular.private.rowNamesDim.checkReservedNames;
|
| | 221 |
|
< 0.001 | 8 | 222 | if modException == "error"
|
< 0.001 | 7 | 223 | validNames = names; % return the originals, or possibly error
|
< 0.001 | 7 | 224 | if ischar(names), names = { names }; end % unusual case, not optimized
|
< 0.001 | 7 | 225 | checkReservedNames(names);
|
< 0.001 | 7 | 226 | modified = false(size(names));
|
| 1 | 227 | else % make names valid
|
< 0.001 | 1 | 228 | validNames = names;
|
0.001 | 1 | 229 | conflicted = checkReservedNames(names);
|
< 0.001 | 1 | 230 | if any(conflicted)
|
| | 231 | validNames(conflicted) = matlab.lang.makeUniqueStrings(validNames(conflicted), validNames,namelengthmax);
|
< 0.001 | 1 | 232 | end
|
| 1 | 233 | modified = conflicted;
|
< 0.001 | 1 | 234 | if any(modified)
|
| | 235 | switch modException % error or warn per level specified
|
| | 236 | case 'silent'
|
| | 237 | % Only used by readtable
|
| | 238 | case 'warn' % Only used by loadobj
|
| | 239 | warningWithoutTrace(message('MATLAB:table:RowNameReservedBackCompat'));
|
| | 240 | otherwise
|
| | 241 | assert(false);
|
| | 242 | end
|
| 1 | 243 | end
|
< 0.001 | 8 | 244 | end
|
< 0.001 | 8 | 245 | end
|
Other subfunctions in this file are not included in this listing.