From 08edf88437e4ca126773ab0b0e2a2f97f78e9656 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 13 Oct 2015 00:42:13 +0100 Subject: Split SqlSource into its own files --- slicer/db/sqlSelectDeserializer.cpp | 80 +---------------------------------- slicer/db/sqlSource.cpp | 84 +++++++++++++++++++++++++++++++++++++ slicer/db/sqlSource.h | 35 ++++++++++++++++ 3 files changed, 120 insertions(+), 79 deletions(-) create mode 100644 slicer/db/sqlSource.cpp create mode 100644 slicer/db/sqlSource.h diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp index 96c58c1..d4198b5 100644 --- a/slicer/db/sqlSelectDeserializer.cpp +++ b/slicer/db/sqlSelectDeserializer.cpp @@ -1,6 +1,6 @@ #include "sqlSelectDeserializer.h" +#include "sqlSource.h" #include -#include namespace Slicer { NoRowsReturned::NoRowsReturned() : std::runtime_error("No rows returned") { } @@ -9,84 +9,6 @@ namespace Slicer { UnsupportedModelType::UnsupportedModelType() : std::invalid_argument("Unspported model type") { } - class SqlSource : public Slicer::ValueSource, - public Slicer::TValueSource, - public Slicer::TValueSource - { - public: - SqlSource(const DB::Column & c) : - column(c) - { - } - - bool isNull() const - { - return column.isNull(); - } - - void set(boost::posix_time::ptime & b) const override - { - column >> b; - } - - void set(boost::posix_time::time_duration & b) const override - { - column >> b; - } - - void set(bool & b) const override - { - column >> b; - } - - void set(Ice::Byte & b) const override - { - int64_t cb; - column >> cb; - b = boost::numeric_cast(cb); - } - - void set(Ice::Short & b) const override - { - int64_t cb; - column >> cb; - b = boost::numeric_cast(cb); - } - - void set(Ice::Int & b) const override - { - int64_t cb; - column >> cb; - b = boost::numeric_cast(cb); - } - - void set(Ice::Long & b) const override - { - column >> b; - } - - void set(Ice::Float & b) const override - { - double cb; - column >> cb; - b = boost::numeric_cast(cb); - } - - void set(Ice::Double & b) const override - { - column >> b; - } - - void set(std::string & b) const override - { - column >> b; - } - - private: - const DB::Column & column; - }; - typedef IceUtil::Handle SqlSourcePtr; - SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand & c, IceUtil::Optional tc) : cmd(c), typeIdColName(tc) diff --git a/slicer/db/sqlSource.cpp b/slicer/db/sqlSource.cpp new file mode 100644 index 0000000..0a3b684 --- /dev/null +++ b/slicer/db/sqlSource.cpp @@ -0,0 +1,84 @@ +#include "sqlSource.h" +#include + +namespace Slicer { + SqlSource::SqlSource(const DB::Column & c) : + column(c) + { + } + + bool + SqlSource::isNull() const + { + return column.isNull(); + } + + void + SqlSource::set(boost::posix_time::ptime & b) const + { + column >> b; + } + + void + SqlSource::set(boost::posix_time::time_duration & b) const + { + column >> b; + } + + void + SqlSource::set(bool & b) const + { + column >> b; + } + + void + SqlSource::set(Ice::Byte & b) const + { + int64_t cb; + column >> cb; + b = boost::numeric_cast(cb); + } + + void + SqlSource::set(Ice::Short & b) const + { + int64_t cb; + column >> cb; + b = boost::numeric_cast(cb); + } + + void + SqlSource::set(Ice::Int & b) const + { + int64_t cb; + column >> cb; + b = boost::numeric_cast(cb); + } + + void + SqlSource::set(Ice::Long & b) const + { + column >> b; + } + + void + SqlSource::set(Ice::Float & b) const + { + double cb; + column >> cb; + b = boost::numeric_cast(cb); + } + + void + SqlSource::set(Ice::Double & b) const + { + column >> b; + } + + void + SqlSource::set(std::string & b) const + { + column >> b; + } +} + diff --git a/slicer/db/sqlSource.h b/slicer/db/sqlSource.h new file mode 100644 index 0000000..bf728dc --- /dev/null +++ b/slicer/db/sqlSource.h @@ -0,0 +1,35 @@ +#ifndef SLICER_DB_SQLSOURCE_H +#define SLICER_DB_SQLSOURCE_H + +#include +#include +#include + +namespace Slicer { + class SqlSource : public Slicer::ValueSource, + public Slicer::TValueSource, + public Slicer::TValueSource + { + public: + SqlSource(const DB::Column & c); + + bool isNull() const; + void set(boost::posix_time::ptime & b) const override; + void set(boost::posix_time::time_duration & b) const override; + void set(bool & b) const override; + void set(Ice::Byte & b) const override; + void set(Ice::Short & b) const override; + void set(Ice::Int & b) const override; + void set(Ice::Long & b) const override; + void set(Ice::Float & b) const override; + void set(Ice::Double & b) const override; + void set(std::string & b) const override; + + private: + const DB::Column & column; + }; + typedef IceUtil::Handle SqlSourcePtr; +} + +#endif + -- cgit v1.2.3