Back to index

php5  5.3.10
Classes | Defines | Typedefs | Enumerations | Functions | Variables
spl_iterators.h File Reference
#include "php.h"
#include "php_spl.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _spl_dual_it_object
struct  _spl_dual_it_object.inner
struct  _spl_dual_it_object.current
union  _spl_dual_it_object.u
struct  _spl_dual_it_object.u.limit
struct  _spl_dual_it_object.u.caching
struct  _spl_dual_it_object.u.append

Defines

#define spl_ce_Traversable   zend_ce_traversable
#define spl_ce_Iterator   zend_ce_iterator
#define spl_ce_Aggregate   zend_ce_aggregate
#define spl_ce_ArrayAccess   zend_ce_arrayaccess
#define spl_ce_Serializable   zend_ce_serializable

Typedefs

typedef struct _spl_dual_it_object spl_dual_it_object
typedef int(* spl_iterator_apply_func_t )(zend_object_iterator *iter, void *puser TSRMLS_DC)

Enumerations

enum  dual_it_type {
  DIT_Default = 0, DIT_FilterIterator = DIT_Default, DIT_RecursiveFilterIterator = DIT_Default, DIT_ParentIterator = DIT_Default,
  DIT_LimitIterator, DIT_CachingIterator, DIT_RecursiveCachingIterator, DIT_IteratorIterator,
  DIT_NoRewindIterator, DIT_InfiniteIterator, DIT_AppendIterator, DIT_Unknown = ~0
}
enum  recursive_it_it_type { RIT_Default = 0, RIT_RecursiveIteratorIterator = RIT_Default, RIT_RecursiveTreeIterator, RIT_Unknow = ~0 }
enum  {
  CIT_CALL_TOSTRING = 0x00000001, CIT_TOSTRING_USE_KEY = 0x00000002, CIT_TOSTRING_USE_CURRENT = 0x00000004, CIT_TOSTRING_USE_INNER = 0x00000008,
  CIT_CATCH_GET_CHILD = 0x00000010, CIT_FULL_CACHE = 0x00000100, CIT_PUBLIC = 0x0000FFFF, CIT_VALID = 0x00010000,
  CIT_HAS_CHILDREN = 0x00020000
}
enum  { REGIT_USE_KEY = 0x00000001, REGIT_INVERTED = 0x00000002 }
enum  regex_mode {
  REGIT_MODE_MATCH, REGIT_MODE_GET_MATCH, REGIT_MODE_ALL_MATCHES, REGIT_MODE_SPLIT,
  REGIT_MODE_REPLACE, REGIT_MODE_MAX
}

Functions

 PHP_MINIT_FUNCTION (spl_iterators)
 PHP_FUNCTION (iterator_to_array)
 PHP_FUNCTION (iterator_count)
 PHP_FUNCTION (iterator_apply)
PHPAPI int spl_iterator_apply (zval *obj, spl_iterator_apply_func_t apply_func, void *puser TSRMLS_DC)

Variables

PHPAPI zend_class_entry * spl_ce_RecursiveIterator
PHPAPI zend_class_entry * spl_ce_RecursiveIteratorIterator
PHPAPI zend_class_entry * spl_ce_RecursiveTreeIterator
PHPAPI zend_class_entry * spl_ce_FilterIterator
PHPAPI zend_class_entry * spl_ce_RecursiveFilterIterator
PHPAPI zend_class_entry * spl_ce_ParentIterator
PHPAPI zend_class_entry * spl_ce_SeekableIterator
PHPAPI zend_class_entry * spl_ce_LimitIterator
PHPAPI zend_class_entry * spl_ce_CachingIterator
PHPAPI zend_class_entry * spl_ce_RecursiveCachingIterator
PHPAPI zend_class_entry * spl_ce_OuterIterator
PHPAPI zend_class_entry * spl_ce_IteratorIterator
PHPAPI zend_class_entry * spl_ce_NoRewindIterator
PHPAPI zend_class_entry * spl_ce_InfiniteIterator
PHPAPI zend_class_entry * spl_ce_EmptyIterator
PHPAPI zend_class_entry * spl_ce_AppendIterator
PHPAPI zend_class_entry * spl_ce_RegexIterator
PHPAPI zend_class_entry * spl_ce_RecursiveRegexIterator
PHPAPI zend_class_entry * spl_ce_Countable

