SetParenthesesCount
Purpose
The CMetaFilterInfo SetParenthesesCount function sets the number of open parentheses to place before this search argument or the number of close parentheses to place after the argument.
Description
The precedence of the search properties can be set.
The total number of open parentheses set in the CMetaFilterInfo list must match the total number of close parentheses set.
Syntax
void SetOpenParenthesesCount(const short CountArg);
void SetCloseParenthesesCount(const short CountArg);
Argument |
In/Out |
Description |
CountArg |
In |
For SetOpenParenthesesCount, the number of open parentheses to place before this property in the search SQL. For SetCloseParenthesesCount, the number of close parentheses to place after this property in the search SQL |
Example
With three search properties and a search precedence of:
Name=’basket’ AND (Type>10 OR Size<999)
The open count of the Parentheses in the CMetaFilterInfo object for the “Type” property would be set to 1. The close count of the Parentheses Count in the CMetaFilterInfo object for the “Size” property would be set to 1. The following is an example of how this would be coded:
CLEARVECTOR(propFilter);
filterInfo.value.SetPropertyID(PID_CMN_NAME);
filterInfo.SetComparisonOperator(EQUAL);
filterInfo.value.SetString(_T("basket"));
filterInfo.SetLogicalOperator(META_AND);
propFilter.push_back(filterInfo);
filterInfo.Initialize();
filterInfo.value.SetPropertyID(10);
filterInfo.SetComparisonOperator(GREATER_THAN);
filterInfo.value.SetInt(10);
filterInfo.SetOpenParenthesesCount(1); // Open Parenthesis Count = 1
filterInfo.SetLogicalOperator(META_OR);
propFilter.push_back(filterInfo);
filterInfo.Initialize();
filterInfo.value.SetPropertyID(12);
filterInfo.SetComparisonOperator(LESS_THAN);
filterInfo.value.SetInt(999);
filterInfo.SetCloseParenthesesCount(1); // Close Parenthesis Count = 1
propFilter.push_back(filterInfo);
propID.SetObjectID(PID_CMN_NAME);
sortList.push_back(propID);
result = obj.GetClassObjectsByProperty(objectList, propFilter, sortList, gClassID, lClassID);
Example
Here is an example of using multiple open parentheses:
(y=45 or (x=8888 and (description LIKE ‘%n%’ or description LIKE ‘%city’)))
CLEARVECTOR(propFilter); filterInfo.Initialize();
filterInfo.value.SetPropertyID(10);
filterInfo.SetComparisonOperator(EQUAL);
filterInfo.value.SetShort(45);
filterInfo.SetOpenParenthesesCount(1); // Open count = 1
filterInfo.SetLogicalOperator(META_OR);
propFilter.push_back(filterInfo);
filterInfo.Initialize();
filterInfo.value.SetPropertyID(11);
filterInfo.SetComparisonOperator(EQUAL);
filterInfo.value.SetInt(8888);
filterInfo.SetOpenParenthesesCount(1); // Open count = 1
filterInfo.SetLogicalOperator(META_AND);
propFilter.push_back(filterInfo);
filterInfo.Initialize();
filterInfo.value.SetPropertyID(PID_CMN_DESCRIPTION);
filterInfo.SetComparisonOperator(REGEX);
filterInfo.value.SetString(_T("%in%"));
filterInfo.SetOpenParenthesesCount(1); // Open count = 1
filterInfo.SetLogicalOperator(META_OR);
propFilter.push_back(filterInfo);
filterInfo.Initialize();
filterInfo.value.SetPropertyID(PID_CMN_DESCRIPTION);
filterInfo.SetComparisonOperator(REGEX);
filterInfo.value.SetString(_T("%city"));
filterInfo.SetCloseParenthesesCount(3); // Close count = 3
propFilter.push_back(filterInfo);
result = obj.GetClassObjectsByProperty(objectList, propFilter, sortList, gClassID, lClassID);