IConditionGenerator::GenerateForLeaf Method
Generates a special query expression for what would otherwise become a leaf query expression.
Syntax
HRESULT GenerateForLeaf( IConditionFactory *pConditionFactory, LPCWSTR pszPropertyName, CONDITION_OPERATION op, LPCWSTR pszValueType, LPCWSTR pszValue, LPCWSTR pszValue2, IRichChunk *pPropertyNameTerm, IRichChunk *pOperationTerm, IRichChunk *pValueTerm, BOOL automaticWildcard, BOOL *pNoStringQuery, ICondition **ppQueryExpression );
Parameters
- pConditionFactory
[in] An IConditionFactory that can be used to create the necessary nodes.- pszPropertyName
[in, unique] Property name or NULL if there is not one.- op
[in] One of the values from CONDITION_OPERATION.- pszValueType
[in, unique] Semantic type describing the values in pszValue and pszValue2- pszValue
[in] Value string generated by IConditionGenerator::RecognizeNamedEntities. If pszValue2 is not NULL, then this represents the beginning of a range.- pszValue2
[in, unique] Value string generated by IConditionGenerator::RecognizeNamedEntities that represents the end of a range. May be NULL.- pPropertyNameTerm
[in] Pointer to an IRichChunk with information about what part of an input string produced the property name.- pOperationTerm
[in] Pointer to an IRichChunk with information about what part of an input string produced the operation.- pValueTerm
[in] Pointer to an IRichChunk with information about what part of an input string produced the value.- automaticWildcard
[in] Determines whether the generated condition should be one that returns results that begin with the given value, if meaningful, or one that returns results matching the given value exactly.- pNoStringQuery
[out] Returns TRUE if the condition tree in ppQueryExpression should be the complete result, or FALSE if the full query should be a disjunction of the condition tree in ppQueryExpression and the condition tree that would have been used if this method had returned S_FALSE.- ppQueryExpression
[out, retval] Returns a condition tree.
Return Value
Returns one of the following, or an error value otherwise.
S_OK Successfully generated a condition. S_FALSE A condition was not generated, and the query parser must produce one in some other way.
Remarks
If this method returns S_FALSE, the calling query parser will generate a leaf node N with this property name, operation, and value. If this method returns S_OK and pNoStringQuery contains VARIANT_TRUE, the condition tree in ppQueryExpression will be used instead. If this method returns S_FALSE and pNoStringQuery contains VARIANT_FALSE, the full generated query will be a disjunction ("OR") with the leaf node N and the condition tree in ppQueryExpression as sub-conditions.
The values of pszValue and (when not NULL) pszValue2 are strings that were produced by IConditionGenerator::RecognizeNamedEntities.
The value of pszValue2 is non-NULL only for a range query, such as
date:1/2/2003..1/30/2006, when pszValue contains the value for 1/2/2003 and pszValue2 contains the value for 1/30/2006. A condition generator can elect to refuse ranges by always returning S_OK when pszValue2 is not NULL.A condition generator can safely ignore the arguments pPropertyNameTerm, pOperationTerm and pValueTerm. However, it would use them to produce a leaf node that has correct information about the origins in the query string of the property name, the operator, and the value, by passing them on to IConditionFactory::MakeLeaf.
In many cases, a condition generator can ignore the argument automaticWildcard because it would not apply. However, if the generated condition tree does some form of string search, where both a prefix search (COP_VALUE_STARTSWITH from CONDITION_OPERATION) and a search for the exact string (COP_EQUAL from CONDITION_OPERATION) are meaningful, then the former should be generated when automaticWildcard is VARIANT_TRUE, and the latter when automaticWildcard is VARIANT_FALSE.