summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--project2/fileRows.cpp6
-rw-r--r--project2/fileRows.h1
-rw-r--r--project2/iterate.h1
-rw-r--r--project2/iterate.hpp7
-rw-r--r--project2/perRowValues.h1
-rw-r--r--project2/rawView.cpp6
-rw-r--r--project2/rawView.h1
-rw-r--r--project2/sqlRows.cpp6
-rw-r--r--project2/sqlRows.h1
-rw-r--r--project2/urlRows.cpp6
-rw-r--r--project2/urlRows.h1
-rw-r--r--project2/view.h1
-rw-r--r--project2/view.hpp13
13 files changed, 49 insertions, 2 deletions
diff --git a/project2/fileRows.cpp b/project2/fileRows.cpp
index 9c6a5fe..f28c96d 100644
--- a/project2/fileRows.cpp
+++ b/project2/fileRows.cpp
@@ -108,6 +108,12 @@ _FileRows::getCurrentValue(unsigned int col) const
return *values[col];
}
+bool
+_FileRows::isNull(unsigned int col) const
+{
+ return false;
+}
+
const Glib::ustring &
_FileRows::getCurrentValue(const Glib::ustring & id) const
{
diff --git a/project2/fileRows.h b/project2/fileRows.h
index f083ecb..7c99c55 100644
--- a/project2/fileRows.h
+++ b/project2/fileRows.h
@@ -21,6 +21,7 @@ class _FileRows : public PerRowValues {
const Glib::ustring & getColumnName(unsigned int col) const;
const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
const Glib::ustring & getCurrentValue(unsigned int col) const;
+ bool isNull(unsigned int col) const;
virtual void rowReady() const = 0;
typedef std::set<gunichar> CharSet;
diff --git a/project2/iterate.h b/project2/iterate.h
index 502c24a..9dc9019 100644
--- a/project2/iterate.h
+++ b/project2/iterate.h
@@ -35,6 +35,7 @@ class _GenericIterate : public _Iterate, public Driver {
virtual const Glib::ustring & getCurrentValue(const unsigned int id) const;
virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
virtual const Glib::ustring & getColumnName(const unsigned int id) const;
+ virtual bool isNull(unsigned int col) const;
virtual void executeChildren() const;
virtual void execute() const;
virtual void rowReady() const;
diff --git a/project2/iterate.hpp b/project2/iterate.hpp
index 07925ad..f71ca9e 100644
--- a/project2/iterate.hpp
+++ b/project2/iterate.hpp
@@ -58,6 +58,13 @@ _GenericIterate<Driver>::getCurrentValue(const Glib::ustring & id) const
}
template <class Driver>
+bool
+_GenericIterate<Driver>::isNull(const unsigned int id) const
+{
+ return Driver::isNull(id);
+}
+
+template <class Driver>
const Glib::ustring &
_GenericIterate<Driver>::getColumnName(const unsigned int id) const
{
diff --git a/project2/perRowValues.h b/project2/perRowValues.h
index 9d4e7a8..09c77f5 100644
--- a/project2/perRowValues.h
+++ b/project2/perRowValues.h
@@ -25,6 +25,7 @@ class PerRowValues {
virtual const Glib::ustring & getColumnName(unsigned int col) const = 0;
virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const = 0;
virtual const Glib::ustring & getCurrentValue(unsigned int col) const = 0;
+ virtual bool isNull(unsigned int col) const = 0;
void use(const RowUser * r) const;
void finish(const RowUser * r) const;
diff --git a/project2/rawView.cpp b/project2/rawView.cpp
index e0691a7..1378f17 100644
--- a/project2/rawView.cpp
+++ b/project2/rawView.cpp
@@ -37,6 +37,12 @@ _RawView::getCurrentValue(const Glib::ustring & id) const
throw std::runtime_error("_RawView::getCurrentValue not implemented");
}
+bool
+_RawView::isNull(unsigned int id) const
+{
+ throw std::runtime_error("_RawView::isNull not implemented");
+}
+
const Glib::ustring &
_RawView::getColumnName(unsigned int id) const
{
diff --git a/project2/rawView.h b/project2/rawView.h
index 116d395..a6d85de 100644
--- a/project2/rawView.h
+++ b/project2/rawView.h
@@ -17,6 +17,7 @@ class _RawView : public _View {
virtual const Glib::ustring & getColumnName(unsigned int col) const;
virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
virtual const Glib::ustring & getCurrentValue(unsigned int col) const;
+ virtual bool isNull(unsigned int col) const;
private:
const xmlpp::Element * copyRoot;
};
diff --git a/project2/sqlRows.cpp b/project2/sqlRows.cpp
index 922d785..751a459 100644
--- a/project2/sqlRows.cpp
+++ b/project2/sqlRows.cpp
@@ -43,6 +43,12 @@ _SqlRows::getCurrentValue(unsigned int col) const
return (*query)[col].compose();
}
+bool
+_SqlRows::isNull(unsigned int col) const
+{
+ return (*query)[col].isNull();
+}
+
unsigned int
_SqlRows::columnCount() const
{
diff --git a/project2/sqlRows.h b/project2/sqlRows.h
index d084b4b..37ca72e 100644
--- a/project2/sqlRows.h
+++ b/project2/sqlRows.h
@@ -22,6 +22,7 @@ class _SqlRows : public IHaveParameters, public PerRowValues {
const Glib::ustring & getColumnName(unsigned int col) const;
const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
const Glib::ustring & getCurrentValue(unsigned int col) const;
+ bool isNull(unsigned int col) const;
virtual void rowReady() const = 0;
const std::string dataSource;
diff --git a/project2/urlRows.cpp b/project2/urlRows.cpp
index 7be904c..6354aa7 100644
--- a/project2/urlRows.cpp
+++ b/project2/urlRows.cpp
@@ -52,6 +52,12 @@ _UrlRows::getCurrentValue(unsigned int col) const
return *values[col];
}
+bool
+_UrlRows::isNull(unsigned int col) const
+{
+ return false;
+}
+
const Glib::ustring &
_UrlRows::getCurrentValue(const Glib::ustring & id) const
{
diff --git a/project2/urlRows.h b/project2/urlRows.h
index d9eb413..5ee7597 100644
--- a/project2/urlRows.h
+++ b/project2/urlRows.h
@@ -19,6 +19,7 @@ class _UrlRows : public PerRowValues {
const Glib::ustring & getColumnName(unsigned int col) const;
const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
const Glib::ustring & getCurrentValue(unsigned int col) const;
+ bool isNull(unsigned int col) const;
virtual void rowReady() const = 0;
typedef std::set<gunichar> CharSet;
diff --git a/project2/view.h b/project2/view.h
index ff0335e..cadb4c9 100644
--- a/project2/view.h
+++ b/project2/view.h
@@ -37,6 +37,7 @@ class _GenericView : public _View, public Driver {
virtual const Glib::ustring & getCurrentValue(const unsigned int id) const;
virtual const Glib::ustring & getCurrentValue(const Glib::ustring & id) const;
virtual const Glib::ustring & getColumnName(const unsigned int id) const;
+ virtual bool isNull(unsigned int col) const;
virtual void execute(xmlpp::Element * e) const;
virtual void rowReady() const;
private:
diff --git a/project2/view.hpp b/project2/view.hpp
index 820360f..a065097 100644
--- a/project2/view.hpp
+++ b/project2/view.hpp
@@ -24,8 +24,10 @@ _GenericView<Driver>::rowReady() const
xmlpp::Element * record = node->add_child(recordName);
unsigned int cols = Driver::columnCount();
for (unsigned int col = 0; col < cols; col += 1) {
- xmlpp::Element * ch = record->add_child(Driver::getColumnName(col));
- ch->set_child_text(Driver::getCurrentValue(col));
+ if (!Driver::isNull(col)) {
+ xmlpp::Element * ch = record->add_child(Driver::getColumnName(col));
+ ch->set_child_text(Driver::getCurrentValue(col));
+ }
}
executeChildren(record);
}
@@ -45,6 +47,13 @@ _GenericView<Driver>:: loadComplete()
}
template <class Driver>
+bool
+_GenericView<Driver>:: isNull(const unsigned int id) const
+{
+ return Driver::isNull(id);
+}
+
+template <class Driver>
const Glib::ustring &
_GenericView<Driver>:: getCurrentValue(const unsigned int id) const
{