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
is0
andtrue
is1
.Declaration
Swift
case integer
-
The bools are represented by their textual counter parts,
false
is"false"
andtrue
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
, and1
for true andfalse
,no
,f
,n
, and0
for false.Declaration
Swift
case fuzzy
-
A custom coding strategy with any given representations for the
true
andfalse
values.Declaration
Swift
case custom(`true`: [UInt8],`false`: [UInt8])
Parameters
true
The value that
true
gets converted to, and thattrue
is represented by in the CSV document.false
The value that
false
gets converted to, and thatfalse
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, ornil
if no match is found.