Class Documentation

struct _spl_dual_it_object

Definition at line 117 of file spl_iterators.h.

Collaboration diagram for _spl_dual_it_object:
Class Members
struct _spl_dual_it_object current
dual_it_type dit_type
struct _spl_dual_it_object inner
zend_object std
union _spl_dual_it_object u
struct _spl_dual_it_object.inner

Definition at line 119 of file spl_iterators.h.

Class Members
zend_class_entry * ce
zend_object_iterator * iterator
zend_object * object
zval * zobject
struct _spl_dual_it_object.current

Definition at line 125 of file spl_iterators.h.

Class Members
zval * data
ulong int_key
int key_type
int pos
char * str_key
uint str_key_len
union _spl_dual_it_object.u

Definition at line 134 of file spl_iterators.h.

Class Members
u append
u caching
u limit
struct _spl_dual_it_object.u.limit

Definition at line 135 of file spl_iterators.h.

Class Members
long count
long offset
struct _spl_dual_it_object.u.caching

Definition at line 139 of file spl_iterators.h.

Class Members
long flags
zval * zcache
zval * zchildren
zval * zstr
struct _spl_dual_it_object.u.append

Definition at line 145 of file spl_iterators.h.

Class Members
zend_object_iterator * iterator
zval * zarrayit

Define Documentation

Definition at line 32 of file spl_iterators.h.

Definition at line 33 of file spl_iterators.h.

Definition at line 31 of file spl_iterators.h.

Definition at line 34 of file spl_iterators.h.

Definition at line 30 of file spl_iterators.h.


Typedef Documentation

typedef int(* spl_iterator_apply_func_t)(zend_object_iterator *iter, void *puser TSRMLS_DC)

Definition at line 162 of file spl_iterators.h.


Enumeration Type Documentation

anonymous enum
Enumerator:
CIT_CALL_TOSTRING 
CIT_TOSTRING_USE_KEY 
CIT_TOSTRING_USE_CURRENT 
CIT_TOSTRING_USE_INNER 
CIT_CATCH_GET_CHILD 
CIT_FULL_CACHE 
CIT_PUBLIC 
CIT_VALID 
CIT_HAS_CHILDREN 

Definition at line 88 of file spl_iterators.h.

     {
       /* public */
       CIT_CALL_TOSTRING        = 0x00000001,
       CIT_TOSTRING_USE_KEY     = 0x00000002,
       CIT_TOSTRING_USE_CURRENT = 0x00000004,
       CIT_TOSTRING_USE_INNER   = 0x00000008,
       CIT_CATCH_GET_CHILD      = 0x00000010,
       CIT_FULL_CACHE           = 0x00000100,
       CIT_PUBLIC               = 0x0000FFFF,
       /* private */
       CIT_VALID                = 0x00010000,
       CIT_HAS_CHILDREN         = 0x00020000
};
anonymous enum
Enumerator:
REGIT_USE_KEY 
REGIT_INVERTED 

Definition at line 102 of file spl_iterators.h.

     {
       /* public */
       REGIT_USE_KEY            = 0x00000001,
       REGIT_INVERTED           = 0x00000002
};
Enumerator:
DIT_Default 
DIT_FilterIterator 
DIT_RecursiveFilterIterator 
DIT_ParentIterator 
DIT_LimitIterator 
DIT_CachingIterator 
DIT_RecursiveCachingIterator 
DIT_IteratorIterator 
DIT_NoRewindIterator 
DIT_InfiniteIterator 
DIT_AppendIterator 
DIT_Unknown 

Definition at line 62 of file spl_iterators.h.

