summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-08-11 01:40:49 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-08-11 01:40:49 +0100
commit8f796ba6400e65143ac49b895e46a7a26de7992b (patch)
treeb83855cceb5066e969fbcede108c597e74a19eda
parentFix weird bracing (diff)
downloadslicer-8f796ba6400e65143ac49b895e46a7a26de7992b.tar.bz2
slicer-8f796ba6400e65143ac49b895e46a7a26de7992b.tar.xz
slicer-8f796ba6400e65143ac49b895e46a7a26de7992b.zip
Misc tidy up in db module
-rw-r--r--slicer/db/sqlBinder.h2
-rw-r--r--slicer/db/sqlCommon.cpp10
-rw-r--r--slicer/db/sqlCommon.h10
-rw-r--r--slicer/db/sqlInsertSerializer.cpp2
-rw-r--r--slicer/db/sqlInsertSerializer.h10
-rw-r--r--slicer/db/sqlSource.cpp33
-rw-r--r--slicer/db/sqlSource.h4
-rw-r--r--slicer/db/sqlTablePatchSerializer.cpp2
8 files changed, 30 insertions, 43 deletions
diff --git a/slicer/db/sqlBinder.h b/slicer/db/sqlBinder.h
index 71f23ea..a4a9a93 100644
--- a/slicer/db/sqlBinder.h
+++ b/slicer/db/sqlBinder.h
@@ -34,8 +34,6 @@ namespace Slicer {
DB::Command & command;
const unsigned int idx;
};
-
- typedef std::shared_ptr<SqlBinder> SqlBinderPtr;
}
#endif
diff --git a/slicer/db/sqlCommon.cpp b/slicer/db/sqlCommon.cpp
index 21fb9e5..0516f45 100644
--- a/slicer/db/sqlCommon.cpp
+++ b/slicer/db/sqlCommon.cpp
@@ -11,31 +11,31 @@ namespace Slicer {
constexpr std::string_view md_global_ignore {"ignore"};
bool
- isPKey(const HookCommon * h)
+ isPKey(const HookCommon * h) noexcept
{
return h->GetMetadata().flagSet(md_pkey) && isBind(h);
}
bool
- isAuto(const HookCommon * h)
+ isAuto(const HookCommon * h) noexcept
{
return h->GetMetadata().flagSet(md_auto) && isBind(h);
}
bool
- isNotAuto(const HookCommon * h)
+ isNotAuto(const HookCommon * h) noexcept
{
return h->GetMetadata().flagNotSet(md_auto) && isBind(h);
}
bool
- isBind(const HookCommon * h)
+ isBind(const HookCommon * h) noexcept
{
return h->GetMetadata().flagNotSet(md_global_ignore) && h->GetMetadata().flagNotSet(md_ignore);
}
bool
- isValue(const HookCommon * h)
+ isValue(const HookCommon * h) noexcept
{
return h->GetMetadata().flagNotSet(md_auto) && h->GetMetadata().flagNotSet(md_pkey) && isBind(h);
}
diff --git a/slicer/db/sqlCommon.h b/slicer/db/sqlCommon.h
index acabc51..16cefac 100644
--- a/slicer/db/sqlCommon.h
+++ b/slicer/db/sqlCommon.h
@@ -4,11 +4,11 @@
namespace Slicer {
class HookCommon;
- bool isPKey(const HookCommon *);
- bool isAuto(const HookCommon *);
- bool isNotAuto(const HookCommon *);
- bool isBind(const HookCommon *);
- bool isValue(const HookCommon *);
+ [[nodiscard]] bool isPKey(const HookCommon *) noexcept;
+ [[nodiscard]] bool isAuto(const HookCommon *) noexcept;
+ [[nodiscard]] bool isNotAuto(const HookCommon *) noexcept;
+ [[nodiscard]] bool isBind(const HookCommon *) noexcept;
+ [[nodiscard]] bool isValue(const HookCommon *) noexcept;
}
#endif
diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp
index ff30c7c..c99df57 100644
--- a/slicer/db/sqlInsertSerializer.cpp
+++ b/slicer/db/sqlInsertSerializer.cpp
@@ -15,8 +15,6 @@
#include <utility>
namespace Slicer {
- using namespace std::placeholders;
-
SqlInsertSerializer::SqlInsertSerializer(DB::Connection * const c, std::string t) :
connection(c), tableName(std::move(t))
{
diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h
index f9f4fdf..36ecac3 100644
--- a/slicer/db/sqlInsertSerializer.h
+++ b/slicer/db/sqlInsertSerializer.h
@@ -36,10 +36,7 @@ namespace Slicer {
class DLL_PUBLIC SqlAutoIdInsertSerializer : public SqlInsertSerializer {
public:
- template<typename... P>
- explicit SqlAutoIdInsertSerializer(P &&... p) : SqlInsertSerializer(std::forward<P>(p)...)
- {
- }
+ using SqlInsertSerializer::SqlInsertSerializer;
protected:
void createInsertField(unsigned int & fieldNo, std::ostream & insert, const std::string & name,
@@ -50,10 +47,7 @@ namespace Slicer {
class DLL_PUBLIC SqlFetchIdInsertSerializer : public SqlAutoIdInsertSerializer {
public:
- template<typename... P>
- explicit SqlFetchIdInsertSerializer(P &&... p) : SqlAutoIdInsertSerializer(std::forward<P>(p)...)
- {
- }
+ using SqlAutoIdInsertSerializer::SqlAutoIdInsertSerializer;
protected:
void bindObjectAndExecute(ModelPartParam, DB::ModifyCommand *) const override;
diff --git a/slicer/db/sqlSource.cpp b/slicer/db/sqlSource.cpp
index 41b9c1c..ed14b3a 100644
--- a/slicer/db/sqlSource.cpp
+++ b/slicer/db/sqlSource.cpp
@@ -7,6 +7,17 @@
namespace Slicer {
SqlSource::SqlSource(const DB::Column & c) : column(c) { }
+ namespace {
+ template<typename C, typename T>
+ void
+ numericSet(const DB::Column & column, T & b)
+ {
+ C cb {};
+ column >> cb;
+ b = boost::numeric_cast<T>(cb);
+ }
+ }
+
bool
SqlSource::isNull() const
{
@@ -34,47 +45,37 @@ namespace Slicer {
void
SqlSource::set(Ice::Byte & b) const
{
- int64_t cb;
- column >> cb;
- b = boost::numeric_cast<Ice::Byte>(cb);
+ numericSet<int64_t>(column, b);
}
void
SqlSource::set(Ice::Short & b) const
{
- int64_t cb;
- column >> cb;
- b = boost::numeric_cast<Ice::Short>(cb);
+ numericSet<int64_t>(column, b);
}
void
SqlSource::set(Ice::Int & b) const
{
- int64_t cb;
- column >> cb;
- b = boost::numeric_cast<Ice::Int>(cb);
+ numericSet<int64_t>(column, b);
}
void
SqlSource::set(Ice::Long & b) const
{
- int64_t cb;
- column >> cb;
- b = boost::numeric_cast<Ice::Long>(cb);
+ numericSet<int64_t>(column, b);
}
void
SqlSource::set(Ice::Float & b) const
{
- double cb;
- column >> cb;
- b = boost::numeric_cast<Ice::Float>(cb);
+ numericSet<double>(column, b);
}
void
SqlSource::set(Ice::Double & b) const
{
- column >> b;
+ numericSet<double>(column, b);
}
void
diff --git a/slicer/db/sqlSource.h b/slicer/db/sqlSource.h
index 70a0122..78d9909 100644
--- a/slicer/db/sqlSource.h
+++ b/slicer/db/sqlSource.h
@@ -23,7 +23,7 @@ namespace Slicer {
public:
explicit SqlSource(const DB::Column & c);
- bool isNull() const;
+ [[nodiscard]] 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;
@@ -38,8 +38,6 @@ namespace Slicer {
private:
const DB::Column & column;
};
-
- typedef std::shared_ptr<SqlSource> SqlSourcePtr;
}
#endif
diff --git a/slicer/db/sqlTablePatchSerializer.cpp b/slicer/db/sqlTablePatchSerializer.cpp
index 69acb16..da5b0b2 100644
--- a/slicer/db/sqlTablePatchSerializer.cpp
+++ b/slicer/db/sqlTablePatchSerializer.cpp
@@ -37,8 +37,6 @@ namespace Slicer {
if (isPKey(h)) {
tablePatch.pk.insert(name);
}
- });
- mp->OnEachChild([this](const auto & name, const auto &, const auto & h) {
if (isBind(h)) {
tablePatch.cols.insert(name);
}