|
SPL-StandardPHPLibrary
|


Public Member Functions | |
| __call ($func, $params) | |
| __construct (Iterator $it, $flags=self::CALL_TOSTRING) | |
| __toString () | |
| current () | |
| getInnerIterator () | |
| hasNext () | |
| key () | |
| next () | |
| rewind () | |
| valid () | |
Public Attributes | |
| const | CALL_TOSTRING = 0x00000001 |
| const | CATCH_GET_CHILD = 0x00000002 |
| const | TOSTRING_USE_CURRENT = 0x00000020 |
| const | TOSTRING_USE_KEY = 0x00000010 |
Private Attributes | |
| $current | |
| $it | |
| $key | |
| $strValue | |
| $valid | |
Cached iteration over another Iterator.
This iterator wrapper does a one ahead iteration. This way it knows whether the inner iterator has one more element.
Definition at line 28 of file cachingiterator.inc.
| CachingIterator::__construct | ( | Iterator $ | it, |
| $ | flags = self::CALL_TOSTRING |
||
| ) |
Construct from another iterator.
| it | Iterator to cache |
| flags | Bitmask:
|
Definition at line 47 of file cachingiterator.inc.
{
if ((($flags & self::CALL_TOSTRING) && ($flags & (self::TOSTRING_USE_KEY|self::TOSTRING_USE_CURRENT)))
|| ((flags & (self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT)) == (self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT)))
{
throw new InvalidArgumentException('Flags must contain only one of CIT_CALL_TOSTRING, CIT_TOSTRING_USE_KEY, CIT_TOSTRING_USE_CURRENT');
}
$this->it = $it;
$this->flags = $flags & (0x0000FFFF);
$this->next();
}

| CachingIterator::__call | ( | $ | func, |
| $ | params | ||
| ) |
Aggregate the inner iterator.
| func | Name of method to invoke |
| params | Array of parameters to pass to method |
Definition at line 122 of file cachingiterator.inc.
{
return call_user_func_array(array($this->it, $func), $params);
}
| CachingIterator::__toString | ( | ) |
| exception | when CALL_TOSTRING was not specified in constructor |
Definition at line 131 of file cachingiterator.inc.
References current(), and key().
{
if ($this->flags & self::TOSTRING_USE_KEY)
{
return $this->key;
}
else if ($this->flags & self::TOSTRING_USE_CURRENT)
{
return $this->current;
}
if (!$this->flags & self::CALL_TOSTRING)
{
throw new exception('CachingIterator does not fetch string value (see CachingIterator::__construct)');
}
return $this->strValue;
}

| CachingIterator::current | ( | ) |
Implements Iterator.
Definition at line 105 of file cachingiterator.inc.
Referenced by __toString(), and next().
{
return $this->current;
}
| CachingIterator::getInnerIterator | ( | ) |
Implements OuterIterator.
Definition at line 151 of file cachingiterator.inc.
{
return $this->it;
}
| CachingIterator::hasNext | ( | ) |
Definition at line 98 of file cachingiterator.inc.
{
return $this->it->valid();
}
| CachingIterator::key | ( | ) |
Implements Iterator.
Definition at line 112 of file cachingiterator.inc.
Referenced by __toString(), and next().
{
return $this->key;
}
| CachingIterator::next | ( | ) |
Forward to the next element.
Implements Iterator.
Definition at line 69 of file cachingiterator.inc.
References current(), key(), and valid().
Referenced by __construct(), and rewind().
{
if ($this->valid = $this->it->valid()) {
$this->current = $this->it->current();
$this->key = $this->it->key();
if ($this->flags & self::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();
}

| CachingIterator::rewind | ( | ) |
Rewind the Iterator.
Implements Iterator.
Reimplemented in RecursiveCachingIterator.
Definition at line 61 of file cachingiterator.inc.
References next().
{
$this->it->rewind();
$this->next();
}

| CachingIterator::valid | ( | ) |
Implements Iterator.
Definition at line 91 of file cachingiterator.inc.
Referenced by next().
{
return $this->valid;
}
CachingIterator::$current [private] |
Definition at line 36 of file cachingiterator.inc.
CachingIterator::$it [private] |
Definition at line 35 of file cachingiterator.inc.
Referenced by __construct().
CachingIterator::$key [private] |
Definition at line 37 of file cachingiterator.inc.
CachingIterator::$strValue [private] |
Definition at line 39 of file cachingiterator.inc.
CachingIterator::$valid [private] |
Definition at line 38 of file cachingiterator.inc.
| const CachingIterator::CALL_TOSTRING = 0x00000001 |
Definition at line 30 of file cachingiterator.inc.
Referenced by DirectoryGraphIterator\__construct(), and DirectoryTreeIterator\__construct().
| const CachingIterator::CATCH_GET_CHILD = 0x00000002 |
Definition at line 31 of file cachingiterator.inc.
Referenced by DirectoryGraphIterator\__construct(), and DirectoryTreeIterator\__construct().
| const CachingIterator::TOSTRING_USE_CURRENT = 0x00000020 |
Definition at line 33 of file cachingiterator.inc.
| const CachingIterator::TOSTRING_USE_KEY = 0x00000010 |
Definition at line 32 of file cachingiterator.inc.
1.7.5.1