From b686f4f780a2331a544d84f9d8bb8345c2361307 Mon Sep 17 00:00:00 2001 From: randomdan Date: Tue, 21 Sep 2010 19:51:33 +0000 Subject: Handle null fields Use null to hide null license details Fix mask counter Include change log --- project2/fileRows.cpp | 6 ++++++ project2/fileRows.h | 1 + project2/iterate.h | 1 + project2/iterate.hpp | 7 +++++++ project2/perRowValues.h | 1 + project2/rawView.cpp | 6 ++++++ project2/rawView.h | 1 + project2/sqlRows.cpp | 6 ++++++ project2/sqlRows.h | 1 + project2/urlRows.cpp | 6 ++++++ project2/urlRows.h | 1 + project2/view.h | 1 + project2/view.hpp | 13 +++++++++++-- 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 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 @@ -57,6 +57,13 @@ _GenericIterate::getCurrentValue(const Glib::ustring & id) const return Driver::getCurrentValue(id); } +template +bool +_GenericIterate::isNull(const unsigned int id) const +{ + return Driver::isNull(id); +} + template const Glib::ustring & _GenericIterate::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 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::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); } @@ -44,6 +46,13 @@ _GenericView:: loadComplete() Driver::loadComplete(); } +template +bool +_GenericView:: isNull(const unsigned int id) const +{ + return Driver::isNull(id); +} + template const Glib::ustring & _GenericView:: getCurrentValue(const unsigned int id) const -- cgit v1.2.3