Better support for boost::optional in database layer.
This commit is contained in:
parent
780d912cd1
commit
e4ccd93b09
4 changed files with 27 additions and 5 deletions
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue