BoolCodingStrategy

public enum BoolCodingStrategy: Hashable

The encoding/decodig strategies used on boolean values in a CSV document.

  • The bools are represented by their number counter part, false is 0 and true is 1.

    Declaration

    Swift

    case integer
  • The bools are represented by their textual counter parts, false is "false" and true is "true".

    Declaration

    Swift

    case string
  • The bools are checked against multiple different values when they are decoded. They are encoded to their string values.

    When decoding data with this strategy, the characters in the data are lowercased and it is then checked against true, yes, y, y, and 1 for true and false, no, f, n, and 0 for false.

    Declaration

    Swift

    case fuzzy
  • A custom coding strategy with any given representations for the true and false values.

    Declaration

    Swift

    case custom(`true`: [UInt8],`false`: [UInt8])

    Parameters

    true

    The value that true gets converted to, and that true is represented by in the CSV document.

    false

    The value that false gets converted to, and that false is represented by in the CSV document.

  • Converts a Bool value to the bytes the reporesent it, given the current strategy.

    Declaration

    Swift

    public func bytes(from bool: Bool) -> [UInt8]

    Parameters

    bool

    The Bool instance to get the bytes for.

    Return Value

    The bytes value for the bool passed in.

  • Attempts get a Bool value from given bytes using the current strategy.

    Declaration

    Swift

    public func bool(from bytes: [UInt8]) -> Bool?

    Parameters

    bytes

    The bytes to chek against the expected value for the given strategy.

    Return Value

    The Bool value for the bytes passed in, or nil if no match is found.