class ParserCSVIterator in Feeds 7.2
Same name and namespace in other branches
- 6 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 15 - Contains CSV Parser.
View source
class ParserCSVIterator implements Iterator {
private $handle;
private $currentLine;
private $currentPos;
/**
* {@inheritdoc}
*/
public function __construct($filepath) {
$this->handle = fopen($filepath, 'r');
$this->currentLine = NULL;
$this->currentPos = NULL;
}
/**
* {@inheritdoc}
*/
public function __destruct() {
if ($this->handle) {
fclose($this->handle);
}
}
/**
* Closes the current file.
*/
public function releaseHandler() {
if ($this->handle) {
fclose($this->handle);
$this->handle = NULL;
}
}
/**
* {@inheritdoc}
*/
public function rewind($pos = 0) {
if ($this->handle) {
fseek($this->handle, $pos);
$this
->next();
}
}
/**
* {@inheritdoc}
*/
public function next() {
if ($this->handle) {
$this->currentLine = feof($this->handle) ? NULL : fgets($this->handle);
$this->currentPos = ftell($this->handle);
return $this->currentLine;
}
}
/**
* {@inheritdoc}
*/
public function valid() {
return isset($this->currentLine);
}
/**
* {@inheritdoc}
*/
public function current() {
return $this->currentLine;
}
/**
* {@inheritdoc}
*/
public function currentPos() {
return $this->currentPos;
}
/**
* {@inheritdoc}
*/
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 | Closes the current file. | |
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function | ||
ParserCSVIterator:: |
public | function |