summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2005-10-08 19:09:58 +0000
committerMarcus Boerger <helly@php.net>2005-10-08 19:09:58 +0000
commit11f0ff9c1afece2127ef7c0fc2e9f6b3f5b46d15 (patch)
treeef83e26da6b1cf822f8f28828cbe92192edd619c
parent7357ac0b968bb338bddfc47ae6ffe51e012f41e7 (diff)
downloadphp-git-11f0ff9c1afece2127ef7c0fc2e9f6b3f5b46d15.tar.gz
- Update docu
- Synch class consts with HEAD - Synch example RecursiveTreeIterator (as far as possible)
-rwxr-xr-xext/spl/examples/class_tree.php1
-rwxr-xr-xext/spl/examples/recursivetreeiterator.inc25
-rwxr-xr-xext/spl/internal/cachingiterator.inc8
-rwxr-xr-xext/spl/internal/recursiveiteratoriterator.inc2
-rwxr-xr-xext/spl/spl_iterators.h4
5 files changed, 30 insertions, 10 deletions
diff --git a/ext/spl/examples/class_tree.php b/ext/spl/examples/class_tree.php
index 07741a7dd8..a3083280be 100755
--- a/ext/spl/examples/class_tree.php
+++ b/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\>
*
diff --git a/ext/spl/examples/recursivetreeiterator.inc b/ext/spl/examples/recursivetreeiterator.inc
index 62198c8d36..ea3cb6ea7f 100755
--- a/ext/spl/examples/recursivetreeiterator.inc
+++ b/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
diff --git a/ext/spl/internal/cachingiterator.inc b/ext/spl/internal/cachingiterator.inc
index 6391322c3d..1129793873 100755
--- a/ext/spl/internal/cachingiterator.inc
+++ b/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;
diff --git a/ext/spl/internal/recursiveiteratoriterator.inc b/ext/spl/internal/recursiveiteratoriterator.inc
index 61a9d60a27..716ab475ff 100755
--- a/ext/spl/internal/recursiveiteratoriterator.inc
+++ b/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;
diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h
index 1f4a61025e..92f5d97ae5 100755
--- a/ext/spl/spl_iterators.h
+++ b/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,