summaryrefslogtreecommitdiff
path: root/ext/spl/spl_iterators.h
diff options
context:
space:
mode:
authorArnaud Le Blanc <lbarnaud@php.net>2011-03-27 20:13:27 +0000
committerArnaud Le Blanc <lbarnaud@php.net>2011-03-27 20:13:27 +0000
commitb83e243c23daafdecaec75461b5ff4705733608d (patch)
tree5b47dc4a3e42eafa3dcf833266928a549c375e1b /ext/spl/spl_iterators.h
parent2191af9546632c2eca7084e7e66745ff6ad7dd1a (diff)
downloadphp-git-b83e243c23daafdecaec75461b5ff4705733608d.tar.gz
Added CallbackFilterIterator and RecursiveCallbackFilterIterator classes
[DOC] This is a concrete FilterIterator which takes a callback as constructor parameter, and uses this callback for filtering. This allows to use FilterIterator without extending it. CallbackFilterIterator Example: $it = new ArrayIterator(range(1,100)); $it = new CallbackFilterIterator($it, function($value) { return $value % 2; }); foreach($it as $value) // ... RecursiveCallbackFilterIterator Example: $it = new RecursiveDirectoryIterator("/"); $it = new RecursiveCallbackFilterIterator($it, function($file, $k, $it) { return $it->hasChildren() || $file->getSize() > 1024; }); foreach(new RecursiveIteratorIterator($it) as $file) // ... The callback takes the current value, the current key and the inner iterator as parameters.
Diffstat (limited to 'ext/spl/spl_iterators.h')
-rwxr-xr-xext/spl/spl_iterators.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h
index ef59fcc6ea..9bbdd68751 100755
--- a/ext/spl/spl_iterators.h
+++ b/ext/spl/spl_iterators.h
@@ -75,6 +75,8 @@ typedef enum {
DIT_RegexIterator,
DIT_RecursiveRegexIterator,
#endif
+ DIT_CallbackFilterIterator,
+ DIT_RecursiveCallbackFilterIterator,
DIT_Unknown = ~0
} dual_it_type;
@@ -114,6 +116,11 @@ typedef enum {
REGIT_MODE_MAX
} regex_mode;
+typedef struct _spl_cbfilter_it_intern {
+ zend_fcall_info fci;
+ zend_fcall_info_cache fcc;
+} _spl_cbfilter_it_intern;
+
typedef struct _spl_dual_it_object {
zend_object std;
struct {
@@ -157,6 +164,7 @@ typedef struct _spl_dual_it_object {
uint regex_len;
} regex;
#endif
+ _spl_cbfilter_it_intern *cbfilter;
} u;
} spl_dual_it_object;