SFS2X Objective-C API  1.7.13
iOS / macOS / tvOS
MatchExpression Class Reference

#import <MatchExpression.h>

Inherits NSObject.

Instance Methods

(id) - initWithVarName:condition:value:
 
(MatchExpression *) - and:condition:value:
 
(MatchExpression *) - or:condition:value:
 
(BOOL) - hasNext
 
(MatchExpression *) - rewind
 
(NSString *) - asString
 
(id< ISFSArray >) - toSFSArray
 
(id< ISFSArray >) - expressionAsSFSArray
 

Class Methods

(id) + expressionWithVarName:condition:value:
 

Properties

NSString * varName
 
id< IMatcher > condition
 
id value
 
LogicOperatorlogicOp
 
MatchExpressionparent
 
MatchExpressionnext
 

Detailed Description

Match Expressions are built like "if" conditions in any common programming language.

They work like queries in a database and can be used to search for Rooms or Users using custom criteria. These expressions are extremely easy to create and concatenate and they can be used for many different filtering operations within the SFS2X framework.

This is a quick example:

MatchExpression *exp = [MatchExpression expressionWithVarName:@"rank" condition:[NumberMatch numberMatchGreaterThan] value:[NSNumber numberWithInt:5]];
exp = [exp and:@"country" condition:[StringMatch stringMatchEquals] value:@"Italy"];

Expressions are made of three elements:

Additionally any number of expressions can be linked together with a logical AND / OR operator, just like in regular code. In the above example we have created an expression that will check for a rank value > 5 and a country value == "Italy".

The search options are not just limited to User/Room Variables name. In fact the Matching engine provides two extra classes, RoomProperties and UserProperties, where you can access many specific attributes of the Room and User class.

See also
RoomProperties
UserProperties

Method Documentation

◆ and:condition:value:

- (MatchExpression *) and: (NSString *)  varName
condition: (id <IMatcher>)  condition
value: (id)  value 

Concatenate the current expression with a new one using the logical AND operator

Parameters
varNamename of the variable/property to match
conditionthe match condition
valuethe value to match against

return a new MatchExpression

◆ expressionWithVarName:condition:value:

+ (id) expressionWithVarName: (NSString *)  varName
condition: (id <IMatcher>)  condition
value: (id)  value 
Parameters
varNamename of the variable/property to match
conditionthe match condition
valuethe value to match against

◆ hasNext

- (BOOL) hasNext

Check if the current expression is concatenated to another one via a logic operator

See also
LogicOperator

◆ or:condition:value:

- (MatchExpression *) or: (NSString *)  varName
condition: (id <IMatcher>)  condition
value: (id)  value 

Concatenate the current expression with a new one using the logical OR operator

Parameters
varNamename of the variable/property to match
conditionthe match condition
valuethe value to match against

return a new MatchExpression

◆ rewind

- (MatchExpression *) rewind

Rewinds the cursor to the first expression in the chain and return the MatchExpression at the top of the chain of expressions

Property Documentation

◆ condition

- (id<IMatcher>) condition
readwritenonatomicstrong

Get the condition used for matching

See also
BoolMatch
NumberMatch
StringMatch

◆ logicOp

- (LogicOperator*) logicOp
readwritenonatomicstrong

Get the current logic operator, could be null if the expression has no other concatenated expressions

See also
LogicOperator

◆ next

- (MatchExpression*) next
readwritenonatomicstrong

Get the next expression chained to the current one.

◆ value

- (id) value
readwritenonatomicstrong

The value used to test the condition in the expression

◆ varName

- (NSString*) varName
readwritenonatomicstrong

Get the name of the variable or property that is being matched.

This can be the name of a User/Room variable or a property from the classes listed below.

See also
RoomProperties
UserProperties
MatchExpression
Definition: MatchExpression.h:42
StringMatch
Definition: StringMatch.h:17
NumberMatch
Definition: NumberMatch.h:17
MatchExpression::condition
id< IMatcher > condition
Definition: MatchExpression.h:68
MatchExpression::value
id value
Definition: MatchExpression.h:72