class ParserCSVIterator in Feeds 6
Same name and namespace in other branches
- 7.2 libraries/ParserCSV.inc \ParserCSVIterator
- 7 libraries/ParserCSV.inc \ParserCSVIterator
Text lines from file iterator.
Hierarchy
- class \ParserCSVIterator implements \Iterator
Expanded class hierarchy of ParserCSVIterator
File
- libraries/
ParserCSV.inc, line 13
View source
class ParserCSVIterator implements Iterator {
private $handle;
private $currentLine;
private $currentPos;
public function __construct($filepath) {
$this->handle = fopen($filepath, 'r');
$this->currentLine = NULL;
$this->currentPos = NULL;
}
function __destruct() {
if ($this->handle) {
fclose($this->handle);
}
}
public function rewind($pos = 0) {
if ($this->handle) {
fseek($this->handle, $pos);
$this
->next();
}
}
public function next() {
if ($this->handle) {
$this->currentLine = feof($this->handle) ? NULL : fgets($this->handle);
$this->currentPos = ftell($this->handle);
return $this->currentLine;
}
}
public function valid() {
return isset($this->currentLine);
}
public function current() {
return $this->currentLine;
}
public function currentPos() {
return $this->currentPos;
}
public function key() {
return 'line';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ParserCSVIterator:: |
private | property | ||
ParserCSVIterator:: |
private | property | ||
ParserCSVIterator:: |
private | property | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
function |