summaryrefslogtreecommitdiff
path: root/project2/files/fileRows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/files/fileRows.cpp')
-rw-r--r--project2/files/fileRows.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/project2/files/fileRows.cpp b/project2/files/fileRows.cpp
new file mode 100644
index 0000000..d7c8fca
--- /dev/null
+++ b/project2/files/fileRows.cpp
@@ -0,0 +1,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);
+}
+