FileIterator
[ class tree: FileIterator ] [ index: FileIterator ] [ all elements ]

Class: FileIterator

Source Location: /FileIterator.php

Class Overview


FileIterator is an implementation of Iterator interface for reading and parsing text files.


Author(s):

Copyright:

  • 2007 Simone Carletti

Implements interfaces:

  • Iterator (internal interface)

Variables

Constants

Methods



Class Details

[line 53]
FileIterator is an implementation of Iterator interface for reading and parsing text files.



Tags:

author:  Simone Carletti <weppos@weppos.net>
copyright:  2007 Simone Carletti
link:  http://www.simonecarletti.com/code/fileiterator/ FileIterator
license:  LGPL License 2.1


[ Top ]


Class Variables

$_currentElement =  null

[line 116]

Current element, which will be returned on each iteration.

Substantially, it's represented by a file row.




Tags:

access:  private

Type:   array


[ Top ]

$_currentIndex =

[line 124]

Current line of file.



Tags:

access:  private

Type:   int


[ Top ]

$_fileData =

[line 107]

File data.



Tags:

access:  private

Type:   array


[ Top ]

$_filePointer =

[line 91]

File pointer.



Tags:

access:  private

Type:   resource


[ Top ]

$_source =

[line 99]

Path to source file



Tags:

access:  private

Type:   string


[ Top ]

$_valid =

[line 132]

Whether current element is valid or not.



Tags:

access:  private

Type:   bool


[ Top ]

$_verbose =  false

[line 83]

Verbose output



Tags:

access:  private

Type:   bool


[ Top ]



Class Methods


constructor __construct [line 138]

FileIterator __construct( $source)

Class constructor



Tags:

access:  public


Parameters:

   $source  

[ Top ]

method current [line 156]

string current( )

Return the current element

Similar to the current() function for arrays. Implement Iterator::current()




Tags:

see:  Iterator::current()
access:  public



Implementation of:
Iterator::current
[ Top ]

method isEmpty [line 247]

bool isEmpty( [bool $whitespaceAsChar = true])

Checks whether current file row is empty



Tags:

access:  public


Parameters:

bool   $whitespaceAsChar  

[ Top ]

method key [line 170]

int key( )

Return the identifying key of the current element

Similar to the key() function for arrays. Implement Iterator::key()




Tags:

see:  Iterator::key()
access:  public



Implementation of:
Iterator::key
[ Top ]

method match [line 263]

bool match( string $pattern, [ &$matches = null], string $matches)

Checks whether current file row matches given regexp pattern

If $matches is provided, then it is filled with the results of search.




Tags:

access:  public


Parameters:

string   $pattern  
string   $matches  
   &$matches  

[ Top ]

method next [line 185]

void next( )

Move forward to next element

Similar to the next() function for arrays. Implement Iterator::next()




Tags:

see:  Iterator::next()
throws:  Exception
access:  public



Implementation of:
Iterator::next
[ Top ]

method rewind [line 221]

void rewind( )

Rewind the Iterator to the first element

Similar to the reset() function for arrays. Implement Iterator::rewind()




Tags:

see:  Iterator::rewind()
access:  public



Implementation of:
Iterator::rewind
[ Top ]

method valid [line 235]

bool valid( )

Check if there is a current element after calls to rewind() or next().

Used to check if we've iterated to the end of the collection.

This method checks if the next row is a valid row.




Tags:

return:  FALSE if there's nothing more to iterate over.
access:  public



Implementation of:
Iterator::valid
[ Top ]

method _openPointer [line 277]

resource _openPointer( [string $source = null])

Opens and returns file pointer to given file



Tags:

throws:  Exception
access:  private


Parameters:

string   $source  

[ Top ]

method _rewindPointer [line 301]

void _rewindPointer( )

Rewind file pointer to the beginning and reset all loop variables



Tags:

access:  private


[ Top ]


Class Constants

AUTHOR =  'Simone Carletti <weppos@weppos.net>'

[line 58]

Author


[ Top ]

BUILD =  '$Rev: 8 $'

[line 64]

Build


[ Top ]

NAME =  'FileIterator'

[line 56]

Name


[ Top ]

ROW_SIZE =  4096

[line 74]

File row size


[ Top ]

STATUS =  'alpha'

[line 62]

Status


[ Top ]

SVN_BUILD =  '$Date: 2007-06-18 10:07:30 +0200 (Mon, 18 Jun 2007) $'

[line 71]

SVN Date


[ Top ]

SVN_ID =  '$Id: FileIterator.php 8 2007-06-18 08:07:30Z weppos $'

[line 67]

SVN ID


[ Top ]

SVN_REVISION =  '$Rev: 8 $'

[line 69]

SVN Revision


[ Top ]

VERSION =  '0.1.0'

[line 60]

Version


[ Top ]



Documentation generated on Mon, 18 Jun 2007 10:16:03 +0200 by phpDocumentor 1.3.2