Enumerator:
RIT_Default 
RIT_RecursiveIteratorIterator 
RIT_RecursiveTreeIterator 
RIT_Unknow 

Definition at line 81 of file spl_iterators.h.

enum regex_mode
Enumerator:
REGIT_MODE_MATCH 
REGIT_MODE_GET_MATCH 
REGIT_MODE_ALL_MATCHES 
REGIT_MODE_SPLIT 
REGIT_MODE_REPLACE 
REGIT_MODE_MAX 

Definition at line 108 of file spl_iterators.h.


Function Documentation

Definition at line 3406 of file spl_iterators.c.

{
       zval  *obj;
       zend_bool use_keys = 1;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|b", &obj, zend_ce_traversable, &use_keys) == FAILURE) {
              RETURN_FALSE;
       }

       array_init(return_value);

       if (spl_iterator_apply(obj, use_keys ? spl_iterator_to_array_apply : spl_iterator_to_values_apply, (void*)return_value TSRMLS_CC) != SUCCESS) {
              zval_dtor(return_value);
              RETURN_NULL();
       }
} /* }}} */

Here is the call graph for this function:

Definition at line 3432 of file spl_iterators.c.

{
       zval  *obj;
       long  count = 0;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &obj, zend_ce_traversable) == FAILURE) {
              RETURN_FALSE;
       }
       
       if (spl_iterator_apply(obj, spl_iterator_count_apply, (void*)&count TSRMLS_CC) == SUCCESS) {
              RETURN_LONG(count);
       }
}

Here is the call graph for this function:

PHP_FUNCTION ( iterator_apply  )

Definition at line 3475 of file spl_iterators.c.

{
       spl_iterator_apply_info  apply_info;

       apply_info.args = NULL;
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Of|a!", &apply_info.obj, zend_ce_traversable, &apply_info.fci, &apply_info.fcc, &apply_info.args) == FAILURE) {
              return;
       }

       apply_info.count = 0;
       zend_fcall_info_args(&apply_info.fci, apply_info.args TSRMLS_CC);
       if (spl_iterator_apply(apply_info.obj, spl_iterator_func_apply, (void*)&apply_info TSRMLS_CC) == SUCCESS) {
              RETVAL_LONG(apply_info.count);
       } else {
              RETVAL_FALSE;
       }
       zend_fcall_info_args(&apply_info.fci, NULL TSRMLS_CC);
}

Here is the call graph for this function:

PHP_MINIT_FUNCTION ( spl_iterators  )

Definition at line 3507 of file spl_iterators.c.

