Better support for boost::optional in database layer.

This commit is contained in:
eelke 2018-09-19 08:25:23 +02:00
parent 780d912cd1
commit e4ccd93b09
4 changed files with 27 additions and 5 deletions

View file

@ -8,6 +8,7 @@
#include <vector>
#include <QString>
#include <QDateTime>
#include <boost/optional.hpp>
namespace Pgsql {
@ -149,10 +150,24 @@ namespace Pgsql {
Oid m_typ;
};
template <typename T>
void operator<<(boost::optional<T> &s, const Value &v)
{
if (v.null())
s = boost::optional<T>();
else
*s << v;
}
template <typename T>
void operator<<(std::vector<T> &s, const Value &v)
{
v.getAsArray(std::back_inserter(s));
}
template <typename T>
void operator<<(T &s, const Value &v)
{
//s = static_cast<T>(v);
s = v.operator T();
}