helly Wed Jul 16 17:51:09 2003 EDT Modified files: /spl/examples dba_dump.php filter.inc sub_dir.inc Log: Update examples Index: spl/examples/dba_dump.php diff -u spl/examples/dba_dump.php:1.2 spl/examples/dba_dump.php:1.3 --- spl/examples/dba_dump.php:1.2 Sun Jun 22 08:57:53 2003 +++ spl/examples/dba_dump.php Wed Jul 16 17:51:09 2003 @@ -2,63 +2,25 @@ /* dba dump utility * - * Usage php dba_dump <file> <handler> + * Usage: php dba_dump <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 * * (c) Marcus Boerger */ -class dba_reader implements spl_sequence_assoc -{ - - private $db = NULL; - private $key = false; - private $val = false; - - function __construct($file, $handler) { - $this->db = dba_open($file, 'r', $handler); - } - - function __destruct() { - if ($this->db) { - dba_close($this->db); - } - } - - function rewind() { - if ($this->db) { - $this->key = dba_firstkey($this->db); - } - } +require_once("dba_reader.inc"); +require_once("key_filter.inc"); - function current() { - return $this->val; - } - - function next() { - if ($this->db) { - $this->key = dba_nextkey($this->db); - if ($this->key !== false) { - $this->val = dba_fetch($this->key, $this->db); - } - } - } - - function has_more() { - if ($this->db && $this->key !== false) { - return true; - } else { - return false; - } - } +$db = new dba_reader($argv[1], $argv[2]); - function key() { - return $this->key; - } +if ($argc>3) { + $db = new key_filter($db, $argv[3]); } -$db = new dba_reader($argv[1], $argv[2]); foreach($db as $key => $val) { echo "'$key' => '$val'\n"; } Index: spl/examples/filter.inc diff -u spl/examples/filter.inc:1.1 spl/examples/filter.inc:1.2 --- spl/examples/filter.inc:1.1 Wed Jul 16 16:18:33 2003 +++ spl/examples/filter.inc Wed Jul 16 17:51:09 2003 @@ -1,8 +1,8 @@ <?php /** - * @brief Regular expression filter for string iterators - * @author Marcus Boerger + * @brief Regular expression filter for string iterators + * @author Marcus Boerger * @version 1.0 * * Instances of this class act as a filter around iterators whose elements Index: spl/examples/sub_dir.inc diff -u spl/examples/sub_dir.inc:1.1 spl/examples/sub_dir.inc:1.2 --- spl/examples/sub_dir.inc:1.1 Wed Jul 16 16:18:33 2003 +++ spl/examples/sub_dir.inc Wed Jul 16 17:51:09 2003 @@ -1,8 +1,8 @@ <?php /** - * @brief Subdirectory aware directory iterator. - * @author Marcus Boerger + * @brief Subdirectory aware directory iterator. + * @author Marcus Boerger * @version 1.0 * * This directory iterator recursively returns all files and directories
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php