diff options
author | SVN Migration <svn@php.net> | 2005-06-10 18:06:44 +0000 |
---|---|---|
committer | SVN Migration <svn@php.net> | 2005-06-10 18:06:44 +0000 |
commit | 02889a1980340caaa4f2450c834da87fb675f848 (patch) | |
tree | 2e0b0f07f6810a635d5ecba89f63b6bfb63126f8 /ext/spl/internal/cachingiterator.inc | |
parent | 3b1f8e9ad74ad07580e4248b39fd0db261c31aa0 (diff) | |
download | php-git-php-5.0.1b1.tar.gz |
This commit was manufactured by cvs2svn to create tag 'php_5_0_1b1'.php-5.0.1b1
Diffstat (limited to 'ext/spl/internal/cachingiterator.inc')
-rwxr-xr-x | ext/spl/internal/cachingiterator.inc | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/ext/spl/internal/cachingiterator.inc b/ext/spl/internal/cachingiterator.inc deleted file mode 100755 index dfefd9987f..0000000000 --- a/ext/spl/internal/cachingiterator.inc +++ /dev/null @@ -1,141 +0,0 @@ -<?php - -/** @file cachingiterator.inc - * @ingroup SPL - * @brief class CachingIterator - * @author Marcus Boerger - * @date 2003 - 2005 - * - * SPL - Standard PHP Library - */ - -define('CIT_CALL_TOSTRING', 1); -define('CIT_CATCH_GET_CHILD', 2); - -/** - * @brief Cached iteration over another Iterator - * @author Marcus Boerger - * @version 1.1 - * @since PHP 5.0 - * - * This iterator wrapper does a one ahead iteration. This way it knows whether - * the inner iterator has one more element. - * - * @note If you want to convert the elements into strings and the inner - * Iterator is an internal Iterator then you need to provide the - * flag CIT_CALL_TOSTRING to do the conversion when the actual element - * is being fetched. Otherwise the conversion would happen with the - * already changed iterator. If you do not need this then it you should - * omit this flag because it costs unneccessary work and time. - */ -class CachingIterator implements OuterIterator -{ - private $it; - private $current; - private $key; - private $valid; - private $strValue; - - /** Construct from another iterator - * - * @param it Iterator to cache - * @param flags Bitmask: - * - CIT_CALL_TOSTRING (whether to call __toString() for every element) - */ - function __construct(Iterator $it, $flags = CIT_CALL_TOSTRING) - { - $this->it = $it; - $this->flags = $flags & (CIT_CALL_TOSTRING|CIT_CATCH_GET_CHILD); - $this->next(); - } - - /** Rewind the Iterator - */ - function rewind() - { - $this->it->rewind(); - $this->next(); - } - - /** Forward to the next element - */ - function next() - { - if ($this->valid = $this->it->valid()) { - $this->current = $this->it->current(); - $this->key = $this->it->key(); - if ($this->flags & CIT_CALL_TOSTRING) { - if (is_object($this->current)) { - $this->strValue = $this->current->__toString(); - } else { - $this->strValue = (string)$this->current; - } - } - } else { - $this->current = NULL; - $this->key = NULL; - $this->strValue = NULL; - } - $this->it->next(); - } - - /** @return whether teh iterator is valid - */ - function valid() - { - return $this->valid; - } - - /** @return whether there is one more element - */ - function hasNext() - { - return $this->it->valid(); - } - - /** @return the current element - */ - function current() - { - return $this->current; - } - - /** @return the current key - */ - function key() - { - return $this->key; - } - - /** Aggregate the inner iterator - * - * @param func Name of method to invoke - * @param params Array of parameters to pass to method - */ - function __call($func, $params) - { - return call_user_func_array(array($this->it, $func), $params); - } - - /** @return the string represenatation that was generated for the current - * element - * @throw exception when CIT_CALL_TOSTRING was not specified in constructor - */ - function __toString() - { - if (!$this->flags & CIT_CALL_TOSTRING) { - throw new exception('CachingIterator does not fetch string value (see CachingIterator::__construct)'); - } - return $this->strValue; - } - - /** - * @return The inner iterator - */ - function getInnerIterator() - { - return $this->it; - } -} - -?>
\ No newline at end of file |