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 object that can be used to create the necessary nodes.
  • pszPropertyName
    [in, unique]  Property name, or NULL if there is no property name.
  • op
    [in]  A CONDITION_OPERATION enumerated type identifying the operation.
  • pszValueType
    [in, unique]  Semantic type describing the values in pszValue and pszValue2.
  • pszValue
    [in]  A string generated by IConditionGenerator::RecognizeNamedEntities that represents the value. If pszValue2 is not NULL, then this represents the beginning of the value's range.
  • pszValue2
    [in, unique]  If not NULL, a string generated by IConditionGenerator::RecognizeNamedEntities that represents the end of the value's range. If NULL, then pszValue represents a discrete value.
  • pPropertyNameTerm
    [in]  Pointer to an IRichChunk object containing information about what part of an input string produced the property name.
  • pOperationTerm
    [in]  Pointer to an IRichChunk object containing information about what part of an input string produced the operation.
  • pValueTerm
    [in]  Pointer to an IRichChunk object containing information about what part of an input string produced the value.
  • automaticWildcard
    [in] TRUE if the generated condition should return results that begin with the specified value, if meaningful. FALSE if the generated condition should return results matching the specified value exactly.
  • pNoStringQuery
    [out] VARIANT_TRUE if the condition tree in ppQueryExpression should be the full query, or VARIANT_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]  Receives a pointer to an ICondition 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 should generate a leaf node N with this property name, operation, and value. If this method returns S_FALSE and pNoStringQuery contains VARIANT_FALSE, the full generated query is a disjunction (OR) with the leaf node N and the condition tree in ppQueryExpression as subconditions.

If this method returns S_OK and pNoStringQuery contains VARIANT_TRUE, the condition tree in ppQueryExpression is the full query.

The value of pszValue2 is non-NULL only for a range query, such as date:1/2/2003..1/30/2006, where 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.

See Also

IConditionGenerator, IConditionFactory, CONDITION_TYPE, CONDITION_OPERATION, CONDITION_CREATION_OPTIONS, ICondition, ICondition2