Expression

Class represents single expression that is added in curly brackets inside key in Localizable.strings file or as a value in Expressions.strings file.

It is able to validate passed string using internal expression matcher.

  • Pattern of expression passed during initialization.

    Declaration

    Swift

    let pattern: ExpressionPattern
  • Type of expression computed based on pattern.

    Declaration

    Swift

    private var type: ExpressionType!
  • Matcher created based on pattern.

    Declaration

    Swift

    private var matcher: ExpressionMatcher!
  • Return ExpressionPattern object if passed str parameter contains some pattern. The pattern may not be one of the supported one. If the syntax of the passed string is correct it is treated as pattern.

    Declaration

    Swift

    class func parseExpressionPattern(str: String) -> ExpressionPattern?

    Parameters

    str

    string which may or may not contain a pattern.

    Return Value

    ExpressionPattern object or nil when pattern is not found.

  • Tries to parse passed str parameter and created Expression from it. If passed string contains expression that is supported and inside logic compute that this string is some supported pattern an Expression object will be returned.

    Declaration

    Swift

    class func expressionFromString(str: String) -> Expression?

    Parameters

    str

    string that may or may not contain expression pattern

    Return Value

    Expression object or nil if pattern is not supported.

  • Initializer that takes expression pattern. It may fail when expression type of passed expression is not supported.

    Declaration

    Swift

    init?(pattern: ExpressionPattern)

    Parameters

    pattern

    pattern of expression

    Return Value

    Expression object or nil when pattern is not supported.

  • Method that validates passed string.

    Declaration

    Swift

    func validate(value: String) -> Bool

    Parameters

    value

    value that should be matched

    Return Value

    true if value match expression, otherwise false.

  • Method used to create ExpressionMatcher instance that match expression pattern of this Expression object.

    Declaration

    Swift

    private func buildMatcher()
  • Method used to get ExpressionType of passed ExpressionPattern.

    Declaration

    Swift

    private class func getExpressionType(pattern: ExpressionPattern) -> ExpressionType?

    Parameters

    pattern

    expression pattern that will be checked.

    Return Value

    ExpressionType if pattern is supported, otherwise nil.