Skip to content

Commit

Permalink
expose filter introspection methods
Browse files Browse the repository at this point in the history
Signed-off-by: William Casarin <[email protected]>
  • Loading branch information
jb55 committed Aug 14, 2024
1 parent b121017 commit b60018f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/nostrdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,20 +637,20 @@ ndb_filter_elements_data(const struct ndb_filter *filter, int offset)
return data;
}

static inline unsigned char *
ndb_filter_get_id_element(const struct ndb_filter *filter, struct ndb_filter_elements *els, int index)
unsigned char *
ndb_filter_get_id_element(const struct ndb_filter *filter, const struct ndb_filter_elements *els, int index)
{
return ndb_filter_elements_data(filter, els->elements[index]);
}

static inline const char *
ndb_filter_get_string_element(const struct ndb_filter *filter, struct ndb_filter_elements *els, int index)
const char *
ndb_filter_get_string_element(const struct ndb_filter *filter, const struct ndb_filter_elements *els, int index)
{
return (const char *)ndb_filter_elements_data(filter, els->elements[index]);
}

static inline uint64_t
ndb_filter_get_int_element(struct ndb_filter_elements *els, int index)
uint64_t
ndb_filter_get_int_element(const struct ndb_filter_elements *els, int index)
{
return els->elements[index];
}
Expand Down
5 changes: 5 additions & 0 deletions src/nostrdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,11 @@ int ndb_filter_add_id_element(struct ndb_filter *, const unsigned char *id);
int ndb_filter_add_int_element(struct ndb_filter *, uint64_t integer);
int ndb_filter_add_str_element(struct ndb_filter *, const char *str);

// getting field elements
unsigned char *ndb_filter_get_id_element(const struct ndb_filter *, const struct ndb_filter_elements *, int index);
const char *ndb_filter_get_string_element(const struct ndb_filter *, const struct ndb_filter_elements *, int index);
uint64_t ndb_filter_get_int_element(const struct ndb_filter_elements *, int index);

struct ndb_filter_elements *ndb_filter_current_element(const struct ndb_filter *);
struct ndb_filter_elements *ndb_filter_get_elements(const struct ndb_filter *, int);
int ndb_filter_start_field(struct ndb_filter *, enum ndb_filter_fieldtype);
Expand Down

0 comments on commit b60018f

Please sign in to comment.