added support for Var assignment to Var-enabled types

This commit is contained in:
Aleksandar Fabijanic
2009-11-13 00:12:26 +00:00
parent 1568abf9be
commit d0d667af56
12 changed files with 394 additions and 3 deletions

View File

@@ -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