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

@@ -49,6 +49,12 @@ namespace Poco {
class DateTime;
namespace Dynamic {
class Var;
}
namespace Data {
@@ -84,9 +90,15 @@ public:
void assign(int year, int month, int day);
/// Assigns date.
Date& operator = (const Date& d);
/// Assignment operator for Date.
Date& operator = (const DateTime& dt);
/// Assignment operator for DateTime.
Date& operator = (const Poco::Dynamic::Var& var);
/// Assignment operator for Var.
bool operator == (const Date& date);
/// Equality operator.
@@ -127,6 +139,13 @@ inline int Date::day() const
}
inline Date& Date::operator = (const Date& d)
{
assign(d.year(), d.month(), d.day());
return *this;
}
inline Date& Date::operator = (const DateTime& dt)
{
assign(dt.year(), dt.month(), dt.day());
@@ -158,7 +177,7 @@ inline bool Date::operator > (const Date& date)
//
// VarHolderImpl<BLOB>
// VarHolderImpl<Date>
//

View File

@@ -0,0 +1,67 @@
//
// DynamicDateTime.h
//
// $Id: //poco/Main/Data/include/Poco/Data/DynamicDateTime.h#7 $
//
// Library: Data
// Package: DataCore
// Module: DynamicDateTime
//
// Definition of the Date and Time cast operators for Poco::Dynamic::Var.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Data_DynamicDateTime_INCLUDED
#define Data_DynamicDateTime_INCLUDED
#include "Poco/Data/Data.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace Data {
class Date;
class Time;
} } // namespace Poco::Data
namespace Poco {
namespace Dynamic {
template <> Data_API Var::operator Poco::Data::Date () const;
template <> Data_API Var::operator Poco::Data::Time () const;
} } // namespace Poco::Dynamic
#endif // Data_DynamicDateTime_INCLUDED

View File

@@ -0,0 +1,66 @@
//
// DynamicLOB.h
//
// $Id: //poco/Main/Data/include/Poco/Data/DynamicLOB.h#12 $
//
// Library: Data
// Package: DataCore
// Module: DynamicLOB
//
// Definition of the Poco::Dynamic::Var LOB cast operators.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Data_DynamicLOB_INCLUDED
#define Data_DynamicLOB_INCLUDED
#include "Poco/Data/Data.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace Data {
template <typename T> class LOB;
typedef LOB<unsigned char> BLOB;
typedef LOB<char> CLOB;
} } // namespace Poco::Data
namespace Poco {
namespace Dynamic {
template <> Data_API Var::operator Poco::Data::CLOB () const;
template <> Data_API Var::operator Poco::Data::BLOB () const;
} } // namespace Poco::Dynamic
#endif // Data_DynamicLOB_INCLUDED

View File

@@ -47,6 +47,12 @@
namespace Poco {
namespace Dynamic {
class Var;
}
class DateTime;
namespace Data {
@@ -84,9 +90,15 @@ public:
void assign(int hour, int minute, int second);
/// Assigns time.
Time& operator = (const Time& t);
/// Assignment operator for Time.
Time& operator = (const DateTime& dt);
/// Assignment operator for DateTime.
Time& operator = (const Poco::Dynamic::Var& var);
/// Assignment operator for Var.
bool operator == (const Time& time);
/// Equality operator.
@@ -127,6 +139,13 @@ inline int Time::second() const
}
inline Time& Time::operator = (const Time& t)
{
assign(t.hour(), t.minute(), t.second());
return *this;
}
inline Time& Time::operator = (const DateTime& dt)
{
assign(dt.hour(), dt.minute(), dt.second());
@@ -158,7 +177,7 @@ inline bool Time::operator > (const Time& time)
//
// VarHolderImpl<BLOB>
// VarHolderImpl<Time>
//