RSDStringLiteralOptionSet

public protocol RSDStringLiteralOptionSet : Decodable, Encodable, OptionSet

RSDStringLiteralOptionSet extends OptionSet to allow mapping any OptionSet that uses a BinaryInteger as its RawValue to a set of string keys.

Seealso

RSDActiveUICommand for example usage.
  • A mapping of an option to a string value. This is used to allow Codable protocol conformance using human-readable strings rather than Binary flags.

    Declaration

    Swift

    static var stringMapping: [String : RawValue] { get }
  • A convenience method for mapping a rawValue to a String.

    Declaration

    Swift

    static func set(rawValue: RawValue, forKey: String)

    Parameters

    rawValue

    The raw value for this command.

    forKey

    The string representation.

  • init(_:codingKey:) Extension method

    Initialize a option step value using both the binary raw value and the coding key to use when coding the value.

    Declaration

    Swift

    public init(_ rawValue: RawValue, codingKey: String)

    Parameters

    rawValue

    The raw value for this command.

    codingKey

    The string representation.

  • init(from:stringMapping:) Extension method

    Creates a new instance by decoding from the given decoder.

    This initializer throws an error if reading from the decoder fails, or if the data read is corrupted or otherwise invalid.

    Declaration

    Swift

    public init(from decoder: Decoder, stringMapping: [String : RawValue]) throws

    Parameters

    decoder

    The decoder to read data from.

    stringMapping

    The mapping of coding strings to the associated raw value.

  • encode(to:) Extension method

    Method for encoding the value back into an array of strings.

    Declaration

    Swift

    public func encode(to encoder: Encoder) throws

    Parameters

    encoder

    The encoder to encode this value to.