helly Mon Feb 19 16:18:24 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/spl spl_iterators.c
Log:
- MFH CachingIterator implements Countable
http://cvs.php.net/viewvc.cgi/php-src/ext/spl/spl_iterators.c?r1=1.73.2.30.2.23&r2=1.73.2.30.2.24&diff_format=u
Index: php-src/ext/spl/spl_iterators.c
diff -u php-src/ext/spl/spl_iterators.c:1.73.2.30.2.23
php-src/ext/spl/spl_iterators.c:1.73.2.30.2.24
--- php-src/ext/spl/spl_iterators.c:1.73.2.30.2.23 Thu Feb 8 22:17:40 2007
+++ php-src/ext/spl/spl_iterators.c Mon Feb 19 16:18:24 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: spl_iterators.c,v 1.73.2.30.2.23 2007/02/08 22:17:40 helly Exp $ */
+/* $Id: spl_iterators.c,v 1.73.2.30.2.24 2007/02/19 16:18:24 helly Exp $ */
#ifdef HAVE_CONFIG_H
# include "config.h"
@@ -2232,6 +2232,23 @@
}
/* }}} */
+/* {{{ proto void CachingIterator::count()
+ Number of cached elements */
+SPL_METHOD(CachingIterator, count)
+{
+ spl_dual_it_object *intern;
+
+ intern = (spl_dual_it_object*)zend_object_store_get_object(getThis()
TSRMLS_CC);
+
+ if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0
TSRMLS_CC, "%v does not use a full cache (see CachingIterator::__construct)",
Z_OBJCE_P(getThis())->name);
+ return;
+ }
+
+ RETURN_LONG(zend_hash_num_elements(HASH_OF(intern->u.caching.zcache)));
+}
+/* }}} */
+
static
ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_it___construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
@@ -2271,6 +2288,7 @@
SPL_ME(CachingIterator, offsetUnset, arginfo_caching_it_offsetGet,
ZEND_ACC_PUBLIC)
SPL_ME(CachingIterator, offsetExists, arginfo_caching_it_offsetGet,
ZEND_ACC_PUBLIC)
SPL_ME(CachingIterator, getCache, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(CachingIterator, count, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
@@ -2900,6 +2918,7 @@
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);
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php