grn_expr is an grn_obj that represents an expression. Here is a list of what expression can do:
- Expression can apply some operations to a record by grn_expr_exec().
- Expression can represents search condition. grn_table_select() can select records that match against the search condition represented by expression.
There are two string representations of expression:
grn_expr_parse() parses string represented expression and appends the parsed expression to another expression.
TODO...
Extracts keywords from expr and stores to keywords. Keywords in keywords are owned by expr. Don't unlink them. Each keyword is GRN_BULK and its domain is GRN_DB_TEXT.
keywords must be GRN_PVECTOR.
Here is an example code:
grn_obj keywords;
GRN_PTR_INIT(&keywords, GRN_OBJ_VECTOR, GRN_ID_NIL);
grn_expr_get_keywords(ctx, expr, &keywords);
{
int i, n_keywords;
n_keywords = GRN_BULK_VSIZE(&keywords) / sizeof(grn_obj *);
for (i = 0; i < n_keywords; i++) {
grn_obj *keyword = GRN_PTR_VALUE_AT(&keywords, i);
const char *keyword_content;
int keyword_size;
keyword_content = GRN_TEXT_VALUE(keyword);
keyword_size = GRN_TEXT_LEN(keyword);
/*
Use keyword_content and keyword_size.
You don't need to unlink keyword.
keyword is owned by expr.
*/
}
}
GRN_OBJ_FIN(ctx, &keywords);
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |
Escapes target_characters in string by escape_character.
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |
Escapes special characters in Query syntax.
Parameters: |
|
---|---|
Returns: | GRN_SUCCESS on success, not GRN_SUCCESS on error. |