diff options
Diffstat (limited to 'slicer/db')
-rw-r--r-- | slicer/db/Jamfile.jam | 11 | ||||
-rw-r--r-- | slicer/db/exceptions.cpp | 6 | ||||
-rw-r--r-- | slicer/db/exceptions.h | 14 | ||||
-rw-r--r-- | slicer/db/sqlExceptions.ice | 17 | ||||
-rw-r--r-- | slicer/db/sqlInsertSerializer.cpp | 5 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.cpp | 7 | ||||
-rw-r--r-- | slicer/db/sqlSelectDeserializer.h | 10 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.cpp | 5 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.h | 5 | ||||
-rw-r--r-- | slicer/db/testInsert.cpp | 2 | ||||
-rw-r--r-- | slicer/db/testSelect.cpp | 3 | ||||
-rw-r--r-- | slicer/db/testUpdate.cpp | 3 |
12 files changed, 40 insertions, 48 deletions
diff --git a/slicer/db/Jamfile.jam b/slicer/db/Jamfile.jam index 664b6b1..f73d3f8 100644 --- a/slicer/db/Jamfile.jam +++ b/slicer/db/Jamfile.jam @@ -6,17 +6,23 @@ lib adhocutil : : : : <include>/usr/include/adhocutil ; lib boost_system ; lib boost_filesystem ; lib boost_utf : : <name>boost_unit_test_framework ; +lib pthread ; +lib Ice ; lib IceUtil ; lib slicer-db : [ glob *.cpp : test*.cpp ] + [ glob *.ice ] : <include>.. + <library>pthread + <library>Ice <library>IceUtil <library>dbppcore <library>../..//glibmm <library>adhocutil <library>../slicer//slicer + <implicit-dependency>../slicer//slicer : : <library>dbppcore ; @@ -28,6 +34,7 @@ run testSelect.cpp <define>ROOT=\"$(me)\" <define>BOOST_TEST_DYN_LINK <library>slicer-db + <implicit-dependency>slicer-db <library>dbpp-postgresql <library>boost_system <library>boost_filesystem @@ -35,6 +42,7 @@ run testSelect.cpp <library>../test//slicer-test <library>../test//common <library>../slicer//slicer + <implicit-dependency>../slicer//slicer <include>.. <dependency>slicer.sql <dependency>../test//compilation @@ -54,6 +62,7 @@ run testInsert.cpp <library>../test//slicer-test <library>../test//common <library>../slicer//slicer + <implicit-dependency>../slicer//slicer <include>.. <dependency>slicer.sql <dependency>../test//compilation @@ -66,6 +75,7 @@ run testUpdate.cpp <define>ROOT=\"$(me)\" <define>BOOST_TEST_DYN_LINK <library>slicer-db + <implicit-dependency>slicer-db <library>dbpp-postgresql <library>boost_system <library>boost_filesystem @@ -73,6 +83,7 @@ run testUpdate.cpp <library>../test//slicer-test <library>../test//common <library>../slicer//slicer + <implicit-dependency>../slicer//slicer <include>.. <dependency>slicer.sql <dependency>../test//compilation diff --git a/slicer/db/exceptions.cpp b/slicer/db/exceptions.cpp deleted file mode 100644 index 50099bd..0000000 --- a/slicer/db/exceptions.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "exceptions.h" - -namespace Slicer { - UnsupportedModelType::UnsupportedModelType() : std::invalid_argument("Unspported model type") { } -} - diff --git a/slicer/db/exceptions.h b/slicer/db/exceptions.h deleted file mode 100644 index 8673627..0000000 --- a/slicer/db/exceptions.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef SLICER_DB_EXCEPTIONS_H -#define SLICER_DB_EXCEPTIONS_H - -#include <stdexcept> - -namespace Slicer { - class UnsupportedModelType : public std::invalid_argument { - public: - UnsupportedModelType(); - }; -} - -#endif - diff --git a/slicer/db/sqlExceptions.ice b/slicer/db/sqlExceptions.ice new file mode 100644 index 0000000..a392876 --- /dev/null +++ b/slicer/db/sqlExceptions.ice @@ -0,0 +1,17 @@ +#ifndef SLICER_XML +#define SLICER_XML + +#include <common.ice> + +module Slicer { + exception TooManyRowsReturned extends DeserializerError {}; + exception NoRowsReturned extends DeserializerError {}; + exception NoRowsFound extends SerializerError {}; + exception UnsuitableIdFieldType extends SerializerError { + string type; + }; +}; + +#endif + + diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp index 0ff0038..f5c4c4f 100644 --- a/slicer/db/sqlInsertSerializer.cpp +++ b/slicer/db/sqlInsertSerializer.cpp @@ -1,5 +1,6 @@ #include "sqlInsertSerializer.h" -#include "exceptions.h" +#include <common.h> +#include <sqlExceptions.h> #include "sqlBinder.h" #include <buffer.h> #include <modifycommand.h> @@ -65,7 +66,7 @@ namespace Slicer { } #define NonNumType(T) \ - void set(T &) const override { throw std::runtime_error("Can't store Id in " #T " type field"); } + void set(T &) const override { throw UnsuitableIdFieldType(#T); } #define NumType(T) \ void set(T & v) const override { v = boost::numeric_cast<T>(connection->insertId()); } diff --git a/slicer/db/sqlSelectDeserializer.cpp b/slicer/db/sqlSelectDeserializer.cpp index 7836c63..5e32f75 100644 --- a/slicer/db/sqlSelectDeserializer.cpp +++ b/slicer/db/sqlSelectDeserializer.cpp @@ -1,13 +1,10 @@ #include "sqlSelectDeserializer.h" #include "sqlSource.h" -#include "exceptions.h" +#include <sqlExceptions.h> +#include <common.h> #include <boost/algorithm/string/predicate.hpp> namespace Slicer { - NoRowsReturned::NoRowsReturned() : std::runtime_error("No rows returned") { } - - TooManyRowsReturned::TooManyRowsReturned() : std::runtime_error("Too many rows returned") { } - SqlSelectDeserializer::SqlSelectDeserializer(DB::SelectCommand & c, IceUtil::Optional<std::string> tc) : cmd(c), typeIdColName(tc) diff --git a/slicer/db/sqlSelectDeserializer.h b/slicer/db/sqlSelectDeserializer.h index 3d73c94..c520090 100644 --- a/slicer/db/sqlSelectDeserializer.h +++ b/slicer/db/sqlSelectDeserializer.h @@ -6,16 +6,6 @@ #include <visibility.h> namespace Slicer { - class NoRowsReturned : public std::runtime_error { - public: - NoRowsReturned(); - }; - - class TooManyRowsReturned : public std::runtime_error { - public: - TooManyRowsReturned(); - }; - class DLL_PUBLIC SqlSelectDeserializer : public Slicer::Deserializer { public: SqlSelectDeserializer(DB::SelectCommand &, IceUtil::Optional<std::string> typeIdCol = IceUtil::Optional<std::string>()); diff --git a/slicer/db/sqlUpdateSerializer.cpp b/slicer/db/sqlUpdateSerializer.cpp index 65889ab..867b9fb 100644 --- a/slicer/db/sqlUpdateSerializer.cpp +++ b/slicer/db/sqlUpdateSerializer.cpp @@ -1,13 +1,12 @@ #include "sqlUpdateSerializer.h" -#include "exceptions.h" +#include <sqlExceptions.h> +#include <common.h> #include "sqlBinder.h" #include <buffer.h> #include <modifycommand.h> #include <slicer/metadata.h> namespace Slicer { - NoRowsFound::NoRowsFound() : std::runtime_error("No rows found") { } - const std::string md_pkey = "db:pkey"; SqlUpdateSerializer::SqlUpdateSerializer(DB::Connection * const c, const std::string & t) : diff --git a/slicer/db/sqlUpdateSerializer.h b/slicer/db/sqlUpdateSerializer.h index cbd8d65..83a5e04 100644 --- a/slicer/db/sqlUpdateSerializer.h +++ b/slicer/db/sqlUpdateSerializer.h @@ -6,11 +6,6 @@ #include <visibility.h> namespace Slicer { - class NoRowsFound : public std::runtime_error { - public: - NoRowsFound(); - }; - class DLL_PUBLIC SqlUpdateSerializer : public Slicer::Serializer { public: typedef boost::shared_ptr<DB::ModifyCommand> ModifyPtr; diff --git a/slicer/db/testInsert.cpp b/slicer/db/testInsert.cpp index e2118b8..ef37e66 100644 --- a/slicer/db/testInsert.cpp +++ b/slicer/db/testInsert.cpp @@ -7,7 +7,7 @@ #include "sqlInsertSerializer.h" #include "sqlSelectDeserializer.h" #include <types.h> -#include "exceptions.h" +#include <common.h> // LCOV_EXCL_START BOOST_TEST_DONT_PRINT_LOG_VALUE(TestModule::DateTime); diff --git a/slicer/db/testSelect.cpp b/slicer/db/testSelect.cpp index 6cade1d..c1e2121 100644 --- a/slicer/db/testSelect.cpp +++ b/slicer/db/testSelect.cpp @@ -6,7 +6,8 @@ #include <definedDirs.h> #include "sqlSelectDeserializer.h" #include <types.h> -#include "exceptions.h" +#include <common.h> +#include <sqlExceptions.h> class StandardMockDatabase : public PQ::Mock { public: diff --git a/slicer/db/testUpdate.cpp b/slicer/db/testUpdate.cpp index 159cb5e..1bf917e 100644 --- a/slicer/db/testUpdate.cpp +++ b/slicer/db/testUpdate.cpp @@ -8,7 +8,8 @@ #include "sqlSelectDeserializer.h" #include "sqlUpdateSerializer.h" #include <types.h> -#include "exceptions.h" +#include <common.h> +#include <sqlExceptions.h> class StandardMockDatabase : public PQ::Mock { public: |