Back to index

php5  5.3.10
spl_iterators.h
Go to the documentation of this file.
00001 /*
00002    +----------------------------------------------------------------------+
00003    | PHP Version 5                                                        |
00004    +----------------------------------------------------------------------+
00005    | Copyright (c) 1997-2012 The PHP Group                                |
00006    +----------------------------------------------------------------------+
00007    | This source file is subject to version 3.01 of the PHP license,      |
00008    | that is bundled with this package in the file LICENSE, and is        |
00009    | available through the world-wide-web at the following url:           |
00010    | http://www.php.net/license/3_01.txt                                  |
00011    | If you did not receive a copy of the PHP license and are unable to   |
00012    | obtain it through the world-wide-web, please send a note to          |
00013    | license@php.net so we can mail you a copy immediately.               |
00014    +----------------------------------------------------------------------+
00015    | Authors: Marcus Boerger <helly@php.net>                              |
00016    +----------------------------------------------------------------------+
00017  */
00018 
00019 /* $Id: spl_iterators.h 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #ifndef SPL_ITERATORS_H
00022 #define SPL_ITERATORS_H
00023 
00024 #include "php.h"
00025 #include "php_spl.h"
00026 #if HAVE_PCRE || HAVE_BUNDLED_PCRE
00027 #include "ext/pcre/php_pcre.h"
00028 #endif
00029 
00030 #define spl_ce_Traversable   zend_ce_traversable
00031 #define spl_ce_Iterator      zend_ce_iterator
00032 #define spl_ce_Aggregate     zend_ce_aggregate
00033 #define spl_ce_ArrayAccess   zend_ce_arrayaccess
00034 #define spl_ce_Serializable  zend_ce_serializable
00035 
00036 extern PHPAPI zend_class_entry *spl_ce_RecursiveIterator;
00037 extern PHPAPI zend_class_entry *spl_ce_RecursiveIteratorIterator;
00038 extern PHPAPI zend_class_entry *spl_ce_RecursiveTreeIterator;
00039 extern PHPAPI zend_class_entry *spl_ce_FilterIterator;
00040 extern PHPAPI zend_class_entry *spl_ce_RecursiveFilterIterator;
00041 extern PHPAPI zend_class_entry *spl_ce_ParentIterator;
00042 extern PHPAPI zend_class_entry *spl_ce_SeekableIterator;
00043 extern PHPAPI zend_class_entry *spl_ce_LimitIterator;
00044 extern PHPAPI zend_class_entry *spl_ce_CachingIterator;
00045 extern PHPAPI zend_class_entry *spl_ce_RecursiveCachingIterator;
00046 extern PHPAPI zend_class_entry *spl_ce_OuterIterator;
00047 extern PHPAPI zend_class_entry *spl_ce_IteratorIterator;
00048 extern PHPAPI zend_class_entry *spl_ce_NoRewindIterator;
00049 extern PHPAPI zend_class_entry *spl_ce_InfiniteIterator;
00050 extern PHPAPI zend_class_entry *spl_ce_EmptyIterator;
00051 extern PHPAPI zend_class_entry *spl_ce_AppendIterator;
00052 extern PHPAPI zend_class_entry *spl_ce_RegexIterator;
00053 extern PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator;
00054 extern PHPAPI zend_class_entry *spl_ce_Countable;
00055 
00056 PHP_MINIT_FUNCTION(spl_iterators);
00057 
00058 PHP_FUNCTION(iterator_to_array);
00059 PHP_FUNCTION(iterator_count);
00060 PHP_FUNCTION(iterator_apply);
00061 
00062 typedef enum {
00063        DIT_Default = 0,
00064        DIT_FilterIterator = DIT_Default,
00065        DIT_RecursiveFilterIterator = DIT_Default,
00066        DIT_ParentIterator = DIT_Default,
00067        DIT_LimitIterator,
00068        DIT_CachingIterator,
00069        DIT_RecursiveCachingIterator,
00070        DIT_IteratorIterator,
00071        DIT_NoRewindIterator,
00072        DIT_InfiniteIterator,
00073        DIT_AppendIterator,
00074 #if HAVE_PCRE || HAVE_BUNDLED_PCRE
00075        DIT_RegexIterator,
00076        DIT_RecursiveRegexIterator,
00077 #endif
00078        DIT_Unknown = ~0
00079 } dual_it_type;
00080 
00081 typedef enum {
00082        RIT_Default = 0,
00083        RIT_RecursiveIteratorIterator = RIT_Default,
00084        RIT_RecursiveTreeIterator,
00085        RIT_Unknow = ~0
00086 } recursive_it_it_type;
00087 
00088 enum {
00089        /* public */
00090        CIT_CALL_TOSTRING        = 0x00000001,
00091        CIT_TOSTRING_USE_KEY     = 0x00000002,
00092        CIT_TOSTRING_USE_CURRENT = 0x00000004,
00093        CIT_TOSTRING_USE_INNER   = 0x00000008,
00094        CIT_CATCH_GET_CHILD      = 0x00000010,
00095        CIT_FULL_CACHE           = 0x00000100,
00096        CIT_PUBLIC               = 0x0000FFFF,
00097        /* private */
00098        CIT_VALID                = 0x00010000,
00099        CIT_HAS_CHILDREN         = 0x00020000
00100 };
00101 
00102 enum {
00103        /* public */
00104        REGIT_USE_KEY            = 0x00000001,
00105        REGIT_INVERTED           = 0x00000002
00106 };
00107 
00108 typedef enum {
00109        REGIT_MODE_MATCH,
00110        REGIT_MODE_GET_MATCH,
00111        REGIT_MODE_ALL_MATCHES,
00112        REGIT_MODE_SPLIT,
00113        REGIT_MODE_REPLACE,
00114        REGIT_MODE_MAX
00115 } regex_mode;
00116 
00117 typedef struct _spl_dual_it_object {
00118        zend_object              std;
00119        struct {
00120               zval                 *zobject;
00121               zend_class_entry     *ce;
00122               zend_object          *object;
00123               zend_object_iterator *iterator;
00124        } inner;
00125        struct {
00126               zval                 *data;
00127               char                 *str_key;
00128               uint                 str_key_len;
00129               ulong                int_key;
00130               int                  key_type; /* HASH_KEY_IS_STRING or HASH_KEY_IS_LONG */
00131               int                  pos;
00132        } current;
00133        dual_it_type             dit_type;
00134        union {
00135               struct {
00136                      long             offset;
00137                      long             count;
00138               } limit;
00139               struct {
00140                      long             flags; /* CIT_* */
00141                      zval             *zstr;
00142                      zval             *zchildren;
00143                      zval             *zcache;
00144               } caching;
00145               struct {
00146                      zval                 *zarrayit;
00147                      zend_object_iterator *iterator;
00148               } append;
00149 #if HAVE_PCRE || HAVE_BUNDLED_PCRE
00150               struct {
00151                      int              use_flags;
00152                      long             flags;
00153                      regex_mode       mode;
00154                      long             preg_flags;
00155                      pcre_cache_entry *pce;
00156                      char             *regex;
00157               } regex;
00158 #endif
00159        } u;
00160 } spl_dual_it_object;
00161 
00162 typedef int (*spl_iterator_apply_func_t)(zend_object_iterator *iter, void *puser TSRMLS_DC);
00163 
00164 PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser TSRMLS_DC);
00165 
00166 #endif /* SPL_ITERATORS_H */
00167 
00168 /*
00169  * Local Variables:
00170  * c-basic-offset: 4
00171  * tab-width: 4
00172  * End:
00173  * vim600: fdm=marker
00174  * vim: noet sw=4 ts=4
00175  */