ADUtilities

public class ADUtilities

Defines a set of utilities to handle data related issues such as comparing two values of type Any.

  • Defines a comparison between two values.

    See more

    Declaration

    Swift

    public enum Comparison
  • Defines a computation between values.

    See more

    Declaration

    Swift

    public enum Operation
  • Compares two values of type Any to see if they are equal, not equal, less than, greater than, less than or equal to or greater than or equal to eachother. Both values must be of the same type and internally stored as a Int, Double, Float, String or Bool.

    Declaration

    Swift

    public static func compare(_ left: Any, _ comparison: Comparison, _ right: Any) -> Bool

    Parameters

    left

    The first value to compare.

    comparison

    The comparison to perform between the two values as equal, not equal, less than, greater than, less than or equal to or greater than or equal to.

    right

    The second value to compare.

    Return Value

    true if the two values are equal, not equal, less than, greater than, less than or equal to or greater than or equal to eachother (based on the requested comparison), else false.

  • Calculates the addition, subtraction, multiplication or division of two values of type Any. Both values must be of the same type and internally stored as a Int, Double, Float, String or Bool. String and Bool types support addition only. Additionally, String can be added to any other type and the result is a String with the value appended to it.

    Declaration

    Swift

    public static func compute(_ left: Any, _ operation: Operation, _ right: Any) -> Any

    Parameters

    left

    The first value to calculate.

    operation

    The operation to perform as addition, subtraction, multiplication or division.

    right

    The second value to calculate.

    Return Value

    The computed value or an error message (as String) if the computation is not valid.

  • Attempts to cast the given Any type value to the given SQL Database type.

    Declaration

    Swift

    public static func cast(_ input: Any, to type: ADSQLColumnType) throws -> Any

    Parameters

    input

    The value to convert.

    type

    The SQL database column type to convert the value to.

    Return Value

    The value converted to the requested type or throws an error if the type cannot be converted.