Browse Source

- Update docu

- Synch class consts with HEAD
- Synch example RecursiveTreeIterator (as far as possible)
PHP-5.1
Marcus Boerger 21 years ago
parent
commit
11f0ff9c1a
  1. 1
      ext/spl/examples/class_tree.php
  2. 25
      ext/spl/examples/recursivetreeiterator.inc
  3. 8
      ext/spl/internal/cachingiterator.inc
  4. 2
      ext/spl/internal/recursiveiteratoriterator.inc
  5. 4
      ext/spl/spl_iterators.h

1
ext/spl/examples/class_tree.php

@ -5,6 +5,7 @@
* @ingroup Examples
* @author Marcus Boerger
* @date 2003 - 2005
* @version 1.0
*
* Usage: php class_tree.php \<class\>
*

25
ext/spl/examples/recursivetreeiterator.inc

@ -18,16 +18,21 @@
*/
class RecursiveTreeIterator extends RecursiveIteratorIterator
{
const BYPASS_CURRENT = 0x00000004;
private $callToString;
private $rit_flags;
/**
* @param it iterator to use as inner iterator
* @param flags flags passed to RecursiveIteratoIterator (parent)
* @param rit_flags flags passed to RecursiveIteratoIterator (parent)
* @param cit_flags flags passed to RecursiveCachingIterator (for hasNext)
* @param mode mode passed to RecursiveIteratoIterator (parent)
*/
function __construct(RecursiveIterator $it, $flags = self::SELF_FIRST, $cit_flags = CachingIterator::CATCH_GET_CHILD)
function __construct(RecursiveIterator $it, $rit_flags = 0, $cit_flags = CachingIterator::CATCH_GET_CHILD, $mode = self::SELF_FIRST)
{
parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $flags);
parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $mode, $rit_flags);
$this->rit_flags = $rit_flags;
$this->callToString = (bool)($cit_flags & CachingIterator::CALL_TOSTRING);
}
@ -74,7 +79,21 @@ class RecursiveTreeIterator extends RecursiveIteratorIterator
*/
function current()
{
if ($this->rit_flags & self::BYPASS_CURRENT)
{
return parent::current();
}
else
{
return $this->getPrefix() . $this->getEntry() . $this->getPostfix();
}
}
/** @return the current key prefixed and postfixed
*/
function key()
{
return $this->getPrefix() . parent::key() . $this->getPostfix();
}
/** Aggregates the inner iterator

8
ext/spl/internal/cachingiterator.inc

@ -27,10 +27,10 @@
*/
class CachingIterator implements OuterIterator
{
const CALL_TOSTRING = 1;
const CATCH_GET_CHILD = 2;
const TOSTRING_USE_KEY = 4;
const TOSTRING_USE_CURRENT = 8;
const CALL_TOSTRING = 0x00000001;
const CATCH_GET_CHILD = 0x00000002;
const TOSTRING_USE_KEY = 0x00000010;
const TOSTRING_USE_CURRENT = 0x00000020;
private $it;
private $current;

2
ext/spl/internal/recursiveiteratoriterator.inc

@ -30,7 +30,7 @@ class RecursiveIteratorIterator implements OuterIterator
/** Flag: Catches exceptions during getChildren() calls and simply jumps
* to the next element. */
const CATCH_GET_CHILD = 2;
const CATCH_GET_CHILD = 0x00000002;
private $ait = array();
private $count = 0;

4
ext/spl/spl_iterators.h

@ -66,8 +66,8 @@ enum {
/* public */
CIT_CALL_TOSTRING = 0x00000001,
CIT_CATCH_GET_CHILD = 0x00000002,
CIT_TOSTRING_USE_KEY = 0x00000004,
CIT_TOSTRING_USE_CURRENT = 0x00000008,
CIT_TOSTRING_USE_KEY = 0x00000010,
CIT_TOSTRING_USE_CURRENT = 0x00000020,
CIT_PUBLIC = 0x0000FFFF,
/* private */
CIT_VALID = 0x00010000,

Loading…
Cancel
Save