nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

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

expose filter introspection methods

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

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

diff --git a/src/nostrdb.c b/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/src/nostrdb.h b/src/nostrdb.h @@ -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);