damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit b326f007f28b80cc1f29a95769b8b1bca2718d1d
parent a86d8416fc0fbdf186f90d1bc28a3cc4f6063af7
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 14 Aug 2024 11:21:31 -0700

nostrdb: expose filter introspection methods

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mnostrdb/src/nostrdb.c | 12++++++------
Mnostrdb/src/nostrdb.h | 5+++++
2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c @@ -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]; } diff --git a/nostrdb/src/nostrdb.h b/nostrdb/src/nostrdb.h @@ -491,6 +491,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);