add possibility to wrap valid function of an iterator (just for the sake of completeness)

Mon, 20 Oct 2025 19:44:18 +0200

author
Mike Becker <universe@uap-core.de>
date
Mon, 20 Oct 2025 19:44:18 +0200
changeset 1432
fb82e7a92258
parent 1431
1ec36e652e57
child 1433
81c301a59b7c

add possibility to wrap valid function of an iterator (just for the sake of completeness)

docs/Writerside/topics/iterator.h.md file | annotate | diff | comparison | revisions
src/cx/iterator.h file | annotate | diff | comparison | revisions
--- a/docs/Writerside/topics/iterator.h.md	Sun Oct 19 21:18:17 2025 +0200
+++ b/docs/Writerside/topics/iterator.h.md	Mon Oct 20 19:44:18 2025 +0200
@@ -119,6 +119,7 @@
 ```C
 struct cx_iterator_base_s {
     bool (*valid)(const void *);
+    bool (*valid_impl)(const void *);
     void *(*current)(const void *);
     void (*next)(void *);
     void *(*current_impl)(const void *);
@@ -138,7 +139,7 @@
 When an iterator is created, the `allow_remove` field is set to indicate if removal of elements is supported.
 The `remove` field is set to indicate if the current element should be removed on the next call to `next()` (see `cxIteratorFlagRemoval()`).
 
-Iterators may be wrapped in which case the original implementation can be stored in `current_impl` and `next_impl`.
+Iterators may be wrapped in which case the original implementation can be stored in the `*_impl` function pointers.
 They can then be called by a wrapper implementation pointed to by `current` and `next`, respectively.
 This can be useful when you want to support the `store_pointer` field of the [](collection.h.md) API.
 
--- a/src/cx/iterator.h	Sun Oct 19 21:18:17 2025 +0200
+++ b/src/cx/iterator.h	Mon Oct 20 19:44:18 2025 +0200
@@ -50,7 +50,10 @@
      * True if the iterator points to valid data.
      */
     bool (*valid)(const void *);
-
+    /**
+     * Original implementation in case the function needs to be wrapped.
+     */
+    bool (*valid_impl)(const void *);
     /**
      * Returns a pointer to the current element.
      *

mercurial