{
       REGISTER_SPL_INTERFACE(RecursiveIterator);
       REGISTER_SPL_ITERATOR(RecursiveIterator);

       REGISTER_SPL_STD_CLASS_EX(RecursiveIteratorIterator, spl_RecursiveIteratorIterator_new, spl_funcs_RecursiveIteratorIterator);
       REGISTER_SPL_ITERATOR(RecursiveIteratorIterator);

       memcpy(&spl_handlers_rec_it_it, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
       spl_handlers_rec_it_it.get_method = spl_recursive_it_get_method;
       spl_handlers_rec_it_it.clone_obj = NULL;

       memcpy(&spl_handlers_dual_it, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
       spl_handlers_dual_it.get_method = spl_dual_it_get_method;
       /*spl_handlers_dual_it.call_method = spl_dual_it_call_method;*/
       spl_handlers_dual_it.clone_obj = NULL;
       
       spl_ce_RecursiveIteratorIterator->get_iterator = spl_recursive_it_get_iterator;
       spl_ce_RecursiveIteratorIterator->iterator_funcs.funcs = &spl_recursive_it_iterator_funcs;

       REGISTER_SPL_CLASS_CONST_LONG(RecursiveIteratorIterator, "LEAVES_ONLY",     RIT_LEAVES_ONLY);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveIteratorIterator, "SELF_FIRST",      RIT_SELF_FIRST);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveIteratorIterator, "CHILD_FIRST",     RIT_CHILD_FIRST);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveIteratorIterator, "CATCH_GET_CHILD", RIT_CATCH_GET_CHILD);

       REGISTER_SPL_INTERFACE(OuterIterator);
       REGISTER_SPL_ITERATOR(OuterIterator);

       REGISTER_SPL_STD_CLASS_EX(IteratorIterator, spl_dual_it_new, spl_funcs_IteratorIterator);
       REGISTER_SPL_ITERATOR(IteratorIterator);
       REGISTER_SPL_IMPLEMENTS(IteratorIterator, OuterIterator);

       REGISTER_SPL_SUB_CLASS_EX(FilterIterator, IteratorIterator, spl_dual_it_new, spl_funcs_FilterIterator);
       spl_ce_FilterIterator->ce_flags |= ZEND_ACC_EXPLICIT_ABSTRACT_CLASS;

       REGISTER_SPL_SUB_CLASS_EX(RecursiveFilterIterator, FilterIterator, spl_dual_it_new, spl_funcs_RecursiveFilterIterator);
       REGISTER_SPL_IMPLEMENTS(RecursiveFilterIterator, RecursiveIterator);

       REGISTER_SPL_SUB_CLASS_EX(ParentIterator, RecursiveFilterIterator, spl_dual_it_new, spl_funcs_ParentIterator);

       REGISTER_SPL_INTERFACE(Countable);
       REGISTER_SPL_INTERFACE(SeekableIterator);
       REGISTER_SPL_ITERATOR(SeekableIterator);

       REGISTER_SPL_SUB_CLASS_EX(LimitIterator, IteratorIterator, spl_dual_it_new, spl_funcs_LimitIterator);

       REGISTER_SPL_SUB_CLASS_EX(CachingIterator, IteratorIterator, spl_dual_it_new, spl_funcs_CachingIterator);
       REGISTER_SPL_IMPLEMENTS(CachingIterator, ArrayAccess);
       REGISTER_SPL_IMPLEMENTS(CachingIterator, Countable);

       REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CALL_TOSTRING",        CIT_CALL_TOSTRING); 
       REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "CATCH_GET_CHILD",      CIT_CATCH_GET_CHILD); 
       REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "TOSTRING_USE_KEY",     CIT_TOSTRING_USE_KEY);
       REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "TOSTRING_USE_CURRENT", CIT_TOSTRING_USE_CURRENT);
       REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "TOSTRING_USE_INNER",   CIT_TOSTRING_USE_INNER);
       REGISTER_SPL_CLASS_CONST_LONG(CachingIterator, "FULL_CACHE",           CIT_FULL_CACHE); 

       REGISTER_SPL_SUB_CLASS_EX(RecursiveCachingIterator, CachingIterator, spl_dual_it_new, spl_funcs_RecursiveCachingIterator);
       REGISTER_SPL_IMPLEMENTS(RecursiveCachingIterator, RecursiveIterator);
       
       REGISTER_SPL_SUB_CLASS_EX(NoRewindIterator, IteratorIterator, spl_dual_it_new, spl_funcs_NoRewindIterator);

       REGISTER_SPL_SUB_CLASS_EX(AppendIterator, IteratorIterator, spl_dual_it_new, spl_funcs_AppendIterator);

       REGISTER_SPL_IMPLEMENTS(RecursiveIteratorIterator, OuterIterator);

       REGISTER_SPL_SUB_CLASS_EX(InfiniteIterator, IteratorIterator, spl_dual_it_new, spl_funcs_InfiniteIterator);
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
       REGISTER_SPL_SUB_CLASS_EX(RegexIterator, FilterIterator, spl_dual_it_new, spl_funcs_RegexIterator);
       REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "USE_KEY",     REGIT_USE_KEY);
       REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "MATCH",       REGIT_MODE_MATCH);
       REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "GET_MATCH",   REGIT_MODE_GET_MATCH);
       REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "ALL_MATCHES", REGIT_MODE_ALL_MATCHES);
       REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "SPLIT",       REGIT_MODE_SPLIT);
       REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "REPLACE",     REGIT_MODE_REPLACE);
       REGISTER_SPL_PROPERTY(RegexIterator, "replacement", 0);
       REGISTER_SPL_SUB_CLASS_EX(RecursiveRegexIterator, RegexIterator, spl_dual_it_new, spl_funcs_RecursiveRegexIterator);
       REGISTER_SPL_IMPLEMENTS(RecursiveRegexIterator, RecursiveIterator);
