Skip to content

Commit

Permalink
hash: add new EACH macros
Browse files Browse the repository at this point in the history
Usage:

    GRN_HASH_EACH_BEGIN(ctx, hash, cursor, id) {
      /* ... */
    } GRN_HASH_EACH_END(ctx, cursor);

It's useful rather than existing EACH macro when you run Groonga on
debugger. You can't step execution with existing EACH macro but you can
do it with this macro.
  • Loading branch information
kou committed May 12, 2016
1 parent ac0555a commit c99c0c0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/groonga/hash.h
Expand Up @@ -84,6 +84,20 @@ GRN_API grn_rc grn_hash_cursor_delete(grn_ctx *ctx, grn_hash_cursor *c,
}\
} while (0)

#define GRN_HASH_EACH_BEGIN(ctx, hash, cursor, id) do {\
grn_hash_cursor *cursor;\
cursor = grn_hash_cursor_open((ctx), (hash),\
NULL, 0, NULL, 0,\
0, -1, GRN_CURSOR_BY_ID);\
if (cursor) {\
grn_id id;\
while ((id = grn_hash_cursor_next((ctx), cursor)) != GRN_ID_NIL)\

#define GRN_HASH_EACH_END(ctx, cursor)\
grn_hash_cursor_close((ctx), cursor);\
}\
} while(0)

#ifdef __cplusplus
}
#endif

0 comments on commit c99c0c0

Please sign in to comment.