r1522 - in trunk: . core core/Base core/SPL core/SPL/bundled doc doc/doxy doc/spl doc/spl/examples doc/spl/examples/tests doc/spl/internal doc/www/parts main/Flow

From: <voxusAT@ATshadanakar.org>
Date: Sun, 9 Apr 2006 22:27:03 +0400 (MSD)

Author: voxus
Date: 2006-04-09 22:26:57 +0400 (Sun, 09 Apr 2006)
New Revision: 1522

Added:
   trunk/core/SPL/
   trunk/core/SPL/AbstractList.class.php
   trunk/core/SPL/IndexedList.class.php
   trunk/core/SPL/PlainList.class.php
   trunk/core/SPL/SimplifiedArrayAccess.class.php
   trunk/core/SPL/bundled/
   trunk/core/SPL/bundled/ArrayAccess.class.php
   trunk/doc/doxy/spl
   trunk/doc/spl/
   trunk/doc/spl/Doxyfile
   trunk/doc/spl/examples/
   trunk/doc/spl/examples/autoload.inc
   trunk/doc/spl/examples/cachingrecursiveiterator.inc
   trunk/doc/spl/examples/class_tree.php
   trunk/doc/spl/examples/dba_array.php
   trunk/doc/spl/examples/dba_dump.php
   trunk/doc/spl/examples/dbaarray.inc
   trunk/doc/spl/examples/dbareader.inc
   trunk/doc/spl/examples/directoryfilterdots.inc
   trunk/doc/spl/examples/directorygraphiterator.inc
   trunk/doc/spl/examples/directorytree.inc
   trunk/doc/spl/examples/directorytree.php
   trunk/doc/spl/examples/directorytreeiterator.inc
   trunk/doc/spl/examples/findfile.inc
   trunk/doc/spl/examples/findfile.php
   trunk/doc/spl/examples/findregex.php
   trunk/doc/spl/examples/ini_groups.php
   trunk/doc/spl/examples/inigroups.inc
   trunk/doc/spl/examples/keyfilter.inc
   trunk/doc/spl/examples/nocvsdir.php
   trunk/doc/spl/examples/recursivetreeiterator.inc
   trunk/doc/spl/examples/regexfindfile.inc
   trunk/doc/spl/examples/searchiterator.inc
   trunk/doc/spl/examples/tests/
   trunk/doc/spl/examples/tests/examples.inc
   trunk/doc/spl/examples/tree.php
   trunk/doc/spl/internal/
   trunk/doc/spl/internal/appenditerator.inc
   trunk/doc/spl/internal/cachingiterator.inc
   trunk/doc/spl/internal/emptyiterator.inc
   trunk/doc/spl/internal/filteriterator.inc
   trunk/doc/spl/internal/infiniteiterator.inc
   trunk/doc/spl/internal/iteratoriterator.inc
   trunk/doc/spl/internal/limititerator.inc
   trunk/doc/spl/internal/norewinditerator.inc
   trunk/doc/spl/internal/outeriterator.inc
   trunk/doc/spl/internal/parentiterator.inc
   trunk/doc/spl/internal/recursivearrayiterator.inc
   trunk/doc/spl/internal/recursivecachingiterator.inc
   trunk/doc/spl/internal/recursivefilteriterator.inc
   trunk/doc/spl/internal/recursiveiterator.inc
   trunk/doc/spl/internal/recursiveiteratoriterator.inc
   trunk/doc/spl/internal/seekableiterator.inc
   trunk/doc/spl/internal/splfileobject.inc
   trunk/doc/spl/internal/splobjectstorage.inc
   trunk/doc/spl/spl.php
Modified:
   trunk/core/Base/IdentifiableObject.class.php
   trunk/doc/Doxyfile
   trunk/doc/THANKS
   trunk/doc/onphp.doxy.php
   trunk/doc/www/parts/doxyLinks.html
   trunk/global.inc.php.tpl
   trunk/main/Flow/Model.class.php
Log:
+ basic SPL support

Modified: trunk/core/Base/IdentifiableObject.class.php
===================================================================
--- trunk/core/Base/IdentifiableObject.class.php 2006-04-09 15:42:30 UTC (rev 1521)
+++ trunk/core/Base/IdentifiableObject.class.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -17,10 +17,15 @@
          *
          * @ingroup Base
         **/
