mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-28 03:20:11 +01:00
added support for Var assignment to Var-enabled types
This commit is contained in:
@@ -35,10 +35,13 @@
|
||||
|
||||
|
||||
#include "Poco/Data/Time.h"
|
||||
#include "Poco/Data/DynamicDateTime.h"
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/Dynamic/Var.h"
|
||||
|
||||
|
||||
using Poco::DateTime;
|
||||
using Poco::Dynamic::Var;
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@@ -106,4 +109,39 @@ bool Time::operator < (const Time& time)
|
||||
}
|
||||
|
||||
|
||||
Time& Time::operator = (const Var& var)
|
||||
{
|
||||
*this = var.operator Time(); // g++ workaround
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Data
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Dynamic {
|
||||
|
||||
|
||||
using Poco::Data::Time;
|
||||
using Poco::DateTime;
|
||||
|
||||
|
||||
template <>
|
||||
Var::operator Time () const
|
||||
{
|
||||
if (!_pHolder)
|
||||
throw InvalidAccessException("Can not convert empty value.");
|
||||
|
||||
if (typeid(Time) == _pHolder->type())
|
||||
return extract<Time>();
|
||||
else
|
||||
{
|
||||
Poco::DateTime result;
|
||||
_pHolder->convert(result);
|
||||
return Time(result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Dynamic
|
||||
|
||||
Reference in New Issue
Block a user