Inherits from NSObject
Declared in MatchExpression.h
MatchExpression.m

Overview

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:

  • Variable name
  • Match operator
  • Value

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 RoomProperties, UserProperties

Properties

condition

Get the condition used for matching

@property (nonatomic, strong) id<IMatcher> condition

Discussion

Get the condition used for matching

Declared In

MatchExpression.h

logicOp

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

@property (nonatomic, strong) LogicOperator *logicOp

Discussion

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

See Also

Declared In

MatchExpression.h

next

Get the next expression chained to the current one.

@property (nonatomic, strong) MatchExpression *next

Discussion

Get the next expression chained to the current one.

Declared In

MatchExpression.h

value

The value used to test the condition in the expression

@property (nonatomic, strong) id value

Discussion

The value used to test the condition in the expression

Declared In

MatchExpression.h

varName

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

@property (nonatomic, strong) NSString *varName

Discussion

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.

Declared In

MatchExpression.h

Class Methods

expressionWithVarName:condition:value:

name of the variable/property to match

+ (id)expressionWithVarName:(NSString *)varName condition:(id<IMatcher>)condition value:(id)value

Parameters

varName

name of the variable/property to match

condition

the match condition

value

the value to match against

Declared In

MatchExpression.h

Instance Methods

and:condition:value:

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

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

Parameters

varName

name of the variable/property to match

condition

the match condition

value

the value to match against

return a new MatchExpression

Discussion

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

Declared In

MatchExpression.h

hasNext

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

- (BOOL)hasNext

Discussion

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

See Also

Declared In

MatchExpression.h

or:condition:value:

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

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

Parameters

varName

name of the variable/property to match

condition

the match condition

value

the value to match against

return a new MatchExpression

Discussion

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

Declared In

MatchExpression.h

rewind

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

- (MatchExpression *)rewind

Discussion

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

Declared In

MatchExpression.h