- class /* spirit of */ IdentifiableObject implements Identifiable
+ class /* spirit of */ IdentifiableObject implements Identifiable, Creatable
         {
                 protected $id = null;
                 
+ public static function create()
+ {
+ return new self;
+ }
+
                 public static function wrap($id)
                 {
                         return self::create()->setId($id);

Added: trunk/core/SPL/AbstractList.class.php
===================================================================
--- trunk/core/SPL/AbstractList.class.php (rev 0)
+++ trunk/core/SPL/AbstractList.class.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,81 @@
+<?php
+/***************************************************************************
+ * Copyright (C) 2006 by Konstantin V. Arkhipov *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* $Id$ */
+
+ /**
+ * Base for handling Identifiable object's lists.
+ *
+ * @ingroup onSPL
+ **/
+ abstract class AbstractList implements ArrayAccess, SimplifiedArrayAccess
+ {
+ protected $list = array();
+
+ public function offsetGet($offset)
+ {
+ if (isset($this->list[$offset]))
+ return $this->list[$offset];
+
+ throw new MissingElementException(
+ "no object found with index == '{$offset}'"
+ );
+ }
+
+ public function offsetUnset($offset)
+ {
+ unset($this->list[$offset]);
+
+ return $this;
+ }
+
+ public function offsetExists($offset)
+ {
+ return isset($this->list[$offset]);
+ }
+
+ // SAA goes here
+
+ public function clean()
+ {
+ $this->list = array();
+ }
+
+ public function isEmpty()
+ {
+ return ($this->list === array());
+ }
+
+ public function getList()
+ {
+ return $this->list;
+ }
+
+ public function set($name, $var)
+ {
+ return $this->offsetSet($name, $var);
+ }
+
+ public function get($name)
+ {
+ return $this->offsetGet($name);
+ }
+
+ public function has($name)
+ {
+ return $this->offsetExists($name);
+ }
+
+ public function drop($name)
+ {
+ return $this->offsetUnset($name);
+ }
+ }
+?>
\ No newline at end of file

Property changes on: trunk/core/SPL/AbstractList.class.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/core/SPL/IndexedList.class.php
===================================================================
--- trunk/core/SPL/IndexedList.class.php (rev 0)
+++ trunk/core/SPL/IndexedList.class.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,41 @@
+<?php
+/***************************************************************************
+ * Copyright (C) 2006 by Konstantin V. Arkhipov *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* $Id$ */
+
+ /**
+ * Unordered indexed list of Identifiable objects.
+ *
+ * @ingroup onSPL
+ **/
+ final class IndexedList extends AbstractList implements Creatable
+ {
+ public static function create()
+ {
+ return new self;
+ }
+
+ public function offsetSet($offset, $value)
+ {
+ Assert::isTrue($value instanceof Identifiable);
+
+ $offset = $value->getId();
+
+ if ($this->offsetExists($offset))
+ throw new WrongArgumentException(
+ "object with id == '{$offset}' already exists"
+ );
+
+ $this->list[$offset] = $value;
+
+ return $this;
+ }
+ }
+?>
\ No newline at end of file

Property changes on: trunk/core/SPL/IndexedList.class.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/core/SPL/PlainList.class.php
===================================================================
--- trunk/core/SPL/PlainList.class.php (rev 0)
+++ trunk/core/SPL/PlainList.class.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,34 @@
+<?php
+/***************************************************************************
+ * Copyright (C) 2006 by Konstantin V. Arkhipov *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* $Id$ */
+
+ /**
+ * Ordered unindexed list of Identifiable objects.
+ *
+ * @ingroup onSPL
+ **/
+ final class PlainList extends AbstractList implements Creatable
+ {
+ public static function create()
+ {
+ return new self;
+ }
+
+ public function offsetSet($offset, $value)
+ {
+ Assert::isTrue($value instanceof Identifiable);
+
+ $this->list[] = $value;
+
+ return $this;
+ }
+ }
+?>
\ No newline at end of file

Property changes on: trunk/core/SPL/PlainList.class.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/core/SPL/SimplifiedArrayAccess.class.php
===================================================================
--- trunk/core/SPL/SimplifiedArrayAccess.class.php (rev 0)
+++ trunk/core/SPL/SimplifiedArrayAccess.class.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,28 @@
+<?php
+/***************************************************************************
+ * Copyright (C) 2006 by Konstantin V. Arkhipov *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+/* $Id$ */
+
+ /**
+ * @ingroup onSPL
+ **/
+ interface SimplifiedArrayAccess
+ {
+ public function clean();
+ public function isEmpty();
+
+ public function getList();
+
+ public function set($name, $var);
+ public function get($name);
+ public function has($name);
+ public function drop($name);
+ }
+?>
\ No newline at end of file

Property changes on: trunk/core/SPL/SimplifiedArrayAccess.class.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/core/SPL/bundled/ArrayAccess.class.php
===================================================================
--- trunk/core/SPL/bundled/ArrayAccess.class.php (rev 0)
+++ trunk/core/SPL/bundled/ArrayAccess.class.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,44 @@
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2006 by Marcus Boerger *
+ * *
+ * This source file is subject to version 3.01 of the PHP license, *
+ * that is available through the world-wide-web at the following url: *
+ * http://www.php.net/license/3_01.txt *
+ * *
+ * If you did not receive a copy of the PHP license and are unable to *
+ * obtain it through the world-wide-web, please send a note to *
+ * licenseAT@ATphp.net so we can mail you a copy immediately. *
+ * *
+ ***************************************************************************/
+/* $Id$ */
+
+ /**
+ * Interface to override array access of objects.
+ *
+ * @ingroup onSPL
+ **/
+ interface ArrayAccess
+ {
+ /**
+ * @param $offset to modify
+ * @param $value new value
+ **/
+ public function offsetSet($offset, $value);
+
+ /**
+ * @param $offset to retrieve
+ * @return value at given offset
+ */
+ public function offsetGet($offset);
+
+ /// @param $offset to delete
+ public function offsetUnset($offset);
+
+ /**
+ * @param $offset to check
+ * @return whether the offset exists.
+ **/
+ public function offsetExists($offset);
+ }
+?>
\ No newline at end of file

Property changes on: trunk/core/SPL/bundled/ArrayAccess.class.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/doc/Doxyfile
===================================================================
--- trunk/doc/Doxyfile 2006-04-09 15:42:30 UTC (rev 1521)
+++ trunk/doc/Doxyfile 2006-04-09 18:26:57 UTC (rev 1522)
@@ -85,10 +85,11 @@
 INPUT = ./onphp.doxy.php ../
 FILE_PATTERNS = *.php
 RECURSIVE = YES
-EXCLUDE = ../test \
- ../incubator \
- sample/ \
- examples/
+EXCLUDE = ../test/ \
+ ../incubator/ \
+ ../core/SPL/bundled/ \
+ examples/ \
+ spl/
 EXCLUDE_SYMLINKS = NO
 EXCLUDE_PATTERNS =
 EXAMPLE_PATH = ./examples/
@@ -111,8 +112,8 @@
 #---------------------------------------------------------------------------
 # configuration options related to the alphabetical class index
 #---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = NO
-COLS_IN_ALPHA_INDEX = 5
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 4
 IGNORE_PREFIX =
 #---------------------------------------------------------------------------
 # configuration options related to the HTML output
@@ -199,7 +200,7 @@
 #---------------------------------------------------------------------------
 # Configuration::additions related to external references
 #---------------------------------------------------------------------------
-TAGFILES =
+TAGFILES = doxy/spl/spl.tag=../../spl/html
 GENERATE_TAGFILE =
 ALLEXTERNALS = NO
 EXTERNAL_GROUPS = YES
@@ -225,7 +226,7 @@
 DOTFILE_DIRS =
 MAX_DOT_GRAPH_WIDTH = 1024
 MAX_DOT_GRAPH_HEIGHT = 1024
-MAX_DOT_GRAPH_DEPTH = 1000
+MAX_DOT_GRAPH_DEPTH = 0
 DOT_TRANSPARENT = NO
 DOT_MULTI_TARGETS = YES
 GENERATE_LEGEND = YES

Modified: trunk/doc/THANKS
===================================================================
--- trunk/doc/THANKS 2006-04-09 15:42:30 UTC (rev 1521)
+++ trunk/doc/THANKS 2006-04-09 18:26:57 UTC (rev 1522)
@@ -5,4 +5,5 @@
 Alexey Y. Chumakov <achumakovAT@ATgentoo.org>
 Dimitry P. Ivanov <dimitry.ivanovAT@ATgmail.com>
 Denis Gabaidulin <gabadenAT@ATgmail.com>
+Marcus Boerger <hellyAT@ATphp.net>
 Sergey N. Lasunov <sergeyAT@ATmicrobecal.com>

Added: trunk/doc/doxy/spl
===================================================================
--- trunk/doc/doxy/spl (rev 0)
+++ trunk/doc/doxy/spl 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1 @@
+link spl-5.1.2
\ No newline at end of file

Property changes on: trunk/doc/doxy/spl
___________________________________________________________________
Name: svn:special
   + *

Modified: trunk/doc/onphp.doxy.php
===================================================================
--- trunk/doc/onphp.doxy.php 2006-04-09 15:42:30 UTC (rev 1521)
+++ trunk/doc/onphp.doxy.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -75,6 +75,9 @@
          * @defgroup Form Data validation layer
          * @ingroup Core
          *
+ * @defgroup onSPL Things based on Standard PHP Library
+ * @ingroup Core
+ *
          * @defgroup Filters Tools for primitive's filtration
          * @ingroup Form
          *

Added: trunk/doc/spl/Doxyfile
===================================================================
--- trunk/doc/spl/Doxyfile (rev 0)
+++ trunk/doc/spl/Doxyfile 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,221 @@
+# $Id$
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = SPL-StandardPHPLibrary
+PROJECT_NUMBER = 5.1.2
+OUTPUT_DIRECTORY = ../doxy/spl-5.1.2
+CREATE_SUBDIRS = NO
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ABBREVIATE_BRIEF =
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = YES
+STRIP_FROM_PATH =
+STRIP_FROM_INC_PATH =
+SHORT_NAMES = NO
+JAVADOC_AUTOBRIEF = YES
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+DISTRIBUTE_GROUP_DOC = YES
+TAB_SIZE = 4
+ALIASES =
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+SUBGROUPING = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL = YES
+EXTRACT_PRIVATE = YES
+EXTRACT_STATIC = YES
+EXTRACT_LOCAL_CLASSES = YES
+EXTRACT_LOCAL_METHODS = YES
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+INTERNAL_DOCS = YES
+CASE_SENSE_NAMES = YES
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+SORT_BRIEF_DOCS = YES
+SORT_BY_SCOPE_NAME = NO
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+SHOW_USED_FILES = YES
+SHOW_DIRECTORIES = YES
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = spl.php \
+ examples \
+ internal
+FILE_PATTERNS = *.inc \
+ *.php
+RECURSIVE = NO
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS =
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_PATTERNS =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = YES
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+USE_HTAGS = NO
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = YES
+COLS_IN_ALPHA_INDEX = 4
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER = ../www/parts/doxyHead.html
+HTML_FOOTER = ../www/parts/doxyHeel.html
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = NO
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = NO
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = NO
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+XML_PROGRAMLISTING = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE = ../doxy/spl-5.1.2/spl.tag
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = NO
+HAVE_DOT = YES
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = NO
+UML_LOOK = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = YES
+GRAPHICAL_HIERARCHY = YES
+DIRECTORY_GRAPH = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 0
+DOT_TRANSPARENT = NO
+DOT_MULTI_TARGETS = YES
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO

Added: trunk/doc/spl/examples/autoload.inc
===================================================================
--- trunk/doc/spl/examples/autoload.inc (rev 0)
+++ trunk/doc/spl/examples/autoload.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,50 @@
+<?php
+
+/** @file autoload.inc
+ * @ingroup Examples
+ * @brief function __autoload
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** \internal
+ * Tries to load class $classname from directory $dir.
+ */
+function __load_class($classname, $dir)
+{
+ $file = $dir . '/' . $classname . '.inc';
+ if (file_exists($file))
+ {
+ require_once($file);
+ return true;
+ }
+ return false;
+}
+
+/**
+ * @brief Class loader for SPL example classes
+ * @author Marcus Boerger
+ * @version 1.0
+ *
+ * Loads classes automatically from include_path as given by ini or from
+ * current directory of script or include file.
+ */
+function __autoload($classname) {
+ $classname = strtolower($classname);
+ $inc = split(':', ini_get('include_path'));
+ $inc[] = '.';
+ $inc[] = dirname($_SERVER['PATH_TRANSLATED']);
+ foreach($inc as $dir)
+ {
+ if (__load_class($classname, $dir))
+ {
+ fprintf(STDERR, 'Loading class('.$classname.")\n");
+ return;
+ }
+ }
+ fprintf(STDERR, 'Class not found ('.$classname.")\n");
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/cachingrecursiveiterator.inc
===================================================================
--- trunk/doc/spl/examples/cachingrecursiveiterator.inc (rev 0)
+++ trunk/doc/spl/examples/cachingrecursiveiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,28 @@
+<?php
+
+/** @file cachingrecursiveiterator.inc
+ * @ingroup Examples
+ * @brief class CachingRecursiveIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief Compatibility to PHP 5.0
+ * @author Marcus Boerger
+ * @version 1.2
+ * @deprecated
+ *
+ * Class RecursiveCachingIterator was named CachingRecursiveIterator until
+ * PHP 5.0.6.
+ *
+ * @see RecursiveCachingIterator
+ */
+
+class CachingRecursiveIterator extends RecursiveCachingIterator
+{
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/class_tree.php
===================================================================
--- trunk/doc/spl/examples/class_tree.php (rev 0)
+++ trunk/doc/spl/examples/class_tree.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,87 @@
+<?php
+
+/** @file class_tree.php
+ * @brief Class Tree example
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ * @version 1.0
+ *
+ * Usage: php class_tree.php \<class\>
+ *
+ * Simply specify the root class or interface to tree with parameter \<class\>.
+ */
+
+if ($argc < 2) {
+ echo <<<EOF
+Usage: php ${_SERVER['PHP_SELF']} <class>
+
+Displays a graphical tree for the given <class>.
+
+<class> The class or interface for which to generate the tree graph.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("RecursiveTreeIterator", false)) require_once("recursivetreeiterator.inc");
+
+/** \brief Collects sub classes for given class or interface
+ */
+class SubClasses extends RecursiveArrayIterator
+{
+ /** @param base base class to collect sub classes for
+ * @param check_interfaces whether we deal with interfaces
+ */
+ function __construct($base, $check_interfaces = false)
+ {
+ foreach(get_declared_classes() as $cname)
+ {
+ if (strcasecmp(get_parent_class($cname), $base) == 0)
+ {
+ $this->offsetSet($cname, new SubClasses($cname));
+ }
+ if ($check_interfaces)
+ {
+ foreach(class_implements($cname) as $iname)
+ {
+ if (strcasecmp($iname, $base) == 0)
+ {
+ $this->offsetSet($cname, new SubClasses($cname));
+ }
+ }
+ }
+ }
+ if ($check_interfaces)
+ {
+ foreach(get_declared_interfaces() as $cname)
+ {
+ foreach(class_implements($cname) as $iname)
+ {
+ if (strcasecmp($iname, $base) == 0)
+ {
+ $this->offsetSet($cname, new SubClasses($cname, true));
+ }
+ }
+ }
+ }
+ }
+
+ /** @return key() since that is the name we need
+ */
+ function current()
+ {
+ return parent::key();
+ }
+}
+
+$it = new RecursiveTreeIterator(new SubClasses($argv[1], true));
+
+echo $argv[1]."\n";
+foreach($it as $c=>$v)
+{
+ echo "$v\n";
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/class_tree.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/dba_array.php
===================================================================
--- trunk/doc/spl/examples/dba_array.php (rev 0)
+++ trunk/doc/spl/examples/dba_array.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,52 @@
+<?php
+
+/** @file dba_array.php
+ * @brief Program DBA array utility
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * Usage php dba_array.php \<file\> \<handler\> \<key\> [\<value\>]
+ *
+ * If \<value\> is specified then \<key\> is set to \<value\> in \<file\>.
+ * Else the value of \<key\> is printed only.
+ *
+ * Note: configure with --enable-dba
+ */
+
+if ($argc < 4) {
+ echo <<<EOF
+Usage: php ${_SERVER['PHP_SELF']} <file> <handler> <key> [<value>]
+
+If <value> is specified then <key> is set to <value> in <file>.
+Else the value of <key> is printed only.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
+
+try {
+ if ($argc > 2) {
+ $dba = new DbaArray($argv[1], $argv[2]);
+ if ($dba && $argc > 3) {
+ if ($argc > 4) {
+ $dba[$argv[3]] = $argv[4];
+ }
+ var_dump(array('Index' => $argv[3], 'Value' => $dba[$argv[3]]));
+ }
+ unset($dba);
+ }
+ else
+ {
+ echo "Not enough parameters\n";
+ exit(1);
+ }
+}
+catch (exception $err) {
+ var_dump($err);
+ exit(1);
+}
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/dba_array.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/dba_dump.php
===================================================================
--- trunk/doc/spl/examples/dba_dump.php (rev 0)
+++ trunk/doc/spl/examples/dba_dump.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,42 @@
+<?php
+
+/** @file dba_dump.php
+ * @brief Program DBA dump utility
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * Usage: php dba_dump.php \<file\> \<handler\> [\<regex\>]
+ *
+ * Show all groups in the ini file specified by \<file\>.
+ * The regular expression \<regex\> is used to filter the by setting name.
+ *
+ * Note: configure with --enable-dba
+ */
+
+if ($argc < 3) {
+ echo <<<EOF
+Usage: php ${_SERVER['PHP_SELF']} <file> <handler> [<regex>]
+
+Show all groups in the ini file specified by <file>.
+The regular expression <regex> is used to filter the by setting name.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
+if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
+
+$db = new DbaReader($argv[1], $argv[2]);
+
+if ($argc>3) {
+ $db = new KeyFilter($db, $argv[3]);
+}
+
+foreach($db as $key => $val) {
+ echo "'$key' => '$val'\n";
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/dba_dump.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/dbaarray.inc
===================================================================
--- trunk/doc/spl/examples/dbaarray.inc (rev 0)
+++ trunk/doc/spl/examples/dbaarray.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,98 @@
+<?php
+
+/** @file dbaarray.inc
+ * @ingroup Examples
+ * @brief class DbaArray
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
+
+/** @ingroup Examples
+ * @brief This implements a DBA Array
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class DbaArray extends DbaReader implements ArrayAccess
+{
+
+ /**
+ * Open database $file with $handler in read only mode.
+ *
+ * @param file Database file to open.
+ * @param handler Handler to use for database access.
+ */
+ function __construct($file, $handler)
+ {
+ $this->db = dba_popen($file, "c", $handler);
+ if (!$this->db) {
+ throw new exception("Databse could not be opened");
+ }
+ }
+
+ /**
+ * Close database.
+ */
+ function __destruct()
+ {
+ parent::__destruct();
+ }
+
+ /**
+ * Read an entry.
+ *
+ * @param $name key to read from
+ * @return value associated with $name
+ */
+ function offsetGet($name)
+ {
+ $data = dba_fetch($name, $this->db);
+ if($data) {
+ if (ini_get('magic_quotes_runtime')) {
+ $data = stripslashes($data);
+ }
+ //return unserialize($data);
+ return $data;
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+
+ /**
+ * Set an entry.
+ *
+ * @param $name key to write to
+ * @param $value value to write
+ */
+ function offsetSet($name, $value)
+ {
+ //dba_replace($name, serialize($value), $this->db);
+ dba_replace($name, $value, $this->db);
+ return $value;
+ }
+
+ /**
+ * @return whether key $name exists.
+ */
+ function offsetExists($name)
+ {
+ return dba_exists($name, $this->db);
+ }
+
+ /**
+ * Delete a key/value pair.
+ *
+ * @param $name key to delete.
+ */
+ function offsetUnset($name)
+ {
+ return dba_delete($name, $this->db);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/dbareader.inc
===================================================================
--- trunk/doc/spl/examples/dbareader.inc (rev 0)
+++ trunk/doc/spl/examples/dbareader.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,96 @@
+<?php
+
+/** @file dbareader.inc
+ * @ingroup Examples
+ * @brief class DbaReader
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief This implements a DBA Iterator.
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class DbaReader implements Iterator
+{
+
+ protected $db = NULL;
+ private $key = false;
+ private $val = false;
+
+ /**
+ * Open database $file with $handler in read only mode.
+ *
+ * @param file Database file to open.
+ * @param handler Handler to use for database access.
+ */
+ function __construct($file, $handler) {
+ if (!$this->db = dba_open($file, 'r', $handler)) {
+ throw new exception('Could not open file ' . $file);
+ }
+ }
+
+ /**
+ * Close database.
+ */
+ function __destruct() {
+ dba_close($this->db);
+ }
+
+ /**
+ * Rewind to first element.
+ */
+ function rewind() {
+ $this->key = dba_firstkey($this->db);
+ $this->fetch_data();
+ }
+
+ /**
+ * Move to next element.
+ *
+ * @return void
+ */
+ function next() {
+ $this->key = dba_nextkey($this->db);
+ $this->fetch_data();
+ }
+
+ /**
+ * Fetches the current data if $key is valid
+ */
+ private function fetch_data() {
+ if ($this->key !== false) {
+ $this->val = dba_fetch($this->key, $this->db);
+ }
+ }
+
+ /**
+ * @return Current data.
+ */
+ function current() {
+ return $this->val;
+ }
+
+ /**
+ * @return Whether more elements are available.
+ */
+ function valid() {
+ if ($this->db && $this->key !== false) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * @return Current key.
+ */
+ function key() {
+ return $this->key;
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/directoryfilterdots.inc
===================================================================
--- trunk/doc/spl/examples/directoryfilterdots.inc (rev 0)
+++ trunk/doc/spl/examples/directoryfilterdots.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,45 @@
+<?php
+
+/** @file directoryfilterdots.inc
+ * @ingroup Examples
+ * @brief class DirectoryFilterDots
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief A filtered DirectoryIterator
+ * @author Marcus Boerger
+ * @version 1.1
+ *
+ * This Iteraotr takes a pathname from which it creates a DirectoryIterator
+ * and makes it recursive. Further more it filters the entries '.' and '..'.
+ */
+class DirectoryFilterDots extends RecursiveFilterIterator
+{
+ /** Construct from a path.
+ * @param $path directory to iterate
+ */
+ function __construct($path)
+ {
+ parent::__construct(new DirectoryIterator($path));
+ }
+
+ /** @return whether the current entry is neither '.' nor '..'
+ */
+ function accept()
+ {
+ return !$this->getInnerIterator()->isDot();
+ }
+
+ /** @return the current entries path name
+ */
+ function key()
+ {
+ return $this->getInnerIterator()->getPathname();
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/directorygraphiterator.inc
===================================================================
--- trunk/doc/spl/examples/directorygraphiterator.inc (rev 0)
+++ trunk/doc/spl/examples/directorygraphiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,25 @@
+<?php
+
+/** @file directorygraphiterator.inc
+ * @ingroup Examples
+ * @brief class DirectoryGraphIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief A tree iterator that only shows directories.
+ * @author Marcus Boerger
+ * @version 1.1
+ */
+class DirectoryGraphIterator extends DirectoryTreeIterator
+{
+ function __construct($path)
+ {
+ RecursiveIteratorIterator::__construct(new RecursiveCachingIterator(new ParentIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME)), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/directorytree.inc
===================================================================
--- trunk/doc/spl/examples/directorytree.inc (rev 0)
+++ trunk/doc/spl/examples/directorytree.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,27 @@
+<?php
+
+/** @file directorytree.inc
+ * @ingroup Examples
+ * @brief class DirectoryTree
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief A directory iterator that does not show '.' and '..'.
+ * @author Marcus Boerger
+ * @version 1.0
+ */
+class DirectoryTree extends RecursiveIteratorIterator
+{
+ /** Construct from a path.
+ * @param $path directory to iterate
+ */
+ function __construct($path) {
+ parent::__construct(new DirectoryFilterDots($path));
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/directorytree.php
===================================================================
--- trunk/doc/spl/examples/directorytree.php (rev 0)
+++ trunk/doc/spl/examples/directorytree.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,37 @@
+<?php
+
+/** @file directorytree.php
+ * @brief Program Directory tree example
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * Usage: php directorytree.php \<path\> [\<start\> [\<count\>]]
+ *
+ * Simply specify the path to tree with parameter \<path\>.
+ */
+
+if ($argc < 2) {
+ echo <<<EOF
+Usage: php ${_SERVER['PHP_SELF']} <path>
+
+Displays a graphical directory tree for the given <path>.
+
+<path> The directory for which to generate the directory tree graph.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
+
+$length = $argc > 3 ? $argv[3] : -1;
+
+echo $argv[1]."\n";
+foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $key=>$file) {
+//foreach(new DirectoryTreeIterator($argv[1]) as $file) {
+ echo $file . "\n";
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/directorytree.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/directorytreeiterator.inc
===================================================================
--- trunk/doc/spl/examples/directorytreeiterator.inc (rev 0)
+++ trunk/doc/spl/examples/directorytreeiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,47 @@
+<?php
+
+/** @file directorytreeiterator.inc
+ * @ingroup Examples
+ * @brief class DirectoryTreeIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief DirectoryIterator to generate ASCII graphic directory trees
+ * @author Marcus Boerger
+ * @version 1.1
+ */
+class DirectoryTreeIterator extends RecursiveIteratorIterator
+{
+ /** Construct from a path.
+ * @param $path directory to iterate
+ */
+ function __construct($path)
+ {
+ parent::__construct(new RecursiveCachingIterator(new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME), CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD), 1);
+ }
+
+ /** @return the current element prefixed with ASCII graphics
+ */
+ function current()
+ {
+ $tree = '';
+ for ($l=0; $l < $this->getDepth(); $l++) {
+ $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
+ }
+ return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
+ . $this->getSubIterator($l)->__toString();
+ }
+
+ /** Aggregates the inner iterator
+ */
+ function __call($func, $params)
+ {
+ return call_user_func_array(array($this->getSubIterator(), $func), $params);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/findfile.inc
===================================================================
--- trunk/doc/spl/examples/findfile.inc (rev 0)
+++ trunk/doc/spl/examples/findfile.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,65 @@
+<?php
+
+/** @file findfile.inc
+ * @ingroup Examples
+ * @brief class FindFile
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+if (!class_exists("FindFile", false)) require_once("findfile.inc");
+if (!class_exists("AppendIterator", false)) require_once("appenditerator.inc");
+
+/** @ingroup Examples
+ * @brief Base class to find files
+ * @author Marcus Boerger
+ * @version 1.1
+ *
+ */
+class FindFile extends FilterIterator
+{
+ /** @internal filename to find */
+ private $file;
+
+ /** Construct from path and filename
+ *
+ * @param $path the directory to search in
+ * If path contains ';' then this parameter is split and every
+ * part of it is used as separate directory.
+ * @param $file the name of the files to search fro
+ */
+ function __construct($path, $file)
+ {
+ $this->file = $file;
+ $list = split(';', $path);
+ if (count($list) <= 1) {
+ parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
+ } else {
+ $it = new AppendIterator();
+ foreach($list as $path) {
+ $it->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
+ }
+ parent::__construct($it);
+ }
+ }
+
+ /** @return whether the current file matches the given filename
+ */
+ function accept()
+ {
+ return !strcmp($this->current(), $this->file);
+ }
+
+ /** @return the filename to search for.
+ * @note This may be overloaded and contain a regular expression for an
+ * extended class that uses regular expressions to search.
+ */
+ function getSearch()
+ {
+ return $this->file;
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/findfile.php
===================================================================
--- trunk/doc/spl/examples/findfile.php (rev 0)
+++ trunk/doc/spl/examples/findfile.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,33 @@
+<?php
+
+/** @file findfile.php
+ * @brief Program Find a specific file by name.
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * Usage: php findfile.php \<path\> \<name\>
+ *
+ * \<path\> Path to search in. You can specify multiple paths by separating
+ * them with ';'.
+ * \<name\> Filename to look for.
+ */
+
+if ($argc < 3) {
+ echo <<<EOF
+Usage: php findfile.php <path> <name>
+
+Find a specific file by name.
+
+<path> Path to search in.
+<name> Filename to look for.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("FindFile", false)) require_once("findfile.inc");
+
+foreach(new FindFile($argv[1], $argv[2]) as $file) echo $file->getPathname()."\n";
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/findfile.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/findregex.php
===================================================================
--- trunk/doc/spl/examples/findregex.php (rev 0)
+++ trunk/doc/spl/examples/findregex.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,36 @@
+<?php
+
+/** @file findregex.php
+ * @brief Program Find a specific file by name.
+ * @ingroup Examples
+ * @author Marcus Boerger, Adam Trachtenberg
+ * @date 2004
+ *
+ * Usage: php findregex.php \<path\> \<name\>
+ *
+ * \<path\> Path to search in.
+ * \<name\> Filename to look for.
+ */
+
+if ($argc < 3) {
+ echo <<<EOF
+Usage: php findregex.php <file> <name>
+
+Find a specific file by name.
+
+<path> Path to search in.
+<name> Regex for filenames to look for.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("RegexFindFile", false)) require_once("regexfindfile.inc");
+
+foreach(new RegexFindFile($argv[1], $argv[2]) as $file)
+{
+ echo $file->getPathname()."\n";
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/findregex.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/ini_groups.php
===================================================================
--- trunk/doc/spl/examples/ini_groups.php (rev 0)
+++ trunk/doc/spl/examples/ini_groups.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,41 @@
+<?php
+
+/** @file ini_groups.php
+ * @brief Program List groups within an ini file
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * Usage: php dba_dump.php \<file\> [\<regex\>]
+ *
+ * Show all groups in the ini file specified by \<file\>.
+ * The regular expression \<regex\> is used to filter the result.
+ *
+ * Note: configure with --enable-dba
+ */
+
+if ($argc < 2) {
+ echo <<<EOF
+Usage: php dba_dump.php <file> [<regex>]
+
+Show all groups in the ini file specified by <file>.
+The regular expression <regex> is used to filter the result.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
+if (!class_exists("IniGroups", false)) require_once("inigroups.inc");
+
+$it = new IniGroups($argv[1]);
+if ($argc>2) {
+ $it = new KeyFilter($it, $argv[2]);
+}
+
+foreach($it as $group) {
+ echo "$group\n";
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/ini_groups.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/inigroups.inc
===================================================================
--- trunk/doc/spl/examples/inigroups.inc (rev 0)
+++ trunk/doc/spl/examples/inigroups.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,54 @@
+<?php
+
+/** @file inigroups.inc
+ * @ingroup Examples
+ * @brief class IniGroups
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
+if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
+
+/** @ingroup Examples
+ * @brief Class to iterate all groups within an ini file.
+ * @author Marcus Boerger
+ * @version 1.1
+ *
+ * Using this class you can iterator over all groups of a ini file.
+ *
+ * This class uses a 'is-a' relation to KeyFilter in contrast to a 'has-a'
+ * relation. Doing so both current() and key() methods must be overwritten.
+ * If it would use a 'has-a' relation there would be much more to type...
+ * but for puritists that would allow correctness in so far as then no
+ * key() would be needed.
+ */
+class IniGroups extends KeyFilter
+{
+ /**
+ * Construct an ini file group iterator from a filename.
+ *
+ * @param file Ini file to open.
+ */
+ function __construct($file) {
+ parent::__construct(new DbaReader($file, 'inifile'), '^\[.*\]$');
+ }
+
+ /**
+ * @return The current group.
+ */
+ function current() {
+ return substr(parent::key(),1,-1);
+ }
+
+ /**
+ * @return The current group.
+ */
+ function key() {
+ return substr(parent::key(),1,-1);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/keyfilter.inc
===================================================================
--- trunk/doc/spl/examples/keyfilter.inc (rev 0)
+++ trunk/doc/spl/examples/keyfilter.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,64 @@
+<?php
+
+/** @file keyfilter.inc
+ * @ingroup Examples
+ * @brief class KeyFilter
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief Regular expression filter for string iterators
+ * @author Marcus Boerger
+ * @version 1.1
+ *
+ * Instances of this class act as a filter around iterators whose elements
+ * are strings. In other words you can put an iterator into the constructor
+ * and the instance will only return elements which match the given regular
+ * expression.
+ */
+class KeyFilter extends FilterIterator
+{
+ /** @internal regular exoression used as filter */
+ private $regex;
+
+ /**
+ * Constructs a filter around an iterator whose elemnts are strings.
+ * If the given iterator is of type spl_sequence then its rewind()
+ * method is called.
+ *
+ * @param it Object that implements at least spl_forward
+ * @param regex Regular expression used as a filter.
+ */
+ function __construct(Iterator $it, $regex)
+ {
+ parent::__construct($it);
+ $this->regex = $regex;
+ }
+
+ /** \return whether the current key mathes the regular expression
+ */
+ function accept()
+ {
+ return ereg($this->regex, $this->getInnerIterator()->key());
+ }
+
+ /** @return regular expression used as filter
+ */
+ function getRegex()
+ {
+ return $this->regex;
+ }
+
+ /**
+ * hidden __clone
+ */
+ protected function __clone()
+ {
+ // disallow clone
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/nocvsdir.php
===================================================================
--- trunk/doc/spl/examples/nocvsdir.php (rev 0)
+++ trunk/doc/spl/examples/nocvsdir.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,55 @@
+<?php
+
+/** @file nocvsdir.php
+ * @brief Program Dir without CVS subdirs
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2006
+ * @version 1.1
+ *
+ * Usage: php nocvsdir.php \<path\>
+ *
+ * Simply specify the path to tree with parameter \<path\>.
+ */
+
+if ($argc < 2) {
+ echo <<<EOF
+Usage: php ${_SERVER['PHP_SELF']} <path>
+
+Show the directory and all it's contents without any CVS directory in <path>.
+
+<path> The directory for which to generate the directory.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("RecursiveFilterIterator")) require_once("recursivefilteriterator.inc");
+
+class NoCvsDirectory extends RecursiveFilterIterator
+{
+ function __construct($path)
+ {
+ parent::__construct(new RecursiveDirectoryIterator($path));
+ }
+
+ function accept()
+ {
+ return $this->getInnerIterator()->getFilename() != 'CVS';
+ }
+
+ function getChildren()
+ {
+ return new NoCvsDirectory($this->key());
+ }
+}
+
+$it = new RecursiveIteratorIterator(new NoCvsDirectory($argv[1]));
+
+foreach($it as $pathname => $file)
+{
+ echo $pathname."\n";
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/nocvsdir.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/examples/recursivetreeiterator.inc
===================================================================
--- trunk/doc/spl/examples/recursivetreeiterator.inc (rev 0)
+++ trunk/doc/spl/examples/recursivetreeiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,113 @@
+<?php
+
+/** @file recursivetreeiterator.inc
+ * @ingroup Examples
+ * @brief class RecursiveTreeIterator
+ * @author Marcus Boerger, Johannes Schlueter
+ * @date 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+
+/** @ingroup Examples
+ * @brief RecursiveIteratorIterator to generate ASCII graphic trees for the
+ * entries in a RecursiveIterator
+ * @author Marcus Boerger, Johannes Schlueter
+ * @version 1.0
+ */
+class RecursiveTreeIterator extends RecursiveIteratorIterator
+{
+ const BYPASS_CURRENT = 0x00000004;
+ const BYPASS_KEY = 0x00000008;
+
+ private $rit_flags;
+
+ /**
+ * @param it iterator to use as inner iterator
+ * @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, $rit_flags = self::BYPASS_KEY, $cit_flags = CachingIterator::CATCH_GET_CHILD, $mode = self::SELF_FIRST)
+ {
+ parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $mode, $rit_flags);
+ $this->rit_flags = $rit_flags;
+ }
+
+ /** Prefix strings used in getPrefix()
+ *
+ * 0: prefix used to start elements
+ * 1: prefix used if $level < depth and hasNext($level) == true
+ * 2: prefix used if $level < depth and hasNext($level) == false
+ * 3: prefix used if $level == depth and hasNext($level) == true
+ * 4: prefix used if $level == depth and hasNext($level) == false
+ * 5: prefix used right in front of the current element
+ */
+ public $prefix = array(0=>'', 1=>'| ', 2=>' ', 3=>'|-', 4=>'\-', 5=>'');
+
+ /** @return string to place in front of current element
+ */
+ function getPrefix()
+ {
+ $tree = '';
+ for ($level = 0; $level < $this->getDepth(); $level++)
+ {
+ $tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[1] : $this->prefix[2];
+ }
+ $tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[3] : $this->prefix[4];
+
+ return $this->prefix[0] . $tree . $this->prefix[5];
+ }
+
+ /** @return string presentation build for current element
+ */
+ function getEntry()
+ {
+ return @(string)parent::current();
+ }
+
+ /** @return string to place after the current element
+ */
+ function getPostfix()
+ {
+ return '';
+ }
+
+ /** @return the current element prefixed and postfixed
+ */
+ 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()
+ {
+ if ($this->rit_flags & self::BYPASS_KEY)
+ {
+ return parent::key();
+ }
+ else
+ {
+ return $this->getPrefix() . parent::key() . $this->getPostfix();
+ }
+ }
+
+ /** Aggregates the inner iterator
+ */
+ function __call($func, $params)
+ {
+ return call_user_func_array(array($this->getSubIterator(), $func), $params);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/regexfindfile.inc
===================================================================
--- trunk/doc/spl/examples/regexfindfile.inc (rev 0)
+++ trunk/doc/spl/examples/regexfindfile.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,40 @@
+<?php
+
+/** @file regexfindfile.inc
+ * @ingroup Examples
+ * @brief class RegexFindFile
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief Find files by regular expression
+ * @author Marcus Boerger
+ * @version 1.1
+ *
+ */
+class RegexFindFile extends FindFile
+{
+ /** Construct from path and regular expression
+ *
+ * @param $path the directory to search in
+ * If path contains ';' then this parameter is split and every
+ * part of it is used as separate directory.
+ * @param $regex perl style regular expression to find files with
+ */
+ function __construct($path, $regex)
+ {
+ parent::__construct($path, $regex);
+ }
+
+ /** @return whether the current filename matches the regular expression.
+ */
+ function accept()
+ {
+ return preg_match($this->getSearch(), $this->current());
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/searchiterator.inc
===================================================================
--- trunk/doc/spl/examples/searchiterator.inc (rev 0)
+++ trunk/doc/spl/examples/searchiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,58 @@
+<?php
+
+/** @file searchiterator.inc
+ * @ingroup Examples
+ * @brief abstract class SearchIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup Examples
+ * @brief Iterator to search for a specific element
+ * @author Marcus Boerger
+ * @version 1.0
+ *
+ * This extended FilterIterator stops after finding the first acceptable
+ * value.
+ */
+abstract class SearchIterator extends FilterIterator
+{
+ /** @internal whether an entry was found already */
+ private $done = false;
+
+ /** Rewind and reset so that it once again searches.
+ * @return void
+ */
+ function rewind()
+ {
+ parent::rewind();
+ $this->done = false;
+ }
+
+ /** @return whether the current element is valid
+ * which can only happen once per iteration.
+ */
+ function valid()
+ {
+ return !$this->done && parent::valid();
+ }
+
+ /** Do not move forward but instead mark as finished.
+ * @return void
+ */
+ function next()
+ {
+ $this->done = true;
+ }
+
+ /** Aggregates the inner iterator
+ */
+ function __call($func, $params)
+ {
+ return call_user_func_array(array($this->getInnerIterator(), $func), $params);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/tests/examples.inc
===================================================================
--- trunk/doc/spl/examples/tests/examples.inc (rev 0)
+++ trunk/doc/spl/examples/tests/examples.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,23 @@
+<?php
+
+class IncludeFiles extends ArrayIterator
+{
+ function __construct($path, $classes)
+ {
+ parent::__construct();
+ foreach($classes as $c)
+ {
+ $this->append($path . '/' . strtolower($c) . '.inc');
+ }
+ }
+}
+
+$classes = array(
+);
+
+foreach (new IncludeFiles(dirname(__FILE__). '/..', $classes) as $file)
+{
+ require_once($file);
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/examples/tree.php
===================================================================
--- trunk/doc/spl/examples/tree.php (rev 0)
+++ trunk/doc/spl/examples/tree.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,40 @@
+<?php
+
+/** @file tree.php
+ * @brief Program Tree view example
+ * @ingroup Examples
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * Usage: php tree.php \<path\>
+ *
+ * Simply specify the path to tree with parameter \<path\>.
+ */
+
+// The following line only operates on classes which are converted to c already.
+// But does not generate a graphical output.
+//foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {
+
+if ($argc < 2) {
+ echo <<<EOF
+Usage: php ${_SERVER['PHP_SELF']} <path>
+
+Displays a graphical tree for the given <path>.
+
+<path> The directory for which to generate the tree graph.
+
+
+EOF;
+ exit(1);
+}
+
+if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
+if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
+
+echo $argv[1]."\n";
+foreach(new DirectoryGraphIterator($argv[1]) as $file)
+{
+ echo $file . "\n";
+}
+
+?>
\ No newline at end of file

Property changes on: trunk/doc/spl/examples/tree.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/doc/spl/internal/appenditerator.inc
===================================================================
--- trunk/doc/spl/internal/appenditerator.inc (rev 0)
+++ trunk/doc/spl/internal/appenditerator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,122 @@
+<?php
+
+/** @file appenditerator.inc
+ * @ingroup SPL
+ * @brief class AppendIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief Iterator that iterates over several iterators one after the other
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.1
+ */
+class AppendIterator implements OuterIterator
+{
+ /** @internal array of inner iterators */
+ private $iterators;
+
+ /** Construct an empty AppendIterator
+ */
+ function __construct()
+ {
+ $this->iterators = new ArrayIterator();
+ }
+
+ /** Append an Iterator
+ * @param $it Iterator to append
+ *
+ * If the current state is invalid but the appended iterator is valid
+ * the the AppendIterator itself becomes valid. However there will be no
+ * call to $it->rewind(). Also if the current state is invalid the inner
+ * ArrayIterator will be rewound und forwarded to the appended element.
+ */
+ function append(Iterator $it)
+ {
+ $this->iterators->append($it);
+ }
+
+ /** @return the current inner Iterator
+ */
+ function getInnerIterator()
+ {
+ return $this->iterators->current();
+ }
+
+ /** Rewind to the first element of the first inner Iterator.
+ * @return void
+ */
+ function rewind()
+ {
+ $this->iterators->rewind();
+ if ($this->iterators->valid())
+ {
+ $this->getInnerIterator()->rewind();
+ }
+ }
+
+ /** @return whether the current element is valid
+ */
+ function valid()
+ {
+ return $this->iterators->valid() && $this->getInnerIterator()->valid();
+ }
+
+ /** @return the current value if it is valid or \c NULL
+ */
+ function current()
+ {
+ /* Using $this->valid() would be exactly the same; it would omit
+ * the access to a non valid element in the inner iterator. Since
+ * the user didn't respect the valid() return value false this
+ * must be intended hence we go on. */
+ return $this->iterators->valid() ? $this->getInnerIterator()->current() : NULL;
+ }
+
+ /** @return the current key if it is valid or \c NULL
+ */
+ function key()
+ {
+ return $this->iterators->valid() ? $this->getInnerIterator()->key() : NULL;
+ }
+
+ /** Move to the next element. If this means to another Iterator that
+ * rewind that Iterator.
+ * @return void
+ */
+ function next()
+ {
+ if (!$this->iterators->valid())
+ {
+ return; /* done all */
+ }
+ $this->getInnerIterator()->next();
+ if ($this->getInnerIterator()->valid())
+ {
+ return; /* found valid element in current inner iterator */
+ }
+ $this->iterators->next();
+ while ($this->iterators->valid())
+ {
+ $this->getInnerIterator()->rewind();
+ if ($this->getInnerIterator()->valid())
+ {
+ return; /* found element as first elemet in another iterator */
+ }
+ $this->iterators->next();
+ }
+ }
+
+ /** Aggregates the inner iterator
+ */
+ function __call($func, $params)
+ {
+ return call_user_func_array(array($this->getInnerIterator(), $func), $params);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/cachingiterator.inc
===================================================================
--- trunk/doc/spl/internal/cachingiterator.inc (rev 0)
+++ trunk/doc/spl/internal/cachingiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,157 @@
+<?php
+
+/** @file cachingiterator.inc
+ * @ingroup SPL
+ * @brief class CachingIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Cached iteration over another Iterator
+ * @author Marcus Boerger
+ * @version 1.2
+ * @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 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
+{
+ const CALL_TOSTRING = 0x00000001;
+ const CATCH_GET_CHILD = 0x00000002;
+ const TOSTRING_USE_KEY = 0x00000010;
+ const TOSTRING_USE_CURRENT = 0x00000020;
+
+ private $it;
+ private $current;
+ private $key;
+ private $valid;
+ private $strValue;
+
+ /** Construct from another iterator
+ *
+ * @param it Iterator to cache
+ * @param flags Bitmask:
+ * - CALL_TOSTRING (whether to call __toString() for every element)
+ */
+ function __construct(Iterator $it, $flags = self::CALL_TOSTRING)
+ {
+ 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();
+ }
+
+ /** 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 & 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();
+ }
+
+ /** @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 CALL_TOSTRING was not specified in constructor
+ */
+ function __toString()
+ {
+ 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;
+ }
+
+ /**
+ * @return The inner iterator
+ */
+ function getInnerIterator()
+ {
+ return $this->it;
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/emptyiterator.inc
===================================================================
--- trunk/doc/spl/internal/emptyiterator.inc (rev 0)
+++ trunk/doc/spl/internal/emptyiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,62 @@
+<?php
+
+/** @file emptyiterator.inc
+ * @ingroup SPL
+ * @brief class EmptyIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief An empty Iterator
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.1
+ */
+class EmptyIterator implements Iterator
+{
+ /** No operation.
+ * @return void
+ */
+ function rewind()
+ {
+ // nothing to do
+ }
+
+ /** @return \c false
+ */
+ function valid()
+ {
+ return false;
+ }
+
+ /** This function must not be called. It throws an exception upon access.
+ * @throw Exception
+ * @return void
+ */
+ function current()
+ {
+ throw new Exception('Accessing the value of an EmptyIterator');
+ }
+
+ /** This function must not be called. It throws an exception upon access.
+ * @throw Exception
+ * @return void
+ */
+ function key()
+ {
+ throw new Exception('Accessing the key of an EmptyIterator');
+ }
+
+ /** No operation.
+ * @return void
+ */
+ function next()
+ {
+ // nothing to do
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/filteriterator.inc
===================================================================
--- trunk/doc/spl/internal/filteriterator.inc (rev 0)
+++ trunk/doc/spl/internal/filteriterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,129 @@
+<?php
+
+/** @file filteriterator.inc
+ * @ingroup SPL
+ * @brief class FilterIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Regular expression filter for string iterators
+ * @author Marcus Boerger
+ * @version 1.1
+ * @since PHP 5.0
+ *
+ * Instances of this class act as a filter around iterators. In other words
+ * you can put an iterator into the constructor and the instance will only
+ * return selected (accepted) elements.
+ *
+ * The only thing that needs to be done to make this work is implementing
+ * method accept(). Typically this invloves reading the current element or
+ * key of the inner Iterator and checking whether it is acceptable.
+ */
+abstract class FilterIterator implements OuterIterator
+{
+ private $it;
+
+ /**
+ * Constructs a filter around an iterator whose elemnts are strings.
+ * If the given iterator is of type spl_sequence then its rewind()
+ * method is called.
+ *
+ * @param it Object that implements at least spl_forward
+ */
+ function __construct(Iterator $it) {
+ $this->it = $it;
+ }
+
+ /**
+ * Rewind the inner iterator.
+ */
+ function rewind() {
+ $this->it->rewind();
+ $this->fetch();
+ }
+
+ /**
+ * Accept function to decide whether an element of the inner iterator
+ * should be accessible through the Filteriterator.
+ *
+ * @return whether or not to expose the current element of the inner
+ * iterator.
+ */
+ abstract function accept();
+
+ /**
+ * Fetch next element and store it.
+ *
+ * @return void
+ */
+ protected function fetch() {
+ while ($this->it->valid()) {
+ if ($this->accept()) {
+ return;
+ }
+ $this->it->next();
+ };
+ }
+
+ /**
+ * Move to next element
+ *
+ * @return void
+ */
+ function next() {
+ $this->it->next();
+ $this->fetch();
+ }
+
+ /**
+ * @return Whether more elements are available
+ */
+ function valid() {
+ return $this->it->valid();
+ }
+
+ /**
+ * @return The current key
+ */
+ function key() {
+ return $this->it->key();
+ }
+
+ /**
+ * @return The current value
+ */
+ function current() {
+ return $this->it->current();
+ }
+
+ /**
+ * hidden __clone
+ */
+ protected function __clone() {
+ // disallow clone
+ }
+
+ /**
+ * @return The inner iterator
+ */
+ function getInnerIterator()
+ {
+ return $this->it;
+ }
+
+ /** 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);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/infiniteiterator.inc
===================================================================
--- trunk/doc/spl/internal/infiniteiterator.inc (rev 0)
+++ trunk/doc/spl/internal/infiniteiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,48 @@
+<?php
+
+/** @file infiniteiterator.inc
+ * @ingroup SPL
+ * @brief class InfiniteIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief An infinite Iterator
+ * @author Marcus Boerger
+ * @version 1.1
+ * @since PHP 5.1
+ *
+ * This Iterator takes another Iterator and infinitvely iterates it by
+ * rewinding it when its end is reached.
+ *
+ * \note Even an InfiniteIterator stops if its inner Iterator is empty.
+ *
+ \verbatim
+ $it = new ArrayIterator(array(1,2,3));
+ $infinite = new InfiniteIterator($it);
+ $limit = new LimitIterator($infinite, 0, 5);
+ foreach($limit as $val=>$key)
+ {
+ echo "$val=>$key\n";
+ }
+ \endverbatim
+ */
+class InfiniteIterator extends IteratorIterator
+{
+ /** Move the inner Iterator forward to its next element or rewind it.
+ * @return void
+ */
+ function next()
+ {
+ $this->getInnerIterator()->next();
+ if (!$this->getInnerIterator()->valid())
+ {
+ $this->getInnerIterator()->rewind();
+ }
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/iteratoriterator.inc
===================================================================
--- trunk/doc/spl/internal/iteratoriterator.inc (rev 0)
+++ trunk/doc/spl/internal/iteratoriterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,121 @@
+<?php
+
+/** @file iteratoriterator.inc
+ * @ingroup SPL
+ * @brief class IteratorIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief Basic Iterator wrapper
+ * @since PHP 5.1
+ *
+ * This iterator wrapper allows to convert anything that is traversable into
+ * an Iterator. It is very important to understand that most classes that do
+ * not implement Iterator have their reasone to. Most likely they do not allow
+ * the full Iterator feature set. If so you need to provide techniques to
+ * prevent missuse. If you do not you must expect exceptions or fatal erros.
+ *
+ * It is also possible to derive the class and implement IteratorAggregate by
+ * downcasting the instances returned in getIterator. See the following
+ * example (assuming BaseClass implements Traversable):
+ \code
+ class SomeClass extends BaseClass implements IteratorAggregate
+ {
+ function getIterator()
+ {
+ return new IteratorIterator($this, 'BaseClass');
+ }
+ }
+ \endcode
+ *
+ * As you can see in the example this approach requires that the class to
+ * downcast to is actually a base class of the specified iterator to wrap.
+ * Omitting the downcast in the above example would result in an endless loop
+ * since IteratorIterator::__construct() would call SomeClass::getIterator().
+ */
+class IteratorIterator implements OuterIterator
+{
+ /** Construct an IteratorIterator from an Iterator or an IteratorAggregate.
+ *
+ * @param iterator inner iterator
+ * @param classname optional class the iterator has to be downcasted to
+ */
+ function __construct(Traversable $iterator, $classname = null)
+ {
+ if ($iterator instanceof IteratorAggregate)
+ {
+ $iterator = $iterator->getIterator();
+ }
+ if ($iterator instanceof Iterator)
+ {
+ $this->iterator = $iterator;
+ }
+ else
+ {
+ throw new Exception("Classes that only implement Traversable can be wrapped only after converting class IteratorIterator into c code");
+ }
+ }
+
+ /** \return the inner iterator as passed to the constructor
+ */
+ function getInnerIterator()
+ {
+ return $this->iterator;
+ }
+
+ /** \return whether the iterator is valid
+ */
+ function valid()
+ {
+ return $this->iterator->valid();
+ }
+
+ /** \return current key
+ */
+ function key()
+ {
+ return $this->iterator->key();
+ }
+
+ /** \return current value
+ */
+ function current()
+ {
+ return $this->iterator->current();
+ }
+
+ /** forward to next element
+ */
+ function next()
+ {
+ return $this->iterator->next();
+ }
+
+ /** rewind to the first element
+ */
+ function rewind()
+ {
+ return $this->iterator->rewind();
+ }
+
+ /** 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);
+ }
+
+ /** The inner iterator must be private because when this class will be
+ * converted to c code it won't no longer be available.
+ */
+ private $iterator;
+}
+
+?>

Added: trunk/doc/spl/internal/limititerator.inc
===================================================================
--- trunk/doc/spl/internal/limititerator.inc (rev 0)
+++ trunk/doc/spl/internal/limititerator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,134 @@
+<?php
+
+/** @file limititerator.inc
+ * @ingroup SPL
+ * @brief class LimitIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Limited Iteration over another Iterator
+ * @author Marcus Boerger
+ * @version 1.1
+ * @since PHP 5.0
+ *
+ * A class that starts iteration at a certain offset and only iterates over
+ * a specified amount of elements.
+ *
+ * This class uses SeekableIterator::seek() if available and rewind() plus
+ * a skip loop otehrwise.
+ */
+class LimitIterator implements OuterIterator
+{
+ private $it;
+ private $offset;
+ private $count;
+ private $pos;
+
+ /** Construct
+ *
+ * @param it Iterator to limit
+ * @param offset Offset to first element
+ * @param count Maximum number of elements to show or -1 for all
+ */
+ function __construct(Iterator $it, $offset = 0, $count = -1)
+ {
+ if ($offset < 0) {
+ throw new exception('Parameter offset must be > 0');
+ }
+ if ($count < 0 && $count != -1) {
+ throw new exception('Parameter count must either be -1 or a value greater than or equal to 0');
+ }
+ $this->it = $it;
+ $this->offset = $offset;
+ $this->count = $count;
+ $this->pos = 0;
+ }
+
+ /** Seek to specified position
+ * @param position offset to seek to (relative to beginning not offset
+ * specified in constructor).
+ * @throw exception when position is invalid
+ */
+ function seek($position) {
+ if ($position < $this->offset) {
+ throw new exception('Cannot seek to '.$position.' which is below offset '.$this->offset);
+ }
+ if ($position > $this->offset + $this->count && $this->count != -1) {
+ throw new exception('Cannot seek to '.$position.' which is behind offset '.$this->offset.' plus count '.$this->count);
+ }
+ if ($this->it instanceof SeekableIterator) {
+ $this->it->seek($position);
+ $this->pos = $position;
+ } else {
+ while($this->pos < $position && $this->it->valid()) {
+ $this->next();
+ }
+ }
+ }
+
+ /** Rewind to offset specified in constructor
+ */
+ function rewind()
+ {
+ $this->it->rewind();
+ $this->pos = 0;
+ $this->seek($this->offset);
+ }
+
+ /** @return whether iterator is valid
+ */
+ function valid() {
+ return ($this->count == -1 || $this->pos < $this->offset + $this->count)
+ && $this->it->valid();
+ }
+
+ /** @return current key
+ */
+ function key() {
+ return $this->it->key();
+ }
+
+ /** @return current element
+ */
+ function current() {
+ return $this->it->current();
+ }
+
+ /** Forward to nect element
+ */
+ function next() {
+ $this->it->next();
+ $this->pos++;
+ }
+
+ /** @return current position relative to zero (not to offset specified in
+ * constructor).
+ */
+ function getPosition() {
+ return $this->pos;
+ }
+
+ /**
+ * @return The inner iterator
+ */
+ function getInnerIterator()
+ {
+ return $this->it;
+ }
+
+ /** 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);
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/norewinditerator.inc
===================================================================
--- trunk/doc/spl/internal/norewinditerator.inc (rev 0)
+++ trunk/doc/spl/internal/norewinditerator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,28 @@
+<?php
+
+/** @file norewinditerator.inc
+ * @ingroup SPL
+ * @brief class NoRewindIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief An Iterator wrapper that doesn't call rewind
+ * @author Marcus Boerger
+ * @version 1.1
+ * @since PHP 5.1
+ */
+class NoRewindIterator extends IteratorIterator
+{
+ /** Simply prevent execution of inner iterators rewind().
+ */
+ function rewind()
+ {
+ // nothing to do
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/outeriterator.inc
===================================================================
--- trunk/doc/spl/internal/outeriterator.inc (rev 0)
+++ trunk/doc/spl/internal/outeriterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,25 @@
+<?php
+
+/** @file outeriterator.inc
+ * @ingroup SPL
+ * @brief class OuterIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Interface to access the current inner iteraor of iterator wrappers
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.1
+ */
+interface OuterIterator extends Iterator
+{
+ /** @return inner iterator
+ */
+ function getInnerIterator();
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/parentiterator.inc
===================================================================
--- trunk/doc/spl/internal/parentiterator.inc (rev 0)
+++ trunk/doc/spl/internal/parentiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,46 @@
+<?php
+
+/** @file parentiterator.inc
+ * @ingroup SPL
+ * @brief class FilterIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Iterator to filter parents
+ * @author Marcus Boerger
+ * @version 1.2
+ * @since PHP 5.1
+ *
+ * This extended FilterIterator allows a recursive iteration using
+ * RecursiveIteratorIterator that only shows those elements which have
+ * children.
+ */
+class ParentIterator extends RecursiveFilterIterator
+{
+ /** @param $it the RecursiveIterator to filter
+ */
+ function __construct(RecursiveIterator $it)
+ {
+ parent::__construct($it);
+ }
+
+ /** @return whetehr the current element has children
+ */
+ function accept()
+ {
+ return $this->it->hasChildren();
+ }
+
+ /** @return the ParentIterator for the current elements children
+ */
+ function getChildren()
+ {
+ return new ParentIterator($this->it->getChildren());
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/recursivearrayiterator.inc
===================================================================
--- trunk/doc/spl/internal/recursivearrayiterator.inc (rev 0)
+++ trunk/doc/spl/internal/recursivearrayiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,59 @@
+<?php
+
+/** @file recursivearrayiterator.inc
+ * @ingroup Examples
+ * @brief class RecursiveArrayIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief A recursive array iterator
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.1
+ *
+ * Passes the RecursiveIterator interface to the inner Iterator and provides
+ * the same functionality as FilterIterator. This allows you to skip parents
+ * and all their childs before loading them all. You need to care about
+ * function getChildren() because it may not always suit your needs. The
+ * builtin behavior uses reflection to return a new instance of the exact same
+ * class it is called from. That is you extend RecursiveFilterIterator and
+ * getChildren() will create instance of that class. The problem is that doing
+ * this does not transport any state or control information of your accept()
+ * implementation to the new instance. To overcome this problem you might
+ * need to overwrite getChildren(), call this implementation and pass the
+ * control vaules manually.
+ */
+class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
+{
+ /** @return whether the current element has children
+ */
+ function hasChildren()
+ {
+ return is_array($this->current());
+ }
+
+ /** @return an iterator for the current elements children
+ *
+ * @note the returned iterator will be of the same class as $this
+ */
+ function getChildren()
+ {
+ if ($this->current() instanceof self)
+ {
+ return $this->current();
+ }
+ if (empty($this->ref))
+ {
+ $this->ref = new ReflectionClass($this);
+ }
+ return $this->ref->newInstance($this->current());
+ }
+
+ private $ref;
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/recursivecachingiterator.inc
===================================================================
--- trunk/doc/spl/internal/recursivecachingiterator.inc (rev 0)
+++ trunk/doc/spl/internal/recursivecachingiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,99 @@
+<?php
+
+/** @file recursivecachingiterator.inc
+ * @ingroup SPL
+ * @brief class RecursiveCachingIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Cached recursive iteration over another Iterator
+ * @author Marcus Boerger
+ * @version 1.2
+ * @since PHP 5.1
+ *
+ * @see CachingIterator
+ */
+class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
+{
+ private $hasChildren;
+ private $getChildren;
+
+ /** Construct from another iterator
+ *
+ * @param it Iterator to cache
+ * @param flags Bitmask:
+ * - CALL_TOSTRING (whether to call __toString() for every element)
+ * - CATCH_GET_CHILD (whether to catch exceptions when trying to get childs)
+ */
+ function __construct(RecursiveIterator $it, $flags = self::CALL_TOSTRING)
+ {
+ parent::__construct($it, $flags);
+ }
+
+ /** Rewind Iterator
+ */
+ function rewind();
+ {
+ $this->hasChildren = false;
+ $this->getChildren = NULL;
+ parent::rewind();
+ }
+
+ /** Forward to next element if necessary then an Iterator for the Children
+ * will be created.
+ */
+ function next()
+ {
+ if ($this->hasChildren = $this->it->hasChildren())
+ {
+ try
+ {
+ $child = $this->it->getChildren();
+ if (!$this->ref)
+ {
+ $this->ref = new ReflectionClass($this);
+ }
+ $this->getChildren = $ref->newInstance($child, $this->flags);
+ }
+ catch(Exception $e)
+ {
+ if (!$this->flags & self::CATCH_GET_CHILD)
+ {
+ throw $e;
+ }
+ $this->hasChildren = false;
+ $this->getChildren = NULL;
+ }
+ } else
+ {
+ $this->getChildren = NULL;
+ }
+ parent::next();
+ }
+
+ private $ref;
+
+ /** @return whether the current element has children
+ * @note The check whether the Iterator for the children can be created was
+ * already executed. Hence when flag CATCH_GET_CHILD was given in
+ * constructor this fucntion returns false so that getChildren does
+ * not try to access those children.
+ */
+ function hasChildren()
+ {
+ return $this->hasChildren;
+ }
+
+ /** @return An Iterator for the children
+ */
+ function getChildren()
+ {
+ return $this->getChildren;
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/recursivefilteriterator.inc
===================================================================
--- trunk/doc/spl/internal/recursivefilteriterator.inc (rev 0)
+++ trunk/doc/spl/internal/recursivefilteriterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,62 @@
+<?php
+
+/** @file recursivefilteriterator.inc
+ * @ingroup SPL
+ * @brief class RecursiveFilterIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief Iterator to filter recursive iterators
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.1
+ *
+ * Passes the RecursiveIterator interface to the inner Iterator and provides
+ * the same functionality as FilterIterator. This allows you to skip parents
+ * and all their childs before loading them all. You need to care about
+ * function getChildren() because it may not always suit your needs. The
+ * builtin behavior uses reflection to return a new instance of the exact same
+ * class it is called from. That is you extend RecursiveFilterIterator and
+ * getChildren() will create instance of that class. The problem is that doing
+ * this does not transport any state or control information of your accept()
+ * implementation to the new instance. To overcome this problem you might
+ * need to overwrite getChildren(), call this implementation and pass the
+ * control vaules manually.
+ */
+abstract class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator
+{
+ /** @param $it the RecursiveIterator to filter
+ */
+ function __construct(RecursiveIterator $it)
+ {
+ parent::__construct($it);
+ }
+
+ /** @return whether the current element has children
+ */
+ function hasChildren()
+ {
+ return $this->getInnerIterator()->hasChildren();
+ }
+
+ /** @return an iterator for the current elements children
+ *
+ * @note the returned iterator will be of the same class as $this
+ */
+ function getChildren()
+ {
+ if (empty($this->ref))
+ {
+ $this->ref = new ReflectionClass($this);
+ }
+ return $this->ref->newInstance($this->getInnerIterator()->getChildren());
+ }
+
+ private $ref;
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/recursiveiterator.inc
===================================================================
--- trunk/doc/spl/internal/recursiveiterator.inc (rev 0)
+++ trunk/doc/spl/internal/recursiveiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,30 @@
+<?php
+
+/** @file recursiveiterator.inc
+ * @ingroup SPL
+ * @brief class RecursiveIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Interface for recursive iteration with RecursiveIteratorIterator
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.0
+ */
+interface RecursiveIterator implements Iterator
+{
+ /** @return whether the current element has children
+ */
+ function hasChildren();
+
+ /** @return the sub iterator for the current element
+ * @note The returned object must implement RecursiveIterator.
+ */
+ function getChildren();
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/recursiveiteratoriterator.inc
===================================================================
--- trunk/doc/spl/internal/recursiveiteratoriterator.inc (rev 0)
+++ trunk/doc/spl/internal/recursiveiteratoriterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,235 @@
+<?php
+
+/** @file recursiveiteratoriterator.inc
+ * @ingroup SPL
+ * @brief class RecursiveIteratorIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Iterates through recursive iterators
+ * @author Marcus Boerger
+ * @version 1.2
+ * @since PHP 5.0
+ *
+ * The objects of this class are created by instances of RecursiveIterator.
+ * Elements of those iterators may be traversable themselves. If so these
+ * sub elements are recursed into.
+ */
+class RecursiveIteratorIterator implements OuterIterator
+{
+ /** Mode: Only show leaves */
+ const LEAVES_ONLY = 0;
+ /** Mode: Show parents prior to their children */
+ const SELF_FIRST = 1;
+ /** Mode: Show all children prior to their parent */
+ const CHILD_FIRST = 2;
+
+ /** Flag: Catches exceptions during getChildren() calls and simply jumps
+ * to the next element. */
+ const CATCH_GET_CHILD = 0x00000002;
+
+ private $ait = array();
+ private $count = 0;
+ private $mode = self::LEAVES_ONLY;
+ private $flags = 0;
+
+ /** Construct from RecursiveIterator
+ *
+ * @param it RecursiveIterator to iterate
+ * @param mode Operation mode (one of):
+ * - LEAVES_ONLY only show leaves
+ * - SELF_FIRST show parents prior to their childs
+ * - CHILD_FIRST show all children prior to their parent
+ * @param flags Control flags, zero or any combination of the following
+ * (since PHP 5.1).
+ * - CATCH_GET_CHILD which catches exceptions during
+ * getChildren() calls and simply jumps to the next
+ * element.
+ */
+ function __construct(RecursiveIterator $it, $mode = self::LEAVES_ONLY, $flags = 0)
+ {
+ $this->ait[0] = $it;
+ $this->mode = $mode;
+ $this->flags = $flags;
+ }
+
+ /** Rewind to top iterator as set in constructor
+ */
+ function rewind()
+ {
+ while ($this->count) {
+ unset($this->ait[$this->count--]);
+ $this->endChildren();
+ }
+ $this->ait[0]->rewind();
+ $this->ait[0]->recursed = false;
+ callNextElement(true);
+ }
+
+ /** @return whether iterator is valid
+ */
+ function valid()
+ {
+ $count = $this->count;
+ while ($count) {
+ $it = $this->ait[$count];
+ if ($it->valid()) {
+ return true;
+ }
+ $count--;
+ $this->endChildren();
+ }
+ return false;
+ }
+
+ /** @return current key
+ */
+ function key()
+ {
+ $it = $this->ait[$this->count];
+ return $it->key();
+ }
+
+ /** @return current element
+ */
+ function current()
+ {
+ $it = $this->ait[$this->count];
+ return $it->current();
+ }
+
+ /** Forward to next element
+ */
+ function next()
+ {
+ while ($this->count) {
+ $it = $this->ait[$this->count];
+ if ($it->valid()) {
+ if (!$it->recursed && callHasChildren()) {
+ $it->recursed = true;
+ try
+ {
+ $sub = callGetChildren();
+ }
+ catch (Exception $e)
+ {
+ if (!($this->flags & self::CATCH_GET_CHILD))
+ {
+ throw $e;
+ }
+ $it->next();
+ continue;
+ }
+ $sub->recursed = false;
+ $sub->rewind();
+ if ($sub->valid()) {
+ $this->ait[++$this->count] = $sub;
+ if (!$sub instanceof RecursiveIterator) {
+ throw new Exception(get_class($sub).'::getChildren() must return an object that implements RecursiveIterator');
+ }
+ $this->beginChildren();
+ return;
+ }
+ unset($sub);
+ }
+ $it->next();
+ $it->recursed = false;
+ if ($it->valid()) {
+ return;
+ }
+ $it->recursed = false;
+ }
+ if ($this->count) {
+ unset($this->ait[$this->count--]);
+ $it = $this->ait[$this->count];
+ $this->endChildren();
+ callNextElement(false);
+ }
+ }
+ callNextElement(true);
+ }
+
+ /** @return Sub Iterator at given level or if unspecified the current sub
+ * Iterator
+ */
+ function getSubIterator($level = NULL)
+ {
+ if (is_null($level)) {
+ $level = $this->count;
+ }
+ return @$this->ait[$level];
+ }
+
+ /**
+ * @return The inner iterator
+ */
+ function getInnerIterator()
+ {
+ return $this->it;
+ }
+
+ /** @return Current Depth (Number of parents)
+ */
+ function getDepth()
+ {
+ return $this->level;
+ }
+
+ /** @return whether current sub iterators current element has children
+ * @since PHP 5.1
+ */
+ function callHasChildren()
+ {
+ return $this->ait[$this->count]->hasChildren();
+ }
+
+ /** @return current sub iterators current children
+ * @since PHP 5.1
+ */
+ function callGetChildren()
+ {
+ return $this->ait[$this->count]->getChildren();
+ }
+
+ /** Called right after calling getChildren() and its rewind().
+ * @since PHP 5.1
+ */
+ function beginChildren()
+ {
+ }
+
+ /** Called after current child iterator is invalid and right before it
+ * gets destructed.
+ * @since PHP 5.1
+ */
+ function endChildren()
+ {
+ }
+
+ private function callNextElement($after_move)
+ {
+ if ($this->valid())
+ {
+ if ($after_move)
+ {
+ if (($this->mode == self::SELF_FIRST && $this->callHasChildren())
+ $this->mode == self::LEAVES_ONLY)
+ $this->nextElement();
+ }
+ else
+ {
+ $this->nextElement();
+ }
+ }
+ }
+
+ /** Called when the next element is available
+ */
+ function nextElement();
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/seekableiterator.inc
===================================================================
--- trunk/doc/spl/internal/seekableiterator.inc (rev 0)
+++ trunk/doc/spl/internal/seekableiterator.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,48 @@
+<?php
+
+/** @file seekableiterator.inc
+ * @ingroup SPL
+ * @brief class SeekableIterator
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @brief seekable iterator
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.0
+ *
+ * Turns a normal iterator ino a seekable iterator. When there is a way
+ * to seek on an iterator LimitIterator can use this to efficiently rewind
+ * to offset.
+ */
+interface SeekableIterator implements Iterator
+{
+ /** Seek to an absolute position
+ *
+ * \param $index position to seek to
+ * \return void
+ *
+ * The method should throw an exception if it is not possible to seek to
+ * the given position. Typically this exception should be of type
+ * OutOfBoundsException.
+ \code
+ function seek($index);
+ $this->rewind();
+ $position = 0;
+ while($position < $index && $this->valid()) {
+ $this->next();
+ $position++;
+ }
+ if (!$this->valid()) {
+ throw new OutOfBoundsException('Invalid seek position');
+ }
+ }
+ \endcode
+ */
+ function seek($index);
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/internal/splfileobject.inc
===================================================================
--- trunk/doc/spl/internal/splfileobject.inc (rev 0)
+++ trunk/doc/spl/internal/splfileobject.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,353 @@
+<?php
+
+/** @file splfileobject.inc
+ * @ingroup SPL
+ * @brief class FileObject
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/** @ingroup SPL
+ * @brief Object representation for any stream
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 5.1
+ */
+class SplFileObject implements RecursiveIterator, SeekableIterator
+{
+ /** Flag: wheter to suppress new lines */
+ const DROP_NEW_LINE = 0x00000001;
+
+ private $fp;
+ private $fname;
+ private $line = NULL;
+ private $lnum = 0;
+ private $max_len = 0;
+ private $flags = 0;
+
+ /**
+ * Constructs a new file object
+ *
+ * @param $file_name The name of the stream to open
+ * @param $open_mode The file open mode
+ * @param $use_include_path Whether to search in include paths
+ * @param $context A stream context
+ * @throw RuntimeException If file cannot be opened (e.g. insufficient
+ * access rights).
+ */
+ function __construct($file_name, $open_mode = 'r', $use_include_path = false, $context = NULL)
+ {
+ $this->fp = fopen($file_name, $open_mode, $use_include_path, $context);
+ if (!$this->fp)
+ {
+ throw new RuntimeException("Cannot open file $file_name");
+ }
+ $this->fname = $file_name;
+ }
+
+ /**
+ * @return the filename as specified in the constructor
+ */
+ function getFilename()
+ {
+ return $this->fname;
+ }
+
+ /**
+ * @return whether the end of the stream is reached
+ */
+ function eof()
+ {
+ return eof($this->fp);
+ }
+
+ /** increase current line number
+ * @return next line from stream
+ */
+ function fgets()
+ {
+ $this->freeLine();
+ $this->lnum++;
+ $buf = fgets($this->fp, $this->max_len);
+
+ return $buf;
+ }
+
+ /**
+ * @param delimiter character used as field separator
+ * @param enclosure end of
+ * @return array containing read data
+ */
+ function fgetcsv($delimiter = ';', $enclosure = '')
+ {
+ $this->freeLine();
+ $this->lnum++;
+ return fgetcsv($this->fp, $this->max_len, $delimiter, $enclosure);
+ }
+
+ /**
+ * @param operation lock operation (LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB)
+ * @retval $wouldblock whether the operation would block
+ */
+ function flock($operation, &$wouldblock)
+ {
+ return flock($this->fp, $operation, $wouldblock);
+ }
+
+ /**
+ * Flush current data
+ * @return success or failure
+ */
+ function fflush()
+ {
+ return fflush($this->fp);
+ }
+
+ /**
+ * @return current file position
+ */
+ function ftell()
+ {
+ return ftell($this->fp);
+ }
+
+ /**
+ * @param pos new file position
+ * @param whence seek method (SEEK_SET, SEEK_CUR, SEEK_END)
+ * @return Upon success, returns 0; otherwise, returns -1. Note that
+ * seeking past EOF is not considered an error.
+ */
+ function fseek($pos, $whence = SEEK_SET)
+ {
+ return fseek($this->fp, $pos, $whence);
+ }
+
+ /**
+ * @return next char from file
+ * @note a new line character does not increase $this->lnum
+ */
+ function fgetc()
+ {
+ $this->freeLine();
+ $c = fgetc($this->fp);
+ if ($c == '\n') {
+ $this->lnum++;
+ }
+ }
+
+ /** Read and return remaining part of stream
+ * @return size of remaining part passed through
+ */
+ function fpassthru()
+ {
+ return fpassthru($this->fp);
+ }
+
+ /** Get a line from the file and strip HTML tags
+ * @param $allowable_tags tags to keep in the string
+ */
+ function fgetss($allowable_tags = NULL)
+ {
+ return fgetss($this->fp, $allowable_tags);
+ }
+
+ /** Scan the next line
+ * @param $format string specifying format to parse
+ */
+ function fscanf($format /* , ... */)
+ {
+ $this->freeLine();
+ $this->lnum++;
+ return fscanf($this->fp, $format /* , ... */);
+ }
+
+ /**
+ * @param $str to write
+ * @param $length maximum line length to write
+ */
+ function fwrite($str, $length = NULL)
+ {
+ return fwrite($this->fp, $length);
+ }
+
+ /**
+ * @return array of file stat information
+ */
+ function fstat()
+ {
+ return fstat($this->fp);
+ }
+
+ /**
+ * @param $size new size to truncate file to
+ */
+ function ftruncate($size)
+ {
+ return ftruncate($this->fp, $size);
+ }
+
+ /**
+ * @param $flags new flag set
+ */
+ function setFlags($flags)
+ {
+ $this->flags = $flags;
+ }
+
+ /**
+ * @return current set of flags
+ */
+ function getFlags()
+ {
+ return $this->flags;
+ }
+
+ /**
+ * @param $max_len set the maximum line length read
+ */
+ function setMaxLineLen($max_len)
+ {
+ $this->max_len = $max_len;
+ }
+
+ /**
+ * @return current setting for max line
+ */
+ function getMaxLineLen()
+ {
+ return $this->max_len;
+ }
+
+ /**
+ * @return false
+ */
+ function hasChildren()
+ {
+ return false;
+ }
+
+ /**
+ * @return false
+ */
+ function getChildren()
+ {
+ return NULL;
+ }
+
+ /**
+ * Invalidate current line buffer and set line number to 0.
+ */
+ function rewind()
+ {
+ $this->freeLine();
+ $this->lnum = 0;
+ }
+
+ /**
+ * @return whether more data can be read
+ */
+ function valid()
+ {
+ return !$this->eof();
+ }
+
+ /**
+ * @note Fill current line buffer if not done yet.
+ * @return line buffer
+ */
+ function current()
+ {
+ if (is_null($this->line))
+ {
+ $this->line = getCurrentLine();
+ }
+ return $this->line;
+ }
+
+ /**
+ * @return line number
+ * @note fgetc() will increase the line number when reaing a new line char.
+ * This has the effect key() called on a read a new line will already
+ * return the increased line number.
+ * @note Line counting works as long as you only read the file and do not
+ * use fseek().
+ */
+ function key()
+ {
+ return $this->lnum;
+ }
+
+ /** Invalidate current line buffer.
+ */
+ function next()
+ {
+ $this->freeLine();
+ }
+
+ /**
+ * @return next line read from file and increase the line counter
+ */
+ private function readLine()
+ {
+ if ($this->eof())
+ {
+ $this->freeLine();
+ throw new RuntimeException("Cannot read from file " . $this->fname);
+ }
+ if ($this->line) {
+ $this->lnum++;
+ }
+ $this->freeLine();
+ $this->line = fgets($this->fp, $this->max_len);
+ return $this->line;
+ }
+
+ /**
+ * Free the current line buffer and increment the line counter
+ */
+ private function freeLine()
+ {
+ if ($this->line) {
+ $this->line = NULL;
+ }
+ }
+
+ /*
+ * @note If you DO overload this function key() and current() will increment
+ * $this->lnum automatically. If not then function reaLine() will do
+ * that for you.
+ */
+ function getCurrentLine()
+ {
+ $this->freeLine();
+ if ($this->eof())
+ {
+ throw new RuntimeException("Cannot read from file " . $this->fname);
+ }
+ $this->readLine();
+ }
+
+ /**
+ * @return current line
+ */
+ function __toString()
+ {
+ return current();
+ }
+
+ /**
+ * @param $line_pos Seek to this line
+ */
+ function seek($line_pos)
+ {
+ $this->rewind();
+ while($this->lnum < $line_pos && !$this->eof())
+ {
+ $this->getCurrentLine();
+ }
+ }
+}
+
+?>

Added: trunk/doc/spl/internal/splobjectstorage.inc
===================================================================
--- trunk/doc/spl/internal/splobjectstorage.inc (rev 0)
+++ trunk/doc/spl/internal/splobjectstorage.inc 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,118 @@
+<?php
+
+/** @file splobjectstorage.inc
+ * @ingroup SPL
+ * @brief class SplObjectStorage
+ * @author Marcus Boerger
+ * @date 2003 - 2005
+ *
+ * SPL - Standard PHP Library
+ */
+
+/**
+ * @brief Object storage
+ * @author Marcus Boerger
+ * @version 1.0
+ * @since PHP 6.0
+ *
+ * This container allows to store objects uniquly without the need to compare
+ * them one by one. This is only possible internally. The code represenation
+ * here therefore has a complexity of O(n) while the actual implementation has
+ * complexity O(1).
+ */
+class SplObjectStorage implements Iterator, Countable
+{
+ private $storage = array();
+ private $index = 0;
+
+ /** Rewind to top iterator as set in constructor
+ */
+ function rewind()
+ {
+ rewind($this->storage);
+ }
+
+ /** @return whether iterator is valid
+ */
+ function valid()
+ {
+ return key($this->storage) !== false;
+ }
+
+ /** @return current key
+ */
+ function key()
+ {
+ return $this->index;
+ }
+
+ /** @return current object
+ */
+ function current()
+ {
+ return current($this->storage);
+ }
+
+ /** Forward to next element
+ */
+ function next()
+ {
+ next($this->storage);
+ $this->index++;
+ }
+
+ /** @return number of objects in storage
+ */
+ function count()
+ {
+ return count($this->storage);
+ }
+
+ /** @param obj object to look for
+ * @return whether $obj is contained in storage
+ */
+ function contains($obj)
+ {
+ if (is_object($obj))
+ {
+ foreach($this->storage as $object)
+ {
+ if ($object === $obj)
+ {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /** @param $obj new object to attach to storage if not yet contained
+ */
+ function attach($obj)
+ {
+ if (is_object($obj) && !$this->contains($obj))
+ {
+ $this->storage[] = $obj;
+ }
+ }
+
+ /** @param $obj object to remove from storage
+ */
+ function detach($obj)
+ {
+ if (is_object($obj))
+ {
+ foreach($this->storage as $idx => $object)
+ {
+ if ($object === $obj)
+ {
+ unset($this->storage[$idx]);
+ $this->rewind();
+ return;
+ }
+ }
+ }
+ }
+}
+
+?>
\ No newline at end of file

Added: trunk/doc/spl/spl.php
===================================================================
--- trunk/doc/spl/spl.php (rev 0)
+++ trunk/doc/spl/spl.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -0,0 +1,946 @@
+<?php
+
+/** @file spl.php
+ * @ingroup SPL
+ * @brief Documentation of internal classes and interfaces
+ *
+ * SPL - Standard PHP Library
+ *
+ * (c) Marcus Boerger, 2003 - 2005
+ */
+
+/** @mainpage SPL - Standard PHP Library
+ *
+ * SPL - Standard PHP Library
+ *
+ * SPL is a collection of interfaces and classes that are meant to solve
+ * standard problems and implements some efficient data access interfaces
+ * and classes. You'll find the classes documented using php code in the
+ * file spl.php or in corresponding .inc files in subdirectories examples
+ * and internal. Based on the internal implementations or the files in the
+ * examples subdirectory there are also some .php files to experiment with.
+ *
+ * The .inc files are not included automatically because they are sooner or
+ * later integrated into the extension. That means that you either need to
+ * put the code of examples/autoload.inc into your autoprepend file or that
+ * you have to point your ini setting auto_prepend_file to that file.
+ *
+ * Below is a list of interfaces/classes already availabel natively through
+ * the SPL extension grouped by category.
+ *
+ * 1) Iterators
+ *
+ * SPL offers some advanced iterator algorithms:
+ *
+ * - interface RecursiveIterator implements Iterator
+ * - interface OuterIterator extends Iterator
+ * - class RecursiveIteratorIterator implements OuterIterator
+ * - abstract class FilterIterator implements OuterIterator
+ * - class ParentIterator extends FilterIterator implements RecursiveIterator
+ * - interface SeekableIterator implements Iterator
+ * - class LimitIterator implements OuterIterator
+ * - class CachingIterator implements OuterIterator
+ * - class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
+ * - class IteratorIterator implements OuterIterator
+ * - class NoRewindIterator implements OuterIterator
+ * - class EmptyIterator implements Iterator
+ * - class InfiniteIterator extends IteratorIterator
+ * - class AppendIterator implements OuterIterator
+ *
+ * 2) Directories and Files
+ *
+ * SPL offers two advanced directory and file handling classes:
+ *
+ * - class DirectoryIterator implements Iterator
+ * - class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
+ * - class SplFileObject implements RecursiveIterator, SeekableIterator
+ *
+ * 3) XML
+ *
+ * SPL offers an advanced XML handling class:
+ *
+ * - class SimpleXMLIterator extends simplexml_element implements RecursiveIterator
+ *
+ * 4) Array Overloading
+ *
+ * SPL offers advanced Array overloading:
+ *
+ * - class ArrayObject implements IteratorAggregate
+ * - class ArrayIterator implements Iterator
+ * - class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
+ *
+ * As the above suggest an ArrayObject creates an ArrayIterator when it comes to
+ * iteration (e.g. ArrayObject instance used inside foreach).
+ *
+ * 5) Counting
+ *
+ * - interface Countable allows to hook into the standard array function count().
+ *
+ * 6) Exception%s
+ *
+ * SPL provides a set of standard Exception classes each meant to indicate a
+ * certain problem type.
+ *
+ * - class LogicException extends Exception
+ * - class BadFunctionCallException extends LogicException
+ * - class BadMethodCallException extends BadFunctionCallException
+ * - class DomainException extends LogicException
+ * - class InvalidArgumentException extends LogicException
+ * - class LengthException extends LogicException
+ * - class OutOfRangeException extends LogicException
+ * - class RuntimeException extends Exception
+ * - class OutOfBoundsException extends RuntimeException
+ * - class OverflowException extends RuntimeException
+ * - class RangeException extends RuntimeException
+ * - class UnderflowException extends RuntimeException
+ *
+ * 7) Observer
+ *
+ * SPL suggests a standard way of implementing the observer pattern.
+ *
+ * - interface SplObserver
+ * - interface SplSubject
+ * - class SplObjectStorage
+ *
+ * Some articles about SPL:
+ * - Introducing PHP 5's Standard Library
+ * - Iterators in PHP5
+ * - Advanced OOP with SPL in PHP 5
+ * - The Standard PHP Library, Part 1
+ * - The Standard PHP Library, Part 2
+ * - SPL on PHP Wiki
+ * - Die Standard PHP Library (SPL) [german]
+ *
+ * Talks on SPL:
+ * - SPL for the masses [pps], [pdf]
+ * - From engine overloading to SPL [pps], [pdf]
+ * - Happy SPLing [pps], [pdf]
+ * - Debug session 1 [pps], [pdf]
+ * - Debug session 2 [pps], [pdf]
+ *
+ * You can download this documentation as a chm file
+ * here.
+ *
+ * (c) Marcus Boerger, 2003 - 2005
+ */
+
+/** @defgroup ZendEngine Zend engine classes
+ *
+ * The classes and interfaces in this group are contained in the c-code of
+ * PHP's Zend engine.
+ */
+
+/** @defgroup SPL Internal classes
+ *
+ * The classes and interfaces in this group are contained in the c-code of
+ * ext/SPL.
+ */
+
+/** @defgroup Examples Example classes
+ *
+ * The classes and interfaces in this group are contained as PHP code in the
+ * examples subdirectory of ext/SPL. Sooner or later they will be moved to
+ * c-code.
+ */
+
+/** @ingroup SPL
+ * @brief Default implementation for __autoload()
+ * @since PHP 5.1
+ *
+ * @param class_name name of class to load
+ * @param file_extensions file extensions (use defaults if NULL)
+ */
+function spl_autoload(string $class_name, string $file_extensions = NULL);
+
+/** @ingroup SPL
+ * @brief Manual invocation of all registerd autoload functions
+ * @since PHP 5.1
+ *
+ * @param class_name name of class to load
+ */
+function spl_autoload_call(string $class_name);
+
+/** @ingroup SPL
+ * @brief Register and return default file extensions for spl_autoload
+ * @since PHP 5.1
+ *
+ * @param file_extensions optional comma separated list of extensions to use in
+ * default autoload function. If not given just return the current list.
+ * @return comma separated list of file extensions to use in default autoload
+ * function.
+ */
+function spl_autoload_extensions($file_extensions);
+
+/** @ingroup SPL
+ * @brief Return all registered autoload functionns
+ * @since PHP 5.1
+ *
+ * @return array of all registered autoload functions or false
+ */
+function spl_autoload_functions();
+
+/** @ingroup SPL
+ * @brief Register given function as autoload implementation
+ * @since PHP 5.1
+ *
+ * @param autoload_function name of function or array of object/class and
+ * function name to register as autoload function.
+ * @param throw whether to throw or issue an error on failure.
+ */
+function spl_autoload_register(string $autoload_function = "spl_autoload", $throw = true);
+
+/** @ingroup SPL
+ * @brief Unregister given function as autoload implementation
+ * @since PHP 5.1
+ *
+ * @param autoload_function name of function or array of object/class and
+ * function name to unregister as autoload function.
+ */
+function spl_autoload_unregister(string $autoload_function = "spl_autoload");
+
+/** @ingroup SPL
+ * @brief Return an array of classes and interfaces in SPL
+ *
+ * @return array containing the names of all clsses and interfaces defined in
+ * extension SPL
+ */
+function spl_classes();
+
+/** @ingroup SPL
+ * @brief Count the elements in an iterator
+ * @since PHP 5.1
+ *
+ * @return number of elements in an iterator
+ */
+function iterator_count(Traversable $it);
+
+/** @ingroup SPL
+ * @brief Copy iterator elements into an array
+ * @since PHP 5.1
+ *
+ * @param it iterator to copy
+ * @return array with elements copied from the iterator
+ */
+function iterator_to_array(Traversable $it);
+
+/** @ingroup ZendEngine
+ * @brief Basic Exception class.
+ * @since PHP 5.0
+ */
+class Exception
+{
+ /** The exception message */
+ protected $message;
+
+ /** The string represenations as generated during construction */
+ private $string;
+
+ /** The code passed to the constructor */
+ protected $code;
+
+ /** The file name where the exception was instantiated */
+ protected $file;
+
+ /** The line number where the exception was instantiated */
+ protected $line;
+
+ /** The stack trace */
+ private $trace;
+
+ /** Prevent clone
+ */
+ final private function __clone() {}
+
+ /** Construct an exception
+ *
+ * @param $message Some text describing the exception
+ * @param $code Some code describing the exception
+ */
+ function __construct($message = NULL, $code = 0) {
+ if (func_num_args()) {
+ $this->message = $message;
+ }
+ $this->code = $code;
+ $this->file = __FILE__; // of throw clause
+ $this->line = __LINE__; // of throw clause
+ $this->trace = debug_backtrace();
+ $this->string = StringFormat($this);
+ }
+
+ /** @return the message passed to the constructor
+ */
+ final public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /** @return the code passed to the constructor
+ */
+ final public function getCode()
+ {
+ return $this->code;
+ }
+
+ /** @return the name of the file where the exception was thrown
+ */
+ final public function getFile()
+ {
+ return $this->file;
+ }
+
+ /** @return the line number where the exception was thrown
+ */
+ final public function getLine()
+ {
+ return $this->line;
+ }
+
+ /** @return the stack trace as array
+ */
+ final public function getTrace()
+ {
+ return $this->trace;
+ }
+
+ /** @return the stack trace as string
+ */
+ final public function getTraceAsString()
+ {
+ }
+
+ /** @return string represenation of exception
+ */
+ public function __toString()
+ {
+ return $this->string;
+ }
+}
+
+/** @ingroup SPL
+ * @brief Exception that represents error in the program logic.
+ * @since PHP 5.1
+ *
+ * This kind of exceptions should directly leed to a fix in your code.
+ */
+class LogicException extends Exception
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when a function call was illegal.
+ * @since PHP 5.1
+ */
+class BadFunctionCallException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when a method call was illegal.
+ * @since PHP 5.1
+ */
+class BadMethodCallException extends BadFunctionCallException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception that denotes a value not in the valid domain was used.
+ * @since PHP 5.1
+ *
+ * This kind of exception should be used to inform about domain erors in
+ * mathematical sense.
+ *
+ * @see RangeException
+ */
+class DomainException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception that denotes invalid arguments were passed.
+ * @since PHP 5.1
+ *
+ * @see UnexpectedValueException
+ */
+class InvalidArgumentException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when a parameter exceeds the allowed length.
+ * @since PHP 5.1
+ *
+ * This can be used for strings length, array size, file size, number of
+ * elements read from an Iterator and so on.
+ */
+class LengthException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when an illegal index was requested.
+ * @since PHP 5.1
+ *
+ * This represents errors that should be detected at compile time.
+ *
+ * @see OutOfBoundsException
+ */
+class OutOfRangeException extends LogicException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown for errors that are only detectable at runtime.
+ * @since PHP 5.1
+ */
+class RuntimeException extends Exception
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown when an illegal index was requested.
+ * @since PHP 5.1
+ *
+ * This represents errors that cannot be detected at compile time.
+ *
+ * @see OutOfRangeException
+ */
+class OutOfBoundsException extends RuntimeException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown to indicate arithmetic/buffer overflow.
+ * @since PHP 5.1
+ */
+class OverflowException extends RuntimeException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown to indicate range errors during program execution.
+ * @since PHP 5.1
+ *
+ * Normally this means there was an arithmetic error other than under/overflow.
+ * This is the runtime version of DomainException.
+ *
+ * @see DomainException
+ */
+class RangeException extends RuntimeException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown to indicate arithmetic/buffer underflow.
+ * @since PHP 5.1
+ */
+class UnderflowException extends RuntimeException
+{
+}
+
+/** @ingroup SPL
+ * @brief Exception thrown to indicate an unexpected value.
+ * @since PHP 5.1
+ *
+ * Typically this happens when a function calls another function and espects
+ * the return value to be of a certain type or value not including arithmetic
+ * or buffer related errors.
+ *
+ * @see InvalidArgumentException
+ */
+class UnexpectedValueException extends RuntimeException
+{
+}
+
+/** @ingroup ZendEngine
+ * @brief Interface to override array access of objects.
+ * @since PHP 5.0
+ */
+interface ArrayAccess
+{
+ /** @param $offset to modify
+ * @param $value new value
+ */
+ function offsetSet($offset, $value);
+
+ /** @param $offset to retrieve
+ * @return value at given offset
+ */
+ function offsetGet($offset);
+
+ /** @param $offset to delete
+ */
+ function offsetUnset($offset);
+
+ /** @param $offset to check
+ * @return whether the offset exists.
+ */
+ function offsetExists($offset);
+}
+
+/** @ingroup ZendEngine
+ * @brief Interface to detect a class is traversable using foreach.
+ * @since PHP 5.0
+ *
+ * Abstract base interface that cannot be implemented alone. Instead it
+ * must be implemented by either IteratorAggregate or Iterator.
+ *
+ * @note Internal classes that implement this interface can be used in a
+ * foreach construct and do not need to implement IteratorAggregate or
+ * Iterator.
+ *
+ * @note This is an engine internal interface which cannot be implemented
+ * in PHP scripts. Either IteratorAggregate or Iterator must be used
+ * instead.
+ */
+interface Traversable
+{
+}
+
+/** @ingroup ZendEngine
+ * @brief Interface to create an external Iterator.
+ * @since PHP 5.0
+ *
+ * @note This is an engine internal interface.
+ */
+interface IteratorAggregate extends Traversable
+{
+ /** @return an Iterator for the implementing object.
+ */
+ function getIterator();
+}
+
+/** @ingroup ZendEngine
+ * @brief Basic iterator
+ * @since PHP 5.0
+ *
+ * Interface for external iterators or objects that can be iterated
+ * themselves internally.
+ *
+ * @note This is an engine internal interface.
+ */
+interface Iterator extends Traversable
+{
+ /** Rewind the Iterator to the first element.
+ */
+ function rewind();
+
+ /** Return the current element.
+ */
+ function current();
+
+ /** Return the key of the current element.
+ */
+ function key();
+
+ /** Move forward to next element.
+ */
+ function next();
+
+ /** Check if there is a current element after calls to rewind() or next().
+ */
+ function valid();
+}
+
+/** @ingroup SPL
+ * @brief This Interface allows to hook into the global count() function.
+ * @since PHP 5.1
+ */
+interface Countable
+{
+ /** @return the number the global function count() should show
+ */
+ function count();
+}
+
+/** @ingroup ZendEngine
+ * @brief Interface for customized serializing
+ * @since 5.1
+ *
+ * Classes that implement this interface no longer support __sleep() and
+ * __wakeup(). The method serialized is called whenever an instance needs to
+ * be serialized. This does not invoke __destruct() or has any other side
+ * effect unless programmed inside the method. When the data is unserialized
+ * the class is known and the appropriate unserialize() method is called as a
+ * constructor instead of calling __construct(). If you need to execute the
+ * standard constructor you may do so in the method.
+ */
+interface Serializable
+{
+ /**
+ * @return string representation of the instance
+ */
+ function serialize();
+
+ /**
+ * @note This is a constructor
+ *
+ * @param $serialized data read from stream to construct the instance
+ */
+ function unserialize($serialized);
+}
+
+/** @ingroup SPL
+ * @brief An Array wrapper
+ * @since PHP 5.0
+ * @version 1.1
+ *
+ * This array wrapper allows to recursively iterate over Arrays and public
+ * Object properties.
+ *
+ * @see ArrayIterator
+ */
+class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
+{
+ /** Properties of the object have their normal functionality
+ * when accessed as list (var_dump, foreach, etc.) */
+ const STD_PROP_LIST = 0x00000001;
+ /** Array indices can be accessed as properties in read/write */
+ const ARRAY_AS_PROPS = 0x00000002;
+
+ /** Construct a new array iterator from anything that has a hash table.
+ * That is any Array or Object.
+ *
+ * @param $array the array to use.
+ * @param $flags see setFlags().
+ * @param $iterator_class class used in getIterator()
+ */
+ function __construct($array, $flags = 0, $iterator_class = "ArrayIterator");
+
+ /** Set behavior flags.
+ *
+ * @param $flags bitmask as follows:
+ * 0 set: properties of the object have their normal functionality
+ * when accessed as list (var_dump, foreach, etc.)
+ * 1 set: array indices can be accessed as properties in read/write
+ */
+ function setFlags($flags);
+
+ /**
+ * @ return current flags
+ */
+ function getFlags();
+
+ /**
+ * @param $array new array or object
+ */
+ function exchangeArray($array);
+
+ /** @return the iterator which is an ArrayIterator object connected to
+ * this object.
+ */
+ function getIterator();
+
+ /** @param $index offset to inspect
+ * @return whetehr offset $index esists
+ */
+ function offsetExists($index);
+
+ /** @param $index offset to return value for
+ * @return value at offset $index
+ */
+ function offsetGet($index);
+
+ /** @param $index index to set
+ * @param $newval new value to store at offset $index
+ */
+ function offsetSet($index, $newval);
+
+ /** @param $index offset to unset
+ */
+ function offsetUnset($index);
+
+ /** @param $value is appended as last element
+ * @warning this method cannot be called when the ArrayObject refers to
+ * an object.
+ */
+ function append($value);
+
+ /** @return a \b copy of the array
+ * @note when the ArrayObject refers to an object then this method
+ * returns an array of the public properties.
+ */
+ function getArrayCopy();
+
+ /** @return the number of elements in the array or the number of public
+ * properties in the object.
+ */
+ function count();
+
+ /* @param $iterator_class new class used in getIterator()
+ */
+ function setIteratorClass($itertor_class);
+
+ /* @return class used in getIterator()
+ */
+ function getIteratorClass();
+}
+
+/** @ingroup SPL
+ * @brief An Array iterator
+ * @since PHP 5.0
+ * @version 1.1
+ *
+ * This iterator allows to unset and modify values and keys while iterating
+ * over Arrays and Objects.
+ *
+ * When you want to iterate over the same array multiple times you need to
+ * instanciate ArrayObject and let it create ArrayIterator instances that
+ * refer to it either by using foreach or by calling its getIterator()
+ * method manually.
+ */
+class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
+{
+ /** Properties of the object have their normal functionality
+ * when accessed as list (var_dump, foreach, etc.) */
+ const STD_PROP_LIST = 0x00000001;
+ /** Array indices can be accessed as properties in read/write */
+ const ARRAY_AS_PROPS = 0x00000002;
+
+ /** Construct a new array iterator from anything that has a hash table.
+ * That is any Array or Object.
+ *
+ * @param $array the array to use.
+ * @param $flags see setFlags().
+ */
+ function __construct($array, $flags = 0);
+
+ /** Set behavior flags.
+ *
+ * @param $flags bitmask as follows:
+ * 0 set: properties of the object have their normal functionality
+ * when accessed as list (var_dump, foreach, etc.)
+ * 1 set: array indices can be accessed as properties in read/write
+ */
+ function setFlags($flags);
+
+ /**
+ * @ return current flags
+ */
+ function getFlags();
+
+ /** @param $index offset to inspect
+ * @return whetehr offset $index esists
+ */
+ function offsetExists($index);
+
+ /** @param $index offset to return value for
+ * @return value at offset $index
+ */
+ function offsetGet($index);
+
+ /** @param $index index to set
+ * @param $newval new value to store at offset $index
+ */
+ function offsetSet($index, $newval);
+
+ /** @param $index offset to unset
+ */
+ function offsetUnset($index);
+
+ /** @param $value is appended as last element
+ * @warning this method cannot be called when the ArrayIterator refers to
+ * an object.
+ */
+ function append($value);
+
+ /** @return a \b copy of the array
+ * @note when the ArrayIterator refers to an object then this method
+ * returns an array of the public properties.
+ */
+ function getArrayCopy();
+
+ /** @param $position offset to seek to
+ * @throw OutOfBoundsException if $position is invalid
+ */
+ function seek($position);
+
+ /** @return the number of elements in the array or the number of public
+ * properties in the object.
+ */
+ function count();
+}
+
+/** @ingroup SPL
+ * @brief Directory iterator
+ * @since PHP 5.0
+ */
+class DirectoryIterator implements Iterator
+{
+ /** Construct a directory iterator from a path-string.
+ *
+ * @param $path directory to iterate.
+ */
+ function __construct($path);
+
+ /** @return The opened path.
+ */
+ function getPath();
+
+ /** @return The current file name.
+ */
+ function getFilename();
+
+ /** @return The current entries path and file name.
+ */
+ function getPathname();
+
+ /** @return The current entry's permissions.
+ */
+ function getPerms();
+
+ /** @return The current entry's inode.
+ */
+ function getInode();
+
+ /** @return The current entry's size in bytes .
+ */
+ function getSize();
+
+ /** @return The current entry's owner name.
+ */
+ function getOwner();
+
+ /** @return The current entry's group name.
+ */
+ function getGroup();
+
+ /** @return The current entry's last access time.
+ */
+ function getATime();
+
+ /** @return The current entry's last modification time.
+ */
+ function getMTime();
+
+ /** @return The current entry's last change time.
+ */
+ function getCTime();
+
+ /** @return The current entry's size in bytes .
+ */
+ function getType();
+
+ /** @return Whether the current entry is writeable.
+ */
+ function isWritable();
+
+ /** @return Whether the current entry is readable.
+ */
+ function isReadable();
+
+ /** @return Whether the current entry is executable.
+ */
+ function isExecutable();
+
+ /** @return Whether the current entry is .
+ */
+ function isFile();
+
+ /** @return Whether the current entry is a directory.
+ */
+ function isDir();
+
+ /** @return Whether the current entry is either '.' or '..'.
+ */
+ function isDot();
+
+ /** @return whether the current entry is a link.
+ */
+ function isLink();
+
+ /** @return getFilename()
+ */
+ function __toString();
+
+ /** Open the current file as a SplFileObject instance
+ *
+ * @param mode open mode
+ * @param use_include_path whether to search include paths (don't use)
+ * @param context resource context to pased to open function
+ * @throw RuntimeException if file cannot be opened (e.g. insufficient
+ * access rights).
+ * @return The opened file as a SplFileObject instance
+ *
+ * @see SplFileObject
+ * @see file()
+ */
+ function DirectoryIterator::openFile($mode = 'r', $use_include_path = false, $context = NULL);
+}
+
+/** @ingroup SPL
+ * @brief recursive directory iterator
+ * @since PHP 5.0
+ */
+class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
+{
+ /** @return whether the current is a directory (not '.' or '..').
+ */
+ function hasChildren();
+
+ /** @return a RecursiveDirectoryIterator for the current entry.
+ */
+ function getChildren();
+}
+
+/** @ingroup SPL
+ * @brief recursive SimpleXML_Element iterator
+ * @since PHP 5.0
+ *
+ * The SimpleXMLIterator implements the RecursiveIterator interface. This
+ * allows iteration over all elements using foreach or an appropriate while
+ * construct, just like SimpleXMLElement does. When using the foreach construct,
+ * you will also iterate over the subelements. For every element which
+ * has subelements, hasChildren() returns true. This will trigger a call to
+ * getChildren() which returns the iterator for that sub element.
+ */
+class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator
+{
+ /** @return whether the current node has sub nodes.
+ */
+ function hasChildren();
+
+ /** @return a SimpleXMLIterator for the current node.
+ */
+ function getChildren();
+}
+
+/** @ingroup SPL
+ * @brief Observer of the observer pattern
+ * @since PHP 5.1
+ *
+ * For a detailed explanation see Observer pattern in
+ * <em>
+ * Gamma, Helm, Johnson, Vlissides<br />
+ * Design Patterns
+ * </em>
+ */
+interface SplObserver
+{
+ /** Called from the subject (i.e. when it's value has changed).
+ * @param $subject the callee
+ */
+ function update(SplSubject $subject);
+}
+
+/** @ingroup SPL
+ * @brief Subject to the observer pattern
+ * @since PHP 5.1
+ * @see Observer
+ */
+interface SplSubject
+{
+ /** @param $observer new observer to attach
+ */
+ function attach(SplObserver $observer);
+
+ /** @param $observer existing observer to detach
+ * @note a non attached observer shouldn't result in a warning or similar
+ */
+ function detach(SplObserver $observer);
+
+ /** Notify all observers
+ */
+ function notify();
+}
+
+?>

Property changes on: trunk/doc/spl/spl.php
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/doc/www/parts/doxyLinks.html
===================================================================
--- trunk/doc/www/parts/doxyLinks.html 2006-04-09 15:42:30 UTC (rev 1521)
+++ trunk/doc/www/parts/doxyLinks.html 2006-04-09 18:26:57 UTC (rev 1522)
@@ -10,4 +10,10 @@
 <p class="miniCenter">
         <a href="doxy/0.2.11/">0.2.11</a><br>
         <a href="doxy/0.2.10/">0.2.10</a>
+</p>
+
+<p class="miniCenter">friends:</p>
+
+<p class="miniCenter">
+ spl-5.1.2
 </p>
\ No newline at end of file

Modified: trunk/global.inc.php.tpl
===================================================================
--- trunk/global.inc.php.tpl 2006-04-09 15:42:30 UTC (rev 1521)
+++ trunk/global.inc.php.tpl 2006-04-09 18:26:57 UTC (rev 1522)
@@ -66,6 +66,7 @@
                 .ONPHP_CORE_PATH.'Exceptions' .PATH_SEPARATOR
                 .ONPHP_CORE_PATH.'Form' .PATH_SEPARATOR
                 .ONPHP_CORE_PATH.'Logic' .PATH_SEPARATOR
+ .ONPHP_CORE_PATH.'SPL' .PATH_SEPARATOR
                 .ONPHP_CORE_PATH.'OSQL' .PATH_SEPARATOR
                 
                 // main framework
@@ -74,6 +75,10 @@
                 .ONPHP_MAIN_PATH.'Flow' .PATH_SEPARATOR
                 .ONPHP_MAIN_PATH.'Containers' .PATH_SEPARATOR
                 .ONPHP_MAIN_PATH.'Utils' .PATH_SEPARATOR
+
+ // uncomment this one, if your php compiled without spl extension:
+ //
+ // .ONPHP_CORE_PATH.'SPL'.DIRECTORY_SEPARATOR.'bundled'.PATH_SEPARATOR
         );
     
         // file extensions

Modified: trunk/main/Flow/Model.class.php
===================================================================
--- trunk/main/Flow/Model.class.php 2006-04-09 15:42:30 UTC (rev 1521)
+++ trunk/main/Flow/Model.class.php 2006-04-09 18:26:57 UTC (rev 1522)
@@ -13,7 +13,7 @@
         /**
          * @ingroup Flow
         **/
- class Model implements Creatable
+ class Model implements Creatable, SimplifiedArrayAccess
         {
                 private $vars = array();
                 
Received on Sun Apr 09 2006 - 22:27:03 MSD

This archive was generated by hypermail 2.2.0 : Sat Oct 27 2007 - 19:59:39 MSD