#else
       spl_ce_RegexIterator = NULL;
       spl_ce_RecursiveRegexIterator = NULL;
#endif

       REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator);
       REGISTER_SPL_ITERATOR(EmptyIterator);

       REGISTER_SPL_SUB_CLASS_EX(RecursiveTreeIterator, RecursiveIteratorIterator, spl_RecursiveTreeIterator_new, spl_funcs_RecursiveTreeIterator);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_CURRENT",      RTIT_BYPASS_CURRENT);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "BYPASS_KEY",          RTIT_BYPASS_KEY);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "PREFIX_LEFT",         0);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "PREFIX_MID_HAS_NEXT", 1);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "PREFIX_MID_LAST",     2);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "PREFIX_END_HAS_NEXT", 3);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "PREFIX_END_LAST",     4);
       REGISTER_SPL_CLASS_CONST_LONG(RecursiveTreeIterator, "PREFIX_RIGHT",        5);

       return SUCCESS;
}

Here is the call graph for this function:

PHPAPI int spl_iterator_apply ( zval *  obj,
spl_iterator_apply_func_t  apply_func,
void *puser  TSRMLS_DC 
)

Definition at line 3308 of file spl_iterators.c.

{
       zend_object_iterator   *iter;
       zend_class_entry       *ce = Z_OBJCE_P(obj);

       iter = ce->get_iterator(ce, obj, 0 TSRMLS_CC);

       if (EG(exception)) {
              goto done;
       }

       iter->index = 0;
       if (iter->funcs->rewind) {
              iter->funcs->rewind(iter TSRMLS_CC);
              if (EG(exception)) {
                     goto done;
              }
       }

       while (iter->funcs->valid(iter TSRMLS_CC) == SUCCESS) {
              if (EG(exception)) {
                     goto done;
              }
              if (apply_func(iter, puser TSRMLS_CC) == ZEND_HASH_APPLY_STOP || EG(exception)) {
                     goto done;
              }
              iter->index++;
              iter->funcs->move_forward(iter TSRMLS_CC);
              if (EG(exception)) {
                     goto done;
              }
       }

done:
       if (iter) {
              iter->funcs->dtor(iter TSRMLS_CC);
       }
       return EG(exception) ? FAILURE : SUCCESS;
}

Here is the caller graph for this function:


Variable Documentation

PHPAPI zend_class_entry* spl_ce_AppendIterator

Definition at line 58 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_CachingIterator

Definition at line 51 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_Countable

Definition at line 61 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_EmptyIterator

Definition at line 57 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_FilterIterator

Definition at line 46 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_InfiniteIterator

Definition at line 56 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_IteratorIterator

Definition at line 54 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_LimitIterator

Definition at line 50 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_NoRewindIterator

Definition at line 55 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_OuterIterator

Definition at line 53 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_ParentIterator

Definition at line 48 of file spl_iterators.c.

Definition at line 52 of file spl_iterators.c.

Definition at line 47 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_RecursiveIterator

Definition at line 44 of file spl_iterators.c.

Definition at line 45 of file spl_iterators.c.

Definition at line 60 of file spl_iterators.c.

Definition at line 62 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_RegexIterator

Definition at line 59 of file spl_iterators.c.

PHPAPI zend_class_entry* spl_ce_SeekableIterator

Definition at line 49 of file spl_iterators.c.