summaryrefslogtreecommitdiff
path: root/project2/fileRows.cpp
blob: d7c8fca4829a12b6e749f6675400ca1944bd2a93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "fileRows.h"
#include "logger.h"
#include "rowProcessor.h"
#include "xmlObjectLoader.h"
#include "exceptions.h"
#include <boost/algorithm/string/predicate.hpp>

DECLARE_LOADER("filerows", FileRows);

FileRows::FileRows(const xmlpp::Element * p) :
	StreamRows(p),
	path(p, "path")
{
}

FileRows::~FileRows()
{
}

void
FileRows::loadComplete(const CommonObjects *)
{
}

void
FileRows::setFilter(const Glib::ustring &)
{
	throw NotSupported(__PRETTY_FUNCTION__);
}

void
FileRows::execute(const Glib::ustring &, const RowProcessor * rp) const
{
	FileStarChannel c(doOpen());
	c.set_encoding(encoding);
	gunichar ch;
	ParseState ps(this, rp);
	while (c.read(ch) == Glib::IO_STATUS_NORMAL) {
		this->pushChar(ch, ps);
	}
}

FileStarChannel
FileRows::doOpen() const
{
	FILE * f = fopen(path(), "r");
	if (!f) {
		throw FileNotReadable(path());
	}
	return FileStarChannel(f, true, fclose);
}