String

class props.String

String prop

This is a type of props.Prop that can be used when a props.HasProps class needs a string property. PROPS.STRING can either accept any string or only certain spcecified strings.

Attributes (in addition to those inherited from props.Prop):

Choices:
The available choices for the string property. If choices is not specified, any string will be considered valid. If choices is a nested cell array of strings, only those choices are valid. Choices may also be a struct with strings as fields and nested cell array of strings as values. This allows several different strings (the values) to be coerced into a single string (the field). Note: The requirement for nesting the cell array is necessary to subvert MATLAB’s default treatment of cell arrays contained in structs. See example below for the implementation of each of these types of Choices.
Lowercase:
If true, the input string is coerced to all-lowercase. If false and Choices are set, the string is coerced to the case found in Choices. If false and Choices is not set, the string is kept as-is.

Example:

...
class HasStringProps < props.HasProps
    properties (Hidden, SetAccess = immutable)
        StringPropsStruct = {                                   ...
            struct(                                             ...
                'Name', 'AnyString',                            ...
                'Type', @props.String,                          ...
                'Doc', 'This property can be any string'        ...
            ), struct(                                          ...
                'Name', 'ChoiceString',                         ...
                'Type', @props.String,                          ...
                'Doc', 'This property can only be hi or bye',   ...
                'Choices', {{'hi', 'bye'}},                     ...
                'DefaultValue', 'hi'                            ...
            ), struct(                                          ...
                'Name', 'CoercedChoiceString',                  ...
                'Type', @props.String,                          ...
                'Doc', 'This coerces hi and bye to English',    ...
                'Choices', struct(                              ...
                    'hi', {{'hola', 'bonjour', 'guten tag'}},   ...
                    'bye', {{'adios', 'au revoir',              ...
                             'auf Wiedersehen'}}                ...
                ),                                              ...
                'DefaultValue', 'hi'                            ...
            )                                                   ...
        }
    end
    ...
end

See also props.Prop, props.HasProps, props.Color, props.Bool