change EOL to 'native'

This commit is contained in:
Aleksandar Fabijanic
2012-04-29 18:52:25 +00:00
parent 056cbeb744
commit 5a639074d9
2420 changed files with 544743 additions and 544298 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,67 +1,67 @@
//
// AbstractBinding.cpp
//
// $Id: //poco/Main/Data/src/AbstractBinding.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: AbstractBinding
//
// 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.
//
#include "Poco/Data/AbstractBinding.h"
namespace Poco {
namespace Data {
AbstractBinding::AbstractBinding(const std::string& name,
Direction direction,
Poco::UInt32 bulkSize):
_pBinder(0),
_name(name),
_direction(direction),
_bulkSize(bulkSize)
{
}
AbstractBinding::~AbstractBinding()
{
}
void AbstractBinding::setBinder(AbstractBinder* pBinder)
{
poco_check_ptr (pBinder);
_pBinder = pBinder;
}
} } // namespace Poco::Data
//
// AbstractBinding.cpp
//
// $Id: //poco/Main/Data/src/AbstractBinding.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: AbstractBinding
//
// 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.
//
#include "Poco/Data/AbstractBinding.h"
namespace Poco {
namespace Data {
AbstractBinding::AbstractBinding(const std::string& name,
Direction direction,
Poco::UInt32 bulkSize):
_pBinder(0),
_name(name),
_direction(direction),
_bulkSize(bulkSize)
{
}
AbstractBinding::~AbstractBinding()
{
}
void AbstractBinding::setBinder(AbstractBinder* pBinder)
{
poco_check_ptr (pBinder);
_pBinder = pBinder;
}
} } // namespace Poco::Data

View File

@@ -1,73 +1,73 @@
//
// AbstractExtraction.cpp
//
// $Id: //poco/Main/Data/src/AbstractExtraction.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: AbstractExtraction
//
// 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.
//
#include "Poco/Data/AbstractExtraction.h"
namespace Poco {
namespace Data {
AbstractExtraction::AbstractExtraction(Poco::UInt32 limit,
Poco::UInt32 position,
bool bulk):
_pExtractor(0),
_limit(limit),
_position(position),
_bulk(bulk),
_emptyStringIsNull(false),
_forceEmptyString(false)
{
}
AbstractExtraction::~AbstractExtraction()
{
}
bool AbstractExtraction::isValueNull(const std::string& str, bool deflt)
{
if (getForceEmptyString()) return false;
if (getEmptyStringIsNull() && str.empty())
return true;
return deflt;
}
} } // namespace Poco::Data
//
// AbstractExtraction.cpp
//
// $Id: //poco/Main/Data/src/AbstractExtraction.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: AbstractExtraction
//
// 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.
//
#include "Poco/Data/AbstractExtraction.h"
namespace Poco {
namespace Data {
AbstractExtraction::AbstractExtraction(Poco::UInt32 limit,
Poco::UInt32 position,
bool bulk):
_pExtractor(0),
_limit(limit),
_position(position),
_bulk(bulk),
_emptyStringIsNull(false),
_forceEmptyString(false)
{
}
AbstractExtraction::~AbstractExtraction()
{
}
bool AbstractExtraction::isValueNull(const std::string& str, bool deflt)
{
if (getForceEmptyString()) return false;
if (getEmptyStringIsNull() && str.empty())
return true;
return deflt;
}
} } // namespace Poco::Data

View File

@@ -1,435 +1,435 @@
//
// AbstractExtractor.cpp
//
// $Id: //poco/Main/Data/src/AbstractExtractor.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: AbstractExtractor
//
// 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.
//
#include "Poco/Data/AbstractExtractor.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
AbstractExtractor::AbstractExtractor()
{
}
AbstractExtractor::~AbstractExtractor()
{
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int8>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int8>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int8>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt8>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt8>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt8>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int16>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int16>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int16>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt16>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt16>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt16>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int32>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int32>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int32>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt32>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt32>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt32>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int64>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int64>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int64>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt64>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt64>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt64>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
#ifndef POCO_LONG_IS_64_BIT
bool AbstractExtractor::extract(std::size_t pos, std::vector<long>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<long>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<long>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
#endif
bool AbstractExtractor::extract(std::size_t pos, std::vector<bool>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<bool>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<bool>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<float>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<float>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<float>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<double>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<double>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<double>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<char>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<char>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<char>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<std::string>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<std::string>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<std::string>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<BLOB>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<BLOB>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<BLOB>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<CLOB>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<CLOB>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<CLOB>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<DateTime>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<DateTime>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<DateTime>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Date>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Date>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Date>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Time>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Time>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Time>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Any>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Any>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Any>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
} } // namespace Poco::Data
//
// AbstractExtractor.cpp
//
// $Id: //poco/Main/Data/src/AbstractExtractor.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: AbstractExtractor
//
// 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.
//
#include "Poco/Data/AbstractExtractor.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
AbstractExtractor::AbstractExtractor()
{
}
AbstractExtractor::~AbstractExtractor()
{
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int8>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int8>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int8>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt8>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt8>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt8>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int16>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int16>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int16>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt16>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt16>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt16>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int32>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int32>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int32>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt32>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt32>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt32>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Int64>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Int64>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Int64>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::UInt64>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::UInt64>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::UInt64>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
#ifndef POCO_LONG_IS_64_BIT
bool AbstractExtractor::extract(std::size_t pos, std::vector<long>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<long>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<long>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
#endif
bool AbstractExtractor::extract(std::size_t pos, std::vector<bool>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<bool>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<bool>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<float>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<float>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<float>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<double>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<double>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<double>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<char>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<char>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<char>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<std::string>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<std::string>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<std::string>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<BLOB>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<BLOB>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<BLOB>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<CLOB>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<CLOB>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<CLOB>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<DateTime>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<DateTime>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<DateTime>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Date>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Date>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Date>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Time>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Time>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Time>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Any>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Any>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Any>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque extractor must be implemented.");
}
bool AbstractExtractor::extract(std::size_t pos, std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list extractor must be implemented.");
}
} } // namespace Poco::Data

View File

@@ -1,56 +1,56 @@
//
// AbstractPreparation.cpp
//
// $Id: //poco/Main/Data/src/AbstractPreparation.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: AbstractPreparation
//
// 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.
//
#include "Poco/Data/AbstractPreparation.h"
namespace Poco {
namespace Data {
AbstractPreparation::AbstractPreparation(AbstractPreparator* pPreparator):
_pPreparator(pPreparator)
{
poco_assert_dbg (_pPreparator);
}
AbstractPreparation::~AbstractPreparation()
{
}
} } // namespace Poco::Data
//
// AbstractPreparation.cpp
//
// $Id: //poco/Main/Data/src/AbstractPreparation.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: AbstractPreparation
//
// 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.
//
#include "Poco/Data/AbstractPreparation.h"
namespace Poco {
namespace Data {
AbstractPreparation::AbstractPreparation(AbstractPreparator* pPreparator):
_pPreparator(pPreparator)
{
poco_assert_dbg (_pPreparator);
}
AbstractPreparation::~AbstractPreparation()
{
}
} } // namespace Poco::Data

View File

@@ -1,436 +1,436 @@
//
// AbstractPreparator.cpp
//
// $Id: //poco/Main/Data/src/AbstractPreparator.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: AbstractPreparator
//
// 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.
//
#include "Poco/Data/AbstractPreparator.h"
namespace Poco {
namespace Data {
AbstractPreparator::AbstractPreparator(Poco::UInt32 length):
_length(length),
_bulk(false)
{
}
AbstractPreparator::~AbstractPreparator()
{
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int8>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int8>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int8>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt8>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt8>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt8>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int16>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int16>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int16>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt16>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt16>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt16>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int32>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int32>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int32>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt32>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt32>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt32>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int64>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int64>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int64>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt64>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt64>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt64>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
#ifndef POCO_LONG_IS_64_BIT
void AbstractPreparator::prepare(std::size_t pos, const std::vector<long>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<long>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<long>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
#endif
void AbstractPreparator::prepare(std::size_t pos, const std::vector<bool>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<bool>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<bool>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<float>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<float>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<float>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<double>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<double>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<double>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<char>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<char>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<char>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<std::string>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<std::string>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<std::string>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<BLOB>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<BLOB>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<BLOB>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<CLOB>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<CLOB>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<CLOB>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<DateTime>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<DateTime>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<DateTime>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Date>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Date>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Date>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Time>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Time>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Time>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Any>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Any>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Any>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
} } // namespace Poco::Data
//
// AbstractPreparator.cpp
//
// $Id: //poco/Main/Data/src/AbstractPreparator.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: AbstractPreparator
//
// 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.
//
#include "Poco/Data/AbstractPreparator.h"
namespace Poco {
namespace Data {
AbstractPreparator::AbstractPreparator(Poco::UInt32 length):
_length(length),
_bulk(false)
{
}
AbstractPreparator::~AbstractPreparator()
{
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int8>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int8>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int8>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt8>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt8>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt8>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int16>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int16>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int16>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt16>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt16>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt16>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int32>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int32>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int32>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt32>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt32>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt32>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Int64>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Int64>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Int64>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::UInt64>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::UInt64>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::UInt64>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
#ifndef POCO_LONG_IS_64_BIT
void AbstractPreparator::prepare(std::size_t pos, const std::vector<long>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<long>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<long>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
#endif
void AbstractPreparator::prepare(std::size_t pos, const std::vector<bool>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<bool>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<bool>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<float>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<float>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<float>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<double>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<double>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<double>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<char>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<char>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<char>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<std::string>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<std::string>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<std::string>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<BLOB>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<BLOB>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<BLOB>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<CLOB>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<CLOB>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<CLOB>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<DateTime>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<DateTime>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<DateTime>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Date>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Date>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Date>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Time>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Time>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Time>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Any>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Any>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Any>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::vector<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::vector preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::deque<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::deque preparator must be implemented.");
}
void AbstractPreparator::prepare(std::size_t pos, const std::list<Poco::Dynamic::Var>& val)
{
throw NotImplementedException("std::list preparator must be implemented.");
}
} } // namespace Poco::Data

View File

@@ -1,168 +1,168 @@
//
// ArchiveStrategy.cpp
//
// $Id: //poco/Main/Data/src/ArchiveStrategy.cpp#8 $
//
// Library: Data
// Package: Logging
// Module: ArchiveStrategy
//
// Copyright (c) 2004-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.
//
#include "Poco/Data/ArchiveStrategy.h"
#include "Poco/Ascii.h"
namespace Poco {
namespace Data {
using namespace Keywords;
//
// ArchiveStrategy
//
const std::string ArchiveStrategy::DEFAULT_ARCHIVE_DESTINATION = "T_POCO_LOG_ARCHIVE";
ArchiveStrategy::ArchiveStrategy(const std::string& connector,
const std::string& connect,
const std::string& source,
const std::string& destination):
_connector(connector),
_connect(connect),
_source(source),
_destination(destination)
{
open();
}
ArchiveStrategy::~ArchiveStrategy()
{
}
void ArchiveStrategy::open()
{
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
_pSession = new Session(_connector, _connect);
}
//
// ArchiveByAgeStrategy
//
ArchiveByAgeStrategy::ArchiveByAgeStrategy(const std::string& connector,
const std::string& connect,
const std::string& sourceTable,
const std::string& destinationTable):
ArchiveStrategy(connector, connect, sourceTable, destinationTable)
{
initStatements();
}
ArchiveByAgeStrategy::~ArchiveByAgeStrategy()
{
}
void ArchiveByAgeStrategy::archive()
{
if (!session().isConnected()) open();
DateTime now;
_archiveDateTime = now - _maxAge;
getCountStatement().execute();
if (_archiveCount > 0)
{
getCopyStatement().execute();
getDeleteStatement().execute();
}
}
void ArchiveByAgeStrategy::initStatements()
{
std::string src = getSource();
std::string dest = getDestination();
setCountStatement();
_archiveCount = 0;
std::string sql;
Poco::format(sql, "SELECT COUNT(*) FROM %s WHERE DateTime < ?", src);
getCountStatement() << sql, into(_archiveCount), use(_archiveDateTime);
setCopyStatement();
sql.clear();
Poco::format(sql, "INSERT INTO %s SELECT * FROM %s WHERE DateTime < ?", dest, src);
getCopyStatement() << sql, use(_archiveDateTime);
setDeleteStatement();
sql.clear();
Poco::format(sql, "DELETE FROM %s WHERE DateTime < ?", src);
getDeleteStatement() << sql, use(_archiveDateTime);
}
void ArchiveByAgeStrategy::setThreshold(const std::string& age)
{
std::string::const_iterator it = age.begin();
std::string::const_iterator end = age.end();
int n = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
while (it != end && Ascii::isSpace(*it)) ++it;
std::string unit;
while (it != end && Ascii::isAlpha(*it)) unit += *it++;
Timespan::TimeDiff factor = Timespan::SECONDS;
if (unit == "minutes")
factor = Timespan::MINUTES;
else if (unit == "hours")
factor = Timespan::HOURS;
else if (unit == "days")
factor = Timespan::DAYS;
else if (unit == "weeks")
factor = 7*Timespan::DAYS;
else if (unit == "months")
factor = 30*Timespan::DAYS;
else if (unit != "seconds")
throw InvalidArgumentException("setMaxAge", age);
_maxAge = factor * n;
}
} } // namespace Poco::Data
//
// ArchiveStrategy.cpp
//
// $Id: //poco/Main/Data/src/ArchiveStrategy.cpp#8 $
//
// Library: Data
// Package: Logging
// Module: ArchiveStrategy
//
// Copyright (c) 2004-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.
//
#include "Poco/Data/ArchiveStrategy.h"
#include "Poco/Ascii.h"
namespace Poco {
namespace Data {
using namespace Keywords;
//
// ArchiveStrategy
//
const std::string ArchiveStrategy::DEFAULT_ARCHIVE_DESTINATION = "T_POCO_LOG_ARCHIVE";
ArchiveStrategy::ArchiveStrategy(const std::string& connector,
const std::string& connect,
const std::string& source,
const std::string& destination):
_connector(connector),
_connect(connect),
_source(source),
_destination(destination)
{
open();
}
ArchiveStrategy::~ArchiveStrategy()
{
}
void ArchiveStrategy::open()
{
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
_pSession = new Session(_connector, _connect);
}
//
// ArchiveByAgeStrategy
//
ArchiveByAgeStrategy::ArchiveByAgeStrategy(const std::string& connector,
const std::string& connect,
const std::string& sourceTable,
const std::string& destinationTable):
ArchiveStrategy(connector, connect, sourceTable, destinationTable)
{
initStatements();
}
ArchiveByAgeStrategy::~ArchiveByAgeStrategy()
{
}
void ArchiveByAgeStrategy::archive()
{
if (!session().isConnected()) open();
DateTime now;
_archiveDateTime = now - _maxAge;
getCountStatement().execute();
if (_archiveCount > 0)
{
getCopyStatement().execute();
getDeleteStatement().execute();
}
}
void ArchiveByAgeStrategy::initStatements()
{
std::string src = getSource();
std::string dest = getDestination();
setCountStatement();
_archiveCount = 0;
std::string sql;
Poco::format(sql, "SELECT COUNT(*) FROM %s WHERE DateTime < ?", src);
getCountStatement() << sql, into(_archiveCount), use(_archiveDateTime);
setCopyStatement();
sql.clear();
Poco::format(sql, "INSERT INTO %s SELECT * FROM %s WHERE DateTime < ?", dest, src);
getCopyStatement() << sql, use(_archiveDateTime);
setDeleteStatement();
sql.clear();
Poco::format(sql, "DELETE FROM %s WHERE DateTime < ?", src);
getDeleteStatement() << sql, use(_archiveDateTime);
}
void ArchiveByAgeStrategy::setThreshold(const std::string& age)
{
std::string::const_iterator it = age.begin();
std::string::const_iterator end = age.end();
int n = 0;
while (it != end && Ascii::isSpace(*it)) ++it;
while (it != end && Ascii::isDigit(*it)) { n *= 10; n += *it++ - '0'; }
while (it != end && Ascii::isSpace(*it)) ++it;
std::string unit;
while (it != end && Ascii::isAlpha(*it)) unit += *it++;
Timespan::TimeDiff factor = Timespan::SECONDS;
if (unit == "minutes")
factor = Timespan::MINUTES;
else if (unit == "hours")
factor = Timespan::HOURS;
else if (unit == "days")
factor = Timespan::DAYS;
else if (unit == "weeks")
factor = 7*Timespan::DAYS;
else if (unit == "months")
factor = 30*Timespan::DAYS;
else if (unit != "seconds")
throw InvalidArgumentException("setMaxAge", age);
_maxAge = factor * n;
}
} } // namespace Poco::Data

View File

@@ -1,59 +1,59 @@
//
// Bulk.cpp
//
// $Id: //poco/Main/Data/src/Bulk.cpp#7 $
//
// Library: Data
// Package: DataCore
// Module: Bulk
//
// 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.
//
#include "Poco/Data/Bulk.h"
namespace Poco {
namespace Data {
Bulk::Bulk(const Limit& limit): _limit(limit.value(), false, false)
{
}
Bulk::Bulk(Poco::UInt32 value): _limit(value, false, false)
{
}
Bulk::~Bulk()
{
}
} } // namespace Poco::Data
//
// Bulk.cpp
//
// $Id: //poco/Main/Data/src/Bulk.cpp#7 $
//
// Library: Data
// Package: DataCore
// Module: Bulk
//
// 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.
//
#include "Poco/Data/Bulk.h"
namespace Poco {
namespace Data {
Bulk::Bulk(const Limit& limit): _limit(limit.value(), false, false)
{
}
Bulk::Bulk(Poco::UInt32 value): _limit(value, false, false)
{
}
Bulk::~Bulk()
{
}
} } // namespace Poco::Data

View File

@@ -1,54 +1,54 @@
//
// Connector.cpp
//
// $Id: //poco/Main/Data/src/Connector.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: Connector
//
// 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.
//
#include "Poco/Data/Connector.h"
namespace Poco {
namespace Data {
Connector::Connector()
{
}
Connector::~Connector()
{
}
} } // namespace Poco::Data
//
// Connector.cpp
//
// $Id: //poco/Main/Data/src/Connector.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: Connector
//
// 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.
//
#include "Poco/Data/Connector.h"
namespace Poco {
namespace Data {
Connector::Connector()
{
}
Connector::~Connector()
{
}
} } // namespace Poco::Data

View File

@@ -1,63 +1,63 @@
//
// DataException.cpp
//
// $Id: //poco/Main/Data/src/DataException.cpp#8 $
//
// Library: Data
// Package: DataCore
// Module: DataException
//
// 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.
//
#include "Poco/Data/DataException.h"
#include <typeinfo>
namespace Poco {
namespace Data {
POCO_IMPLEMENT_EXCEPTION(DataException, Poco::IOException, "Database Exception")
POCO_IMPLEMENT_EXCEPTION(RowDataMissingException, DataException, "Data for row missing")
POCO_IMPLEMENT_EXCEPTION(UnknownDataBaseException, DataException, "Type of data base unknown")
POCO_IMPLEMENT_EXCEPTION(UnknownTypeException, DataException, "Type of data unknown")
POCO_IMPLEMENT_EXCEPTION(ExecutionException, DataException, "Execution error")
POCO_IMPLEMENT_EXCEPTION(BindingException, DataException, "Binding error")
POCO_IMPLEMENT_EXCEPTION(ExtractException, DataException, "Extraction error")
POCO_IMPLEMENT_EXCEPTION(LimitException, DataException, "Limit error")
POCO_IMPLEMENT_EXCEPTION(NotSupportedException, DataException, "Feature or property not supported")
POCO_IMPLEMENT_EXCEPTION(SessionUnavailableException, DataException, "Session is unavailable")
POCO_IMPLEMENT_EXCEPTION(SessionPoolExhaustedException, DataException, "No more sessions available from the session pool")
POCO_IMPLEMENT_EXCEPTION(SessionPoolExistsException, DataException, "Session already exists in the pool")
POCO_IMPLEMENT_EXCEPTION(NoDataException, DataException, "No data found")
POCO_IMPLEMENT_EXCEPTION(LengthExceededException, DataException, "Data too long")
POCO_IMPLEMENT_EXCEPTION(ConnectionFailedException, DataException, "Connection attempt failed")
POCO_IMPLEMENT_EXCEPTION(NotConnectedException, DataException, "Not connected to data source")
} } // namespace Poco::Data
//
// DataException.cpp
//
// $Id: //poco/Main/Data/src/DataException.cpp#8 $
//
// Library: Data
// Package: DataCore
// Module: DataException
//
// 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.
//
#include "Poco/Data/DataException.h"
#include <typeinfo>
namespace Poco {
namespace Data {
POCO_IMPLEMENT_EXCEPTION(DataException, Poco::IOException, "Database Exception")
POCO_IMPLEMENT_EXCEPTION(RowDataMissingException, DataException, "Data for row missing")
POCO_IMPLEMENT_EXCEPTION(UnknownDataBaseException, DataException, "Type of data base unknown")
POCO_IMPLEMENT_EXCEPTION(UnknownTypeException, DataException, "Type of data unknown")
POCO_IMPLEMENT_EXCEPTION(ExecutionException, DataException, "Execution error")
POCO_IMPLEMENT_EXCEPTION(BindingException, DataException, "Binding error")
POCO_IMPLEMENT_EXCEPTION(ExtractException, DataException, "Extraction error")
POCO_IMPLEMENT_EXCEPTION(LimitException, DataException, "Limit error")
POCO_IMPLEMENT_EXCEPTION(NotSupportedException, DataException, "Feature or property not supported")
POCO_IMPLEMENT_EXCEPTION(SessionUnavailableException, DataException, "Session is unavailable")
POCO_IMPLEMENT_EXCEPTION(SessionPoolExhaustedException, DataException, "No more sessions available from the session pool")
POCO_IMPLEMENT_EXCEPTION(SessionPoolExistsException, DataException, "Session already exists in the pool")
POCO_IMPLEMENT_EXCEPTION(NoDataException, DataException, "No data found")
POCO_IMPLEMENT_EXCEPTION(LengthExceededException, DataException, "Data too long")
POCO_IMPLEMENT_EXCEPTION(ConnectionFailedException, DataException, "Connection attempt failed")
POCO_IMPLEMENT_EXCEPTION(NotConnectedException, DataException, "Not connected to data source")
} } // namespace Poco::Data

View File

@@ -1,150 +1,150 @@
//
// Date.cpp
//
// $Id: //poco/Main/Data/src/Date.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Date
//
// 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.
//
#include "Poco/Data/Date.h"
#include "Poco/DateTime.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Data/DynamicDateTime.h"
#include "Poco/Dynamic/Var.h"
using Poco::DateTime;
using Poco::Dynamic::Var;
using Poco::NumberFormatter;
namespace Poco {
namespace Data {
Date::Date()
{
DateTime dt;
assign(dt.year(), dt.month(), dt.day());
}
Date::Date(int year, int month, int day)
{
assign(year, month, day);
}
Date::Date(const DateTime& dt)
{
assign(dt.year(), dt.month(), dt.day());
}
Date::~Date()
{
}
void Date::assign(int year, int month, int day)
{
if (year < 0 || year > 9999)
throw InvalidArgumentException("Year must be between 0 and 9999");
if (month < 1 || month > 12)
throw InvalidArgumentException("Month must be between 1 and 12");
if (day < 1 || day > DateTime::daysOfMonth(year, month))
throw InvalidArgumentException("Month must be between 1 and " +
NumberFormatter::format(DateTime::daysOfMonth(year, month)));
_year = year;
_month = month;
_day = day;
}
bool Date::operator < (const Date& date)
{
int year = date.year();
if (_year < year) return true;
else if (_year > year) return false;
else // years equal
{
int month = date.month();
if (_month < month) return true;
else
if (_month > month) return false;
else // months equal
if (_day < date.day()) return true;
}
return false;
}
Date& Date::operator = (const Var& var)
{
*this = var.operator Date(); // g++ workaround
return *this;
}
} } // namespace Poco::Data
namespace Poco {
namespace Dynamic {
using Poco::Data::Date;
using Poco::DateTime;
template <>
Var::operator Date () const
{
if (!_pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(Date) == _pHolder->type())
return extract<Date>();
else
{
Poco::DateTime result;
_pHolder->convert(result);
return Date(result);
}
}
} } // namespace Poco::Dynamic
//
// Date.cpp
//
// $Id: //poco/Main/Data/src/Date.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Date
//
// 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.
//
#include "Poco/Data/Date.h"
#include "Poco/DateTime.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Data/DynamicDateTime.h"
#include "Poco/Dynamic/Var.h"
using Poco::DateTime;
using Poco::Dynamic::Var;
using Poco::NumberFormatter;
namespace Poco {
namespace Data {
Date::Date()
{
DateTime dt;
assign(dt.year(), dt.month(), dt.day());
}
Date::Date(int year, int month, int day)
{
assign(year, month, day);
}
Date::Date(const DateTime& dt)
{
assign(dt.year(), dt.month(), dt.day());
}
Date::~Date()
{
}
void Date::assign(int year, int month, int day)
{
if (year < 0 || year > 9999)
throw InvalidArgumentException("Year must be between 0 and 9999");
if (month < 1 || month > 12)
throw InvalidArgumentException("Month must be between 1 and 12");
if (day < 1 || day > DateTime::daysOfMonth(year, month))
throw InvalidArgumentException("Month must be between 1 and " +
NumberFormatter::format(DateTime::daysOfMonth(year, month)));
_year = year;
_month = month;
_day = day;
}
bool Date::operator < (const Date& date)
{
int year = date.year();
if (_year < year) return true;
else if (_year > year) return false;
else // years equal
{
int month = date.month();
if (_month < month) return true;
else
if (_month > month) return false;
else // months equal
if (_day < date.day()) return true;
}
return false;
}
Date& Date::operator = (const Var& var)
{
*this = var.operator Date(); // g++ workaround
return *this;
}
} } // namespace Poco::Data
namespace Poco {
namespace Dynamic {
using Poco::Data::Date;
using Poco::DateTime;
template <>
Var::operator Date () const
{
if (!_pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(Date) == _pHolder->type())
return extract<Date>();
else
{
Poco::DateTime result;
_pHolder->convert(result);
return Date(result);
}
}
} } // namespace Poco::Dynamic

View File

@@ -1,85 +1,85 @@
//
// DynamicLOB.cpp
//
// $Id: //poco/Main/Data/src/DynamicLOB.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: DynamicLOB
//
// 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.
//
#include "Poco/Data/DynamicLOB.h"
#include "Poco/Data/LOB.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace Dynamic {
using Poco::Data::CLOB;
using Poco::Data::BLOB;
template <>
Var::operator CLOB () const
{
if (!_pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(CLOB) == _pHolder->type())
return extract<CLOB>();
else
{
std::string result;
_pHolder->convert(result);
return CLOB(result);
}
}
template <>
Var::operator BLOB () const
{
if (!_pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(BLOB) == _pHolder->type())
return extract<BLOB>();
else
{
std::string result;
_pHolder->convert(result);
return BLOB(reinterpret_cast<const unsigned char*>(result.data()),
result.size());
}
}
} } // namespace Poco::Data
//
// DynamicLOB.cpp
//
// $Id: //poco/Main/Data/src/DynamicLOB.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: DynamicLOB
//
// 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.
//
#include "Poco/Data/DynamicLOB.h"
#include "Poco/Data/LOB.h"
#include "Poco/Dynamic/Var.h"
namespace Poco {
namespace Dynamic {
using Poco::Data::CLOB;
using Poco::Data::BLOB;
template <>
Var::operator CLOB () const
{
if (!_pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(CLOB) == _pHolder->type())
return extract<CLOB>();
else
{
std::string result;
_pHolder->convert(result);
return CLOB(result);
}
}
template <>
Var::operator BLOB () const
{
if (!_pHolder)
throw InvalidAccessException("Can not convert empty value.");
if (typeid(BLOB) == _pHolder->type())
return extract<BLOB>();
else
{
std::string result;
_pHolder->convert(result);
return BLOB(reinterpret_cast<const unsigned char*>(result.data()),
result.size());
}
}
} } // namespace Poco::Data

View File

@@ -1,57 +1,57 @@
//
// Limit.cpp
//
// $Id: //poco/Main/Data/src/Limit.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Limit
//
// 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.
//
#include "Poco/Data/Limit.h"
namespace Poco {
namespace Data {
Limit::Limit(Poco::UInt32 value, bool hardLimit, bool isLowerLimit):
_value(value),
_hardLimit(hardLimit),
_isLowerLimit(isLowerLimit)
{
}
Limit::~Limit()
{
}
} } // namespace Poco::Data
//
// Limit.cpp
//
// $Id: //poco/Main/Data/src/Limit.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Limit
//
// 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.
//
#include "Poco/Data/Limit.h"
namespace Poco {
namespace Data {
Limit::Limit(Poco::UInt32 value, bool hardLimit, bool isLowerLimit):
_value(value),
_hardLimit(hardLimit),
_isLowerLimit(isLowerLimit)
{
}
Limit::~Limit()
{
}
} } // namespace Poco::Data

View File

@@ -1,70 +1,70 @@
//
// MetaColumn.cpp
//
// $Id: //poco/Main/Data/src/MetaColumn.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: MetaColumn
//
// 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.
//
#include "Poco/Data/MetaColumn.h"
namespace Poco {
namespace Data {
MetaColumn::MetaColumn()
{
}
MetaColumn::MetaColumn(std::size_t position,
const std::string& name,
ColumnDataType type,
std::size_t length,
std::size_t precision,
bool nullable):
_name(name),
_length(length),
_precision(precision),
_position(position),
_type(type),
_nullable(nullable)
{
}
MetaColumn::~MetaColumn()
{
}
} } // namespace Poco::Data
//
// MetaColumn.cpp
//
// $Id: //poco/Main/Data/src/MetaColumn.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: MetaColumn
//
// 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.
//
#include "Poco/Data/MetaColumn.h"
namespace Poco {
namespace Data {
MetaColumn::MetaColumn()
{
}
MetaColumn::MetaColumn(std::size_t position,
const std::string& name,
ColumnDataType type,
std::size_t length,
std::size_t precision,
bool nullable):
_name(name),
_length(length),
_precision(precision),
_position(position),
_type(type),
_nullable(nullable)
{
}
MetaColumn::~MetaColumn()
{
}
} } // namespace Poco::Data

View File

@@ -1,56 +1,56 @@
//
// PooledSessionHolder.cpp
//
// $Id: //poco/Main/Data/src/PooledSessionHolder.cpp#1 $
//
// Library: Data
// Package: SessionPooling
// Module: PooledSessionHolder
//
// 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.
//
#include "Poco/Data/PooledSessionHolder.h"
namespace Poco {
namespace Data {
PooledSessionHolder::PooledSessionHolder(SessionPool& owner, SessionImpl* pSessionImpl):
_owner(owner),
_pImpl(pSessionImpl, true)
{
}
PooledSessionHolder::~PooledSessionHolder()
{
}
} } // namespace Poco::Data
//
// PooledSessionHolder.cpp
//
// $Id: //poco/Main/Data/src/PooledSessionHolder.cpp#1 $
//
// Library: Data
// Package: SessionPooling
// Module: PooledSessionHolder
//
// 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.
//
#include "Poco/Data/PooledSessionHolder.h"
namespace Poco {
namespace Data {
PooledSessionHolder::PooledSessionHolder(SessionPool& owner, SessionImpl* pSessionImpl):
_owner(owner),
_pImpl(pSessionImpl, true)
{
}
PooledSessionHolder::~PooledSessionHolder()
{
}
} } // namespace Poco::Data

View File

@@ -1,207 +1,207 @@
//
// PooledSessionImpl.cpp
//
// $Id: //poco/Main/Data/src/PooledSessionImpl.cpp#3 $
//
// Library: Data
// Package: SessionPooling
// Module: PooledSessionImpl
//
// 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.
//
#include "Poco/Data/PooledSessionImpl.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/SessionPool.h"
namespace Poco {
namespace Data {
PooledSessionImpl::PooledSessionImpl(PooledSessionHolder* pHolder):
SessionImpl(pHolder->session()->connectionString(),
pHolder->session()->getLoginTimeout()),
_pHolder(pHolder, true)
{
}
PooledSessionImpl::~PooledSessionImpl()
{
close();
}
StatementImpl* PooledSessionImpl::createStatementImpl()
{
return access()->createStatementImpl();
}
void PooledSessionImpl::begin()
{
return access()->begin();
}
void PooledSessionImpl::commit()
{
return access()->commit();
}
bool PooledSessionImpl::isConnected()
{
return access()->isConnected();
}
void PooledSessionImpl::setConnectionTimeout(std::size_t timeout)
{
return access()->setConnectionTimeout(timeout);
}
std::size_t PooledSessionImpl::getConnectionTimeout()
{
return access()->getConnectionTimeout();
}
bool PooledSessionImpl::canTransact()
{
return access()->canTransact();
}
bool PooledSessionImpl::isTransaction()
{
return access()->isTransaction();
}
void PooledSessionImpl::setTransactionIsolation(Poco::UInt32 ti)
{
access()->setTransactionIsolation(ti);
}
Poco::UInt32 PooledSessionImpl::getTransactionIsolation()
{
return access()->getTransactionIsolation();
}
bool PooledSessionImpl::hasTransactionIsolation(Poco::UInt32 ti)
{
return access()->hasTransactionIsolation(ti);
}
bool PooledSessionImpl::isTransactionIsolation(Poco::UInt32 ti)
{
return access()->isTransactionIsolation(ti);
}
void PooledSessionImpl::rollback()
{
return access()->rollback();
}
void PooledSessionImpl::open(const std::string& connect)
{
access()->open(connect);
}
void PooledSessionImpl::close()
{
if (_pHolder)
{
if (isTransaction())
{
try
{
rollback();
}
catch (...)
{
// Something's wrong with the session. Get rid of it.
access()->close();
}
}
_pHolder->owner().putBack(_pHolder);
_pHolder = 0;
}
}
const std::string& PooledSessionImpl::connectorName()
{
return access()->connectorName();
}
void PooledSessionImpl::setFeature(const std::string& name, bool state)
{
access()->setFeature(name, state);
}
bool PooledSessionImpl::getFeature(const std::string& name)
{
return access()->getFeature(name);
}
void PooledSessionImpl::setProperty(const std::string& name, const Poco::Any& value)
{
access()->setProperty(name, value);
}
Poco::Any PooledSessionImpl::getProperty(const std::string& name)
{
return access()->getProperty(name);
}
SessionImpl* PooledSessionImpl::access()
{
if (_pHolder)
{
_pHolder->access();
return impl();
}
else throw SessionUnavailableException();
}
} } // namespace Poco::Data
//
// PooledSessionImpl.cpp
//
// $Id: //poco/Main/Data/src/PooledSessionImpl.cpp#3 $
//
// Library: Data
// Package: SessionPooling
// Module: PooledSessionImpl
//
// 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.
//
#include "Poco/Data/PooledSessionImpl.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/SessionPool.h"
namespace Poco {
namespace Data {
PooledSessionImpl::PooledSessionImpl(PooledSessionHolder* pHolder):
SessionImpl(pHolder->session()->connectionString(),
pHolder->session()->getLoginTimeout()),
_pHolder(pHolder, true)
{
}
PooledSessionImpl::~PooledSessionImpl()
{
close();
}
StatementImpl* PooledSessionImpl::createStatementImpl()
{
return access()->createStatementImpl();
}
void PooledSessionImpl::begin()
{
return access()->begin();
}
void PooledSessionImpl::commit()
{
return access()->commit();
}
bool PooledSessionImpl::isConnected()
{
return access()->isConnected();
}
void PooledSessionImpl::setConnectionTimeout(std::size_t timeout)
{
return access()->setConnectionTimeout(timeout);
}
std::size_t PooledSessionImpl::getConnectionTimeout()
{
return access()->getConnectionTimeout();
}
bool PooledSessionImpl::canTransact()
{
return access()->canTransact();
}
bool PooledSessionImpl::isTransaction()
{
return access()->isTransaction();
}
void PooledSessionImpl::setTransactionIsolation(Poco::UInt32 ti)
{
access()->setTransactionIsolation(ti);
}
Poco::UInt32 PooledSessionImpl::getTransactionIsolation()
{
return access()->getTransactionIsolation();
}
bool PooledSessionImpl::hasTransactionIsolation(Poco::UInt32 ti)
{
return access()->hasTransactionIsolation(ti);
}
bool PooledSessionImpl::isTransactionIsolation(Poco::UInt32 ti)
{
return access()->isTransactionIsolation(ti);
}
void PooledSessionImpl::rollback()
{
return access()->rollback();
}
void PooledSessionImpl::open(const std::string& connect)
{
access()->open(connect);
}
void PooledSessionImpl::close()
{
if (_pHolder)
{
if (isTransaction())
{
try
{
rollback();
}
catch (...)
{
// Something's wrong with the session. Get rid of it.
access()->close();
}
}
_pHolder->owner().putBack(_pHolder);
_pHolder = 0;
}
}
const std::string& PooledSessionImpl::connectorName()
{
return access()->connectorName();
}
void PooledSessionImpl::setFeature(const std::string& name, bool state)
{
access()->setFeature(name, state);
}
bool PooledSessionImpl::getFeature(const std::string& name)
{
return access()->getFeature(name);
}
void PooledSessionImpl::setProperty(const std::string& name, const Poco::Any& value)
{
access()->setProperty(name, value);
}
Poco::Any PooledSessionImpl::getProperty(const std::string& name)
{
return access()->getProperty(name);
}
SessionImpl* PooledSessionImpl::access()
{
if (_pHolder)
{
_pHolder->access();
return impl();
}
else throw SessionUnavailableException();
}
} } // namespace Poco::Data

View File

@@ -1,54 +1,54 @@
//
// Position.cpp
//
// $Id: //poco/Main/Data/src/Position.cpp#7 $
//
// Library: Data
// Package: DataCore
// Module: Position
//
// 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.
//
#include "Poco/Data/Position.h"
namespace Poco {
namespace Data {
Position::Position(Poco::UInt32 value): _value(value)
{
}
Position::~Position()
{
}
} } // namespace Poco::Data
//
// Position.cpp
//
// $Id: //poco/Main/Data/src/Position.cpp#7 $
//
// Library: Data
// Package: DataCore
// Module: Position
//
// 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.
//
#include "Poco/Data/Position.h"
namespace Poco {
namespace Data {
Position::Position(Poco::UInt32 value): _value(value)
{
}
Position::~Position()
{
}
} } // namespace Poco::Data

View File

@@ -1,62 +1,62 @@
//
// Range.cpp
//
// $Id: //poco/Main/Data/src/Range.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: Range
//
// 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.
//
#include "Poco/Data/Range.h"
#include "Poco/Data/DataException.h"
namespace Poco {
namespace Data {
using namespace Keywords;
Range::Range(Poco::UInt32 lowValue, Poco::UInt32 upValue, bool hardLimit):
_lower(lowerLimit(lowValue)),
_upper(upperLimit(upValue, hardLimit))
{
if (lowValue > upValue)
throw LimitException("lowerLimit > upperLimit!");
}
Range::~Range()
{
}
} } // namespace Poco::Data
//
// Range.cpp
//
// $Id: //poco/Main/Data/src/Range.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: Range
//
// 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.
//
#include "Poco/Data/Range.h"
#include "Poco/Data/DataException.h"
namespace Poco {
namespace Data {
using namespace Keywords;
Range::Range(Poco::UInt32 lowValue, Poco::UInt32 upValue, bool hardLimit):
_lower(lowerLimit(lowValue)),
_upper(upperLimit(upValue, hardLimit))
{
if (lowValue > upValue)
throw LimitException("lowerLimit > upperLimit!");
}
Range::~Range()
{
}
} } // namespace Poco::Data

View File

@@ -1,390 +1,390 @@
//
// RecordSet.cpp
//
// $Id: //poco/Main/Data/src/RecordSet.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: RecordSet
//
// 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.
//
#include "Poco/Data/RecordSet.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/RowFilter.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Poco/Data/DataException.h"
#include "Poco/DateTime.h"
using namespace Poco::Data::Keywords;
using Poco::DateTime;
namespace Poco {
namespace Data {
const std::size_t RecordSet::UNKNOWN_TOTAL_ROW_COUNT = std::numeric_limits<std::size_t>::max();
RecordSet::RecordSet(const Statement& rStatement,
RowFormatter* pRowFormatter):
Statement(rStatement),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(0),
_totalRowCount(UNKNOWN_TOTAL_ROW_COUNT)
{
if (pRowFormatter) setRowFormatter(pRowFormatter);
}
RecordSet::RecordSet(Session& rSession,
const std::string& query,
RowFormatter* pRowFormatter):
Statement((rSession << query, now)),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(0),
_totalRowCount(UNKNOWN_TOTAL_ROW_COUNT)
{
if (pRowFormatter) setRowFormatter(pRowFormatter);
}
RecordSet::RecordSet(const RecordSet& other):
Statement(other.impl().duplicate()),
_currentRow(other._currentRow),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(other._pFilter),
_totalRowCount(other._totalRowCount)
{
}
RecordSet::~RecordSet()
{
delete _pBegin;
delete _pEnd;
if(_pFilter) _pFilter->release();
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) delete it->second;
}
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(col, row)) return Poco::Dynamic::Var();
switch (columnType(col))
{
case MetaColumn::FDT_BOOL: return value<bool>(col, row, useFilter);
case MetaColumn::FDT_INT8: return value<Int8>(col, row, useFilter);
case MetaColumn::FDT_UINT8: return value<UInt8>(col, row, useFilter);
case MetaColumn::FDT_INT16: return value<Int16>(col, row, useFilter);
case MetaColumn::FDT_UINT16: return value<UInt16>(col, row, useFilter);
case MetaColumn::FDT_INT32: return value<Int32>(col, row, useFilter);
case MetaColumn::FDT_UINT32: return value<UInt32>(col, row, useFilter);
case MetaColumn::FDT_INT64: return value<Int64>(col, row, useFilter);
case MetaColumn::FDT_UINT64: return value<UInt64>(col, row, useFilter);
case MetaColumn::FDT_FLOAT: return value<float>(col, row, useFilter);
case MetaColumn::FDT_DOUBLE: return value<double>(col, row, useFilter);
case MetaColumn::FDT_STRING: return value<std::string>(col, row, useFilter);
case MetaColumn::FDT_BLOB: return value<BLOB>(col, row, useFilter);
case MetaColumn::FDT_CLOB: return value<CLOB>(col, row, useFilter);
case MetaColumn::FDT_DATE: return value<Date>(col, row, useFilter);
case MetaColumn::FDT_TIME: return value<Time>(col, row, useFilter);
case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(col, row);
default:
throw UnknownTypeException("Data type not supported.");
}
}
Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(metaColumn(name).position(), row)) return Poco::Dynamic::Var();
switch (columnType(name))
{
case MetaColumn::FDT_BOOL: return value<bool>(name, row, useFilter);
case MetaColumn::FDT_INT8: return value<Int8>(name, row, useFilter);
case MetaColumn::FDT_UINT8: return value<UInt8>(name, row, useFilter);
case MetaColumn::FDT_INT16: return value<Int16>(name, row, useFilter);
case MetaColumn::FDT_UINT16: return value<UInt16>(name, row, useFilter);
case MetaColumn::FDT_INT32: return value<Int32>(name, row, useFilter);
case MetaColumn::FDT_UINT32: return value<UInt32>(name, row, useFilter);
case MetaColumn::FDT_INT64: return value<Int64>(name, row, useFilter);
case MetaColumn::FDT_UINT64: return value<UInt64>(name, row, useFilter);
case MetaColumn::FDT_FLOAT: return value<float>(name, row, useFilter);
case MetaColumn::FDT_DOUBLE: return value<double>(name, row, useFilter);
case MetaColumn::FDT_STRING: return value<std::string>(name, row, useFilter);
case MetaColumn::FDT_BLOB: return value<BLOB>(name, row, useFilter);
case MetaColumn::FDT_DATE: return value<Date>(name, row, useFilter);
case MetaColumn::FDT_TIME: return value<Time>(name, row, useFilter);
case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(name, row, useFilter);
default:
throw UnknownTypeException("Data type not supported.");
}
}
Row& RecordSet::row(std::size_t pos)
{
std::size_t rowCnt = rowCount();
if (0 == rowCnt || pos > rowCnt - 1)
throw RangeException("Invalid recordset row requested.");
RowMap::const_iterator it = _rowMap.find(pos);
Row* pRow = 0;
std::size_t columns = columnCount();
if (it == _rowMap.end())
{
if (_rowMap.size())
{
//reuse first row column names and sorting fields to save some memory
pRow = new Row(_rowMap.begin()->second->names(),
_rowMap.begin()->second->getSortMap(),
getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->set(col, value(col, pos));
}
else
{
pRow = new Row;
pRow->setFormatter(getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->append(metaColumn(static_cast<UInt32>(col)).name(), value(col, pos));
}
_rowMap.insert(RowMap::value_type(pos, pRow));
}
else
{
pRow = it->second;
poco_check_ptr (pRow);
}
return *pRow;
}
std::size_t RecordSet::rowCount() const
{
poco_assert (extractions().size());
std::size_t rc = subTotalRowCount();
if (!isFiltered()) return rc;
std::size_t counter = 0;
for (int row = 0; row < rc; ++row)
{
if (isAllowed(row)) ++counter;
}
return counter;
}
bool RecordSet::isAllowed(std::size_t row) const
{
if (!isFiltered()) return true;
return _pFilter->isAllowed(row);
}
bool RecordSet::moveFirst()
{
if (subTotalRowCount() > 0)
{
if (!isFiltered())
{
_currentRow = 0;
return true;
}
std::size_t currentRow = _currentRow;
currentRow = 0;
while (!isAllowed(currentRow))
{
if (currentRow >= subTotalRowCount() - 1) return false;
++currentRow;
}
_currentRow = currentRow;
return true;
}
else return false;
}
bool RecordSet::moveNext()
{
std::size_t currentRow = _currentRow;
do
{
if (currentRow >= subTotalRowCount() - 1) return false;
++currentRow;
} while (isFiltered() && !isAllowed(currentRow));
_currentRow = currentRow;
return true;
}
bool RecordSet::movePrevious()
{
std::size_t currentRow = _currentRow;
do
{
if (currentRow <= 0) return false;
--currentRow;
} while (isFiltered() && !isAllowed(currentRow));
_currentRow = currentRow;
return true;
}
bool RecordSet::moveLast()
{
if (subTotalRowCount() > 0)
{
std::size_t currentRow = _currentRow;
currentRow = subTotalRowCount() - 1;
if (!isFiltered())
{
_currentRow = currentRow;
return true;
}
while (!isAllowed(currentRow))
{
if (currentRow <= 0) return false;
--currentRow;
}
_currentRow = currentRow;
return true;
}
else return false;
}
void RecordSet::setRowFormatter(RowFormatter* pRowFormatter)
{
pRowFormatter->setTotalRowCount(getTotalRowCount());
Statement::setRowFormatter(pRowFormatter);
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) it->second->setFormatter(getRowFormatter());
}
std::ostream& RecordSet::copyNames(std::ostream& os) const
{
std::string names = (*_pBegin)->namesToString();
if (!names.empty()) os << names;
return os;
}
std::ostream& RecordSet::copyValues(std::ostream& os, std::size_t offset, std::size_t length) const
{
RowIterator it = *_pBegin + offset;
RowIterator end = (RowIterator::POSITION_END != length) ? it + length : *_pEnd;
std::copy(it, end, std::ostream_iterator<Row>(os));
return os;
}
void RecordSet::formatValues(std::size_t offset, std::size_t length) const
{
RowIterator it = *_pBegin + offset;
RowIterator end = (RowIterator::POSITION_END != length) ? it + length : *_pEnd;
std::string val;
for (; it != end; ++it) it->formatValues();
}
std::ostream& RecordSet::copy(std::ostream& os, std::size_t offset, std::size_t length) const
{
RowFormatter& rf = const_cast<RowFormatter&>((*_pBegin)->getFormatter());
rf.setTotalRowCount(getTotalRowCount());
if (RowFormatter::FORMAT_PROGRESSIVE == rf.getMode())
{
os << rf.prefix();
copyNames(os);
copyValues(os, offset, length);
os << rf.postfix();
}
else
{
formatNames();
formatValues(offset, length);
os << rf.toString();
}
return os;
}
void RecordSet::filter(RowFilter* pFilter)
{
if (_pFilter) _pFilter->release();
_pFilter = pFilter;
if(_pFilter) _pFilter->duplicate();
}
bool RecordSet::isFiltered() const
{
return _pFilter && !_pFilter->isEmpty();
}
void RecordSet::setTotalRowCount(const std::string& sql)
{
session() << sql, into(_totalRowCount), now;
}
} } // namespace Poco::Data
//
// RecordSet.cpp
//
// $Id: //poco/Main/Data/src/RecordSet.cpp#2 $
//
// Library: Data
// Package: DataCore
// Module: RecordSet
//
// 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.
//
#include "Poco/Data/RecordSet.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/RowFilter.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Poco/Data/DataException.h"
#include "Poco/DateTime.h"
using namespace Poco::Data::Keywords;
using Poco::DateTime;
namespace Poco {
namespace Data {
const std::size_t RecordSet::UNKNOWN_TOTAL_ROW_COUNT = std::numeric_limits<std::size_t>::max();
RecordSet::RecordSet(const Statement& rStatement,
RowFormatter* pRowFormatter):
Statement(rStatement),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(0),
_totalRowCount(UNKNOWN_TOTAL_ROW_COUNT)
{
if (pRowFormatter) setRowFormatter(pRowFormatter);
}
RecordSet::RecordSet(Session& rSession,
const std::string& query,
RowFormatter* pRowFormatter):
Statement((rSession << query, now)),
_currentRow(0),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(0),
_totalRowCount(UNKNOWN_TOTAL_ROW_COUNT)
{
if (pRowFormatter) setRowFormatter(pRowFormatter);
}
RecordSet::RecordSet(const RecordSet& other):
Statement(other.impl().duplicate()),
_currentRow(other._currentRow),
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
_pEnd(new RowIterator(this, true)),
_pFilter(other._pFilter),
_totalRowCount(other._totalRowCount)
{
}
RecordSet::~RecordSet()
{
delete _pBegin;
delete _pEnd;
if(_pFilter) _pFilter->release();
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) delete it->second;
}
Poco::Dynamic::Var RecordSet::value(std::size_t col, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(col, row)) return Poco::Dynamic::Var();
switch (columnType(col))
{
case MetaColumn::FDT_BOOL: return value<bool>(col, row, useFilter);
case MetaColumn::FDT_INT8: return value<Int8>(col, row, useFilter);
case MetaColumn::FDT_UINT8: return value<UInt8>(col, row, useFilter);
case MetaColumn::FDT_INT16: return value<Int16>(col, row, useFilter);
case MetaColumn::FDT_UINT16: return value<UInt16>(col, row, useFilter);
case MetaColumn::FDT_INT32: return value<Int32>(col, row, useFilter);
case MetaColumn::FDT_UINT32: return value<UInt32>(col, row, useFilter);
case MetaColumn::FDT_INT64: return value<Int64>(col, row, useFilter);
case MetaColumn::FDT_UINT64: return value<UInt64>(col, row, useFilter);
case MetaColumn::FDT_FLOAT: return value<float>(col, row, useFilter);
case MetaColumn::FDT_DOUBLE: return value<double>(col, row, useFilter);
case MetaColumn::FDT_STRING: return value<std::string>(col, row, useFilter);
case MetaColumn::FDT_BLOB: return value<BLOB>(col, row, useFilter);
case MetaColumn::FDT_CLOB: return value<CLOB>(col, row, useFilter);
case MetaColumn::FDT_DATE: return value<Date>(col, row, useFilter);
case MetaColumn::FDT_TIME: return value<Time>(col, row, useFilter);
case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(col, row);
default:
throw UnknownTypeException("Data type not supported.");
}
}
Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bool useFilter) const
{
if (useFilter && isFiltered() && !isAllowed(row))
throw InvalidAccessException("Row not allowed");
if (isNull(metaColumn(name).position(), row)) return Poco::Dynamic::Var();
switch (columnType(name))
{
case MetaColumn::FDT_BOOL: return value<bool>(name, row, useFilter);
case MetaColumn::FDT_INT8: return value<Int8>(name, row, useFilter);
case MetaColumn::FDT_UINT8: return value<UInt8>(name, row, useFilter);
case MetaColumn::FDT_INT16: return value<Int16>(name, row, useFilter);
case MetaColumn::FDT_UINT16: return value<UInt16>(name, row, useFilter);
case MetaColumn::FDT_INT32: return value<Int32>(name, row, useFilter);
case MetaColumn::FDT_UINT32: return value<UInt32>(name, row, useFilter);
case MetaColumn::FDT_INT64: return value<Int64>(name, row, useFilter);
case MetaColumn::FDT_UINT64: return value<UInt64>(name, row, useFilter);
case MetaColumn::FDT_FLOAT: return value<float>(name, row, useFilter);
case MetaColumn::FDT_DOUBLE: return value<double>(name, row, useFilter);
case MetaColumn::FDT_STRING: return value<std::string>(name, row, useFilter);
case MetaColumn::FDT_BLOB: return value<BLOB>(name, row, useFilter);
case MetaColumn::FDT_DATE: return value<Date>(name, row, useFilter);
case MetaColumn::FDT_TIME: return value<Time>(name, row, useFilter);
case MetaColumn::FDT_TIMESTAMP: return value<DateTime>(name, row, useFilter);
default:
throw UnknownTypeException("Data type not supported.");
}
}
Row& RecordSet::row(std::size_t pos)
{
std::size_t rowCnt = rowCount();
if (0 == rowCnt || pos > rowCnt - 1)
throw RangeException("Invalid recordset row requested.");
RowMap::const_iterator it = _rowMap.find(pos);
Row* pRow = 0;
std::size_t columns = columnCount();
if (it == _rowMap.end())
{
if (_rowMap.size())
{
//reuse first row column names and sorting fields to save some memory
pRow = new Row(_rowMap.begin()->second->names(),
_rowMap.begin()->second->getSortMap(),
getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->set(col, value(col, pos));
}
else
{
pRow = new Row;
pRow->setFormatter(getRowFormatter());
for (std::size_t col = 0; col < columns; ++col)
pRow->append(metaColumn(static_cast<UInt32>(col)).name(), value(col, pos));
}
_rowMap.insert(RowMap::value_type(pos, pRow));
}
else
{
pRow = it->second;
poco_check_ptr (pRow);
}
return *pRow;
}
std::size_t RecordSet::rowCount() const
{
poco_assert (extractions().size());
std::size_t rc = subTotalRowCount();
if (!isFiltered()) return rc;
std::size_t counter = 0;
for (int row = 0; row < rc; ++row)
{
if (isAllowed(row)) ++counter;
}
return counter;
}
bool RecordSet::isAllowed(std::size_t row) const
{
if (!isFiltered()) return true;
return _pFilter->isAllowed(row);
}
bool RecordSet::moveFirst()
{
if (subTotalRowCount() > 0)
{
if (!isFiltered())
{
_currentRow = 0;
return true;
}
std::size_t currentRow = _currentRow;
currentRow = 0;
while (!isAllowed(currentRow))
{
if (currentRow >= subTotalRowCount() - 1) return false;
++currentRow;
}
_currentRow = currentRow;
return true;
}
else return false;
}
bool RecordSet::moveNext()
{
std::size_t currentRow = _currentRow;
do
{
if (currentRow >= subTotalRowCount() - 1) return false;
++currentRow;
} while (isFiltered() && !isAllowed(currentRow));
_currentRow = currentRow;
return true;
}
bool RecordSet::movePrevious()
{
std::size_t currentRow = _currentRow;
do
{
if (currentRow <= 0) return false;
--currentRow;
} while (isFiltered() && !isAllowed(currentRow));
_currentRow = currentRow;
return true;
}
bool RecordSet::moveLast()
{
if (subTotalRowCount() > 0)
{
std::size_t currentRow = _currentRow;
currentRow = subTotalRowCount() - 1;
if (!isFiltered())
{
_currentRow = currentRow;
return true;
}
while (!isAllowed(currentRow))
{
if (currentRow <= 0) return false;
--currentRow;
}
_currentRow = currentRow;
return true;
}
else return false;
}
void RecordSet::setRowFormatter(RowFormatter* pRowFormatter)
{
pRowFormatter->setTotalRowCount(getTotalRowCount());
Statement::setRowFormatter(pRowFormatter);
RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) it->second->setFormatter(getRowFormatter());
}
std::ostream& RecordSet::copyNames(std::ostream& os) const
{
std::string names = (*_pBegin)->namesToString();
if (!names.empty()) os << names;
return os;
}
std::ostream& RecordSet::copyValues(std::ostream& os, std::size_t offset, std::size_t length) const
{
RowIterator it = *_pBegin + offset;
RowIterator end = (RowIterator::POSITION_END != length) ? it + length : *_pEnd;
std::copy(it, end, std::ostream_iterator<Row>(os));
return os;
}
void RecordSet::formatValues(std::size_t offset, std::size_t length) const
{
RowIterator it = *_pBegin + offset;
RowIterator end = (RowIterator::POSITION_END != length) ? it + length : *_pEnd;
std::string val;
for (; it != end; ++it) it->formatValues();
}
std::ostream& RecordSet::copy(std::ostream& os, std::size_t offset, std::size_t length) const
{
RowFormatter& rf = const_cast<RowFormatter&>((*_pBegin)->getFormatter());
rf.setTotalRowCount(getTotalRowCount());
if (RowFormatter::FORMAT_PROGRESSIVE == rf.getMode())
{
os << rf.prefix();
copyNames(os);
copyValues(os, offset, length);
os << rf.postfix();
}
else
{
formatNames();
formatValues(offset, length);
os << rf.toString();
}
return os;
}
void RecordSet::filter(RowFilter* pFilter)
{
if (_pFilter) _pFilter->release();
_pFilter = pFilter;
if(_pFilter) _pFilter->duplicate();
}
bool RecordSet::isFiltered() const
{
return _pFilter && !_pFilter->isEmpty();
}
void RecordSet::setTotalRowCount(const std::string& sql)
{
session() << sql, into(_totalRowCount), now;
}
} } // namespace Poco::Data

View File

@@ -1,410 +1,410 @@
//
// Row.cpp
//
// $Id: //poco/Main/Data/src/Row.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: Row
//
// 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.
//
#include "Poco/Data/Row.h"
#include "Poco/Data/SimpleRowFormatter.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
std::ostream& operator << (std::ostream &os, const Row& row)
{
os << row.valuesToString();
return os;
}
Row::Row():
_pNames(0),
_pSortMap(new SortMap),
_pFormatter(new SimpleRowFormatter)
{
}
Row::Row(NameVecPtr pNames,
const RowFormatterPtr& pFormatter): _pNames(pNames)
{
if (!_pNames) throw NullPointerException();
init(0, pFormatter);
}
Row::Row(NameVecPtr pNames,
const SortMapPtr& pSortMap,
const RowFormatterPtr& pFormatter): _pNames(pNames)
{
if (!_pNames) throw NullPointerException();
init(pSortMap, pFormatter);
}
void Row::init(const SortMapPtr& pSortMap, const RowFormatterPtr& pFormatter)
{
setFormatter(pFormatter);
setSortMap(pSortMap);
NameVec::size_type sz = _pNames->size();
if (sz)
{
_values.resize(sz);
// Row sortability in the strict weak ordering sense is
// an invariant, hence we must start with a zero here.
// If null value is later retrieved from DB, the
// Var::empty() call should be used to empty
// the corresponding Row value.
_values[0] = 0;
addSortField(0);
}
}
Row::~Row()
{
}
Poco::Dynamic::Var& Row::get(std::size_t col)
{
try
{
return _values.at(col);
}catch (std::out_of_range& re)
{
throw RangeException(re.what());
}
}
std::size_t Row::getPosition(const std::string& name)
{
if (!_pNames)
throw NullPointerException();
NameVec::const_iterator it = _pNames->begin();
NameVec::const_iterator end = _pNames->end();
std::size_t col = 0;
for (; it != end; ++it, ++col)
if (0 == icompare(name, *it)) return col;
throw NotFoundException(name);
}
void Row::checkEmpty(std::size_t pos, const Poco::Dynamic::Var& val)
{
bool empty = true;
SortMap::const_iterator it = _pSortMap->begin();
SortMap::const_iterator end = _pSortMap->end();
for (std::size_t cnt = 0; it != end; ++it, ++cnt)
{
if (cnt != pos)
empty = empty && _values[it->get<0>()].isEmpty();
}
if (empty && val.isEmpty())
throw IllegalStateException("All values are empty.");
}
void Row::addSortField(std::size_t pos)
{
poco_assert (pos <= _values.size());
checkEmpty(std::numeric_limits<std::size_t>::max(), _values[pos]);
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == pos) return;
}
ComparisonType ct;
if (_values[pos].isEmpty())
{
ct = COMPARE_AS_EMPTY;
}
else if ((_values[pos].type() == typeid(Poco::Int8)) ||
(_values[pos].type() == typeid(Poco::UInt8)) ||
(_values[pos].type() == typeid(Poco::Int16)) ||
(_values[pos].type() == typeid(Poco::UInt16)) ||
(_values[pos].type() == typeid(Poco::Int32)) ||
(_values[pos].type() == typeid(Poco::UInt32)) ||
(_values[pos].type() == typeid(Poco::Int64)) ||
(_values[pos].type() == typeid(Poco::UInt64)) ||
(_values[pos].type() == typeid(bool)))
{
ct = COMPARE_AS_INTEGER;
}
else if ((_values[pos].type() == typeid(float)) ||
(_values[pos].type() == typeid(double)))
{
ct = COMPARE_AS_FLOAT;
}
else
{
ct = COMPARE_AS_STRING;
}
_pSortMap->push_back(SortTuple(pos, ct));
}
void Row::addSortField(const std::string& name)
{
addSortField(getPosition(name));
}
void Row::removeSortField(std::size_t pos)
{
checkEmpty(pos, Poco::Dynamic::Var());
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == pos)
{
_pSortMap->erase(it);
return;
}
}
}
void Row::removeSortField(const std::string& name)
{
removeSortField(getPosition(name));
}
void Row::replaceSortField(std::size_t oldPos, std::size_t newPos)
{
poco_assert (oldPos <= _values.size());
poco_assert (newPos <= _values.size());
ComparisonType ct;
if (_values[newPos].isEmpty())
{
ct = COMPARE_AS_EMPTY;
}
else if ((_values[newPos].type() == typeid(Poco::Int8)) ||
(_values[newPos].type() == typeid(Poco::UInt8)) ||
(_values[newPos].type() == typeid(Poco::Int16)) ||
(_values[newPos].type() == typeid(Poco::UInt16)) ||
(_values[newPos].type() == typeid(Poco::Int32)) ||
(_values[newPos].type() == typeid(Poco::UInt32)) ||
(_values[newPos].type() == typeid(Poco::Int64)) ||
(_values[newPos].type() == typeid(Poco::UInt64)) ||
(_values[newPos].type() == typeid(bool)))
{
ct = COMPARE_AS_INTEGER;
}
else if ((_values[newPos].type() == typeid(float)) ||
(_values[newPos].type() == typeid(double)))
{
ct = COMPARE_AS_FLOAT;
}
else
{
ct = COMPARE_AS_STRING;
}
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == oldPos)
{
*it = SortTuple(newPos, ct);
return;
}
}
throw NotFoundException("Field not found");
}
void Row::replaceSortField(const std::string& oldName, const std::string& newName)
{
replaceSortField(getPosition(oldName), getPosition(newName));
}
void Row::resetSort()
{
_pSortMap->clear();
if (_values.size()) addSortField(0);
}
bool Row::isEqualSize(const Row& other) const
{
return (other._values.size() == _values.size());
}
bool Row::isEqualType(const Row& other) const
{
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if (it->type() != other._values[i].type())
return false;
}
return true;
}
bool Row::operator == (const Row& other) const
{
if (!isEqualSize(other)) return false;
if (!isEqualType(other)) return false;
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if ((*it).convert<std::string>() != other._values[i].convert<std::string>())
return false;
}
return true;
}
bool Row::operator != (const Row& other) const
{
return !(*this == other);
}
bool Row::operator < (const Row& other) const
{
if (*_pSortMap != *other._pSortMap)
throw InvalidAccessException("Rows compared have different sorting criteria.");
SortMap::const_iterator it = _pSortMap->begin();
SortMap::const_iterator end = _pSortMap->end();
for (; it != end; ++it)
{
switch (it->get<1>())
{
case COMPARE_AS_EMPTY:
return false;
case COMPARE_AS_INTEGER:
if (_values[it->get<0>()].convert<Poco::Int64>() <
other._values[it->get<0>()].convert<Poco::Int64>())
return true;
else if (_values[it->get<0>()].convert<Poco::Int64>() !=
other._values[it->get<0>()].convert<Poco::Int64>())
return false;
break;
case COMPARE_AS_FLOAT:
if (_values[it->get<0>()].convert<double>() <
other._values[it->get<0>()].convert<double>())
return true;
else if (_values[it->get<0>()].convert<double>() !=
other._values[it->get<0>()].convert<double>())
return false;
break;
case COMPARE_AS_STRING:
if (_values[it->get<0>()].convert<std::string>() <
other._values[it->get<0>()].convert<std::string>())
return true;
else if (_values[it->get<0>()].convert<std::string>() !=
other._values[it->get<0>()].convert<std::string>())
return false;
break;
default:
throw IllegalStateException("Unknown comparison criteria.");
}
}
return false;
}
void Row::setFormatter(const RowFormatterPtr& pFormatter)
{
if (pFormatter.get())
_pFormatter = pFormatter;
else
_pFormatter = new SimpleRowFormatter;
}
void Row::setSortMap(const SortMapPtr& pSortMap)
{
if (pSortMap.get())
_pSortMap = pSortMap;
else
_pSortMap = new SortMap;
}
const std::string& Row::namesToString() const
{
if (!_pNames)
throw NullPointerException();
return _pFormatter->formatNames(names(), _nameStr);
}
void Row::formatNames() const
{
if (!_pNames)
throw NullPointerException();
return _pFormatter->formatNames(names());
}
} } // namespace Poco::Data
//
// Row.cpp
//
// $Id: //poco/Main/Data/src/Row.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: Row
//
// 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.
//
#include "Poco/Data/Row.h"
#include "Poco/Data/SimpleRowFormatter.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
std::ostream& operator << (std::ostream &os, const Row& row)
{
os << row.valuesToString();
return os;
}
Row::Row():
_pNames(0),
_pSortMap(new SortMap),
_pFormatter(new SimpleRowFormatter)
{
}
Row::Row(NameVecPtr pNames,
const RowFormatterPtr& pFormatter): _pNames(pNames)
{
if (!_pNames) throw NullPointerException();
init(0, pFormatter);
}
Row::Row(NameVecPtr pNames,
const SortMapPtr& pSortMap,
const RowFormatterPtr& pFormatter): _pNames(pNames)
{
if (!_pNames) throw NullPointerException();
init(pSortMap, pFormatter);
}
void Row::init(const SortMapPtr& pSortMap, const RowFormatterPtr& pFormatter)
{
setFormatter(pFormatter);
setSortMap(pSortMap);
NameVec::size_type sz = _pNames->size();
if (sz)
{
_values.resize(sz);
// Row sortability in the strict weak ordering sense is
// an invariant, hence we must start with a zero here.
// If null value is later retrieved from DB, the
// Var::empty() call should be used to empty
// the corresponding Row value.
_values[0] = 0;
addSortField(0);
}
}
Row::~Row()
{
}
Poco::Dynamic::Var& Row::get(std::size_t col)
{
try
{
return _values.at(col);
}catch (std::out_of_range& re)
{
throw RangeException(re.what());
}
}
std::size_t Row::getPosition(const std::string& name)
{
if (!_pNames)
throw NullPointerException();
NameVec::const_iterator it = _pNames->begin();
NameVec::const_iterator end = _pNames->end();
std::size_t col = 0;
for (; it != end; ++it, ++col)
if (0 == icompare(name, *it)) return col;
throw NotFoundException(name);
}
void Row::checkEmpty(std::size_t pos, const Poco::Dynamic::Var& val)
{
bool empty = true;
SortMap::const_iterator it = _pSortMap->begin();
SortMap::const_iterator end = _pSortMap->end();
for (std::size_t cnt = 0; it != end; ++it, ++cnt)
{
if (cnt != pos)
empty = empty && _values[it->get<0>()].isEmpty();
}
if (empty && val.isEmpty())
throw IllegalStateException("All values are empty.");
}
void Row::addSortField(std::size_t pos)
{
poco_assert (pos <= _values.size());
checkEmpty(std::numeric_limits<std::size_t>::max(), _values[pos]);
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == pos) return;
}
ComparisonType ct;
if (_values[pos].isEmpty())
{
ct = COMPARE_AS_EMPTY;
}
else if ((_values[pos].type() == typeid(Poco::Int8)) ||
(_values[pos].type() == typeid(Poco::UInt8)) ||
(_values[pos].type() == typeid(Poco::Int16)) ||
(_values[pos].type() == typeid(Poco::UInt16)) ||
(_values[pos].type() == typeid(Poco::Int32)) ||
(_values[pos].type() == typeid(Poco::UInt32)) ||
(_values[pos].type() == typeid(Poco::Int64)) ||
(_values[pos].type() == typeid(Poco::UInt64)) ||
(_values[pos].type() == typeid(bool)))
{
ct = COMPARE_AS_INTEGER;
}
else if ((_values[pos].type() == typeid(float)) ||
(_values[pos].type() == typeid(double)))
{
ct = COMPARE_AS_FLOAT;
}
else
{
ct = COMPARE_AS_STRING;
}
_pSortMap->push_back(SortTuple(pos, ct));
}
void Row::addSortField(const std::string& name)
{
addSortField(getPosition(name));
}
void Row::removeSortField(std::size_t pos)
{
checkEmpty(pos, Poco::Dynamic::Var());
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == pos)
{
_pSortMap->erase(it);
return;
}
}
}
void Row::removeSortField(const std::string& name)
{
removeSortField(getPosition(name));
}
void Row::replaceSortField(std::size_t oldPos, std::size_t newPos)
{
poco_assert (oldPos <= _values.size());
poco_assert (newPos <= _values.size());
ComparisonType ct;
if (_values[newPos].isEmpty())
{
ct = COMPARE_AS_EMPTY;
}
else if ((_values[newPos].type() == typeid(Poco::Int8)) ||
(_values[newPos].type() == typeid(Poco::UInt8)) ||
(_values[newPos].type() == typeid(Poco::Int16)) ||
(_values[newPos].type() == typeid(Poco::UInt16)) ||
(_values[newPos].type() == typeid(Poco::Int32)) ||
(_values[newPos].type() == typeid(Poco::UInt32)) ||
(_values[newPos].type() == typeid(Poco::Int64)) ||
(_values[newPos].type() == typeid(Poco::UInt64)) ||
(_values[newPos].type() == typeid(bool)))
{
ct = COMPARE_AS_INTEGER;
}
else if ((_values[newPos].type() == typeid(float)) ||
(_values[newPos].type() == typeid(double)))
{
ct = COMPARE_AS_FLOAT;
}
else
{
ct = COMPARE_AS_STRING;
}
SortMap::iterator it = _pSortMap->begin();
SortMap::iterator end = _pSortMap->end();
for (; it != end; ++it)
{
if (it->get<0>() == oldPos)
{
*it = SortTuple(newPos, ct);
return;
}
}
throw NotFoundException("Field not found");
}
void Row::replaceSortField(const std::string& oldName, const std::string& newName)
{
replaceSortField(getPosition(oldName), getPosition(newName));
}
void Row::resetSort()
{
_pSortMap->clear();
if (_values.size()) addSortField(0);
}
bool Row::isEqualSize(const Row& other) const
{
return (other._values.size() == _values.size());
}
bool Row::isEqualType(const Row& other) const
{
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if (it->type() != other._values[i].type())
return false;
}
return true;
}
bool Row::operator == (const Row& other) const
{
if (!isEqualSize(other)) return false;
if (!isEqualType(other)) return false;
std::vector<Poco::Dynamic::Var>::const_iterator it = _values.begin();
std::vector<Poco::Dynamic::Var>::const_iterator end = _values.end();
for (int i = 0; it != end; ++it, ++i)
{
if ((*it).convert<std::string>() != other._values[i].convert<std::string>())
return false;
}
return true;
}
bool Row::operator != (const Row& other) const
{
return !(*this == other);
}
bool Row::operator < (const Row& other) const
{
if (*_pSortMap != *other._pSortMap)
throw InvalidAccessException("Rows compared have different sorting criteria.");
SortMap::const_iterator it = _pSortMap->begin();
SortMap::const_iterator end = _pSortMap->end();
for (; it != end; ++it)
{
switch (it->get<1>())
{
case COMPARE_AS_EMPTY:
return false;
case COMPARE_AS_INTEGER:
if (_values[it->get<0>()].convert<Poco::Int64>() <
other._values[it->get<0>()].convert<Poco::Int64>())
return true;
else if (_values[it->get<0>()].convert<Poco::Int64>() !=
other._values[it->get<0>()].convert<Poco::Int64>())
return false;
break;
case COMPARE_AS_FLOAT:
if (_values[it->get<0>()].convert<double>() <
other._values[it->get<0>()].convert<double>())
return true;
else if (_values[it->get<0>()].convert<double>() !=
other._values[it->get<0>()].convert<double>())
return false;
break;
case COMPARE_AS_STRING:
if (_values[it->get<0>()].convert<std::string>() <
other._values[it->get<0>()].convert<std::string>())
return true;
else if (_values[it->get<0>()].convert<std::string>() !=
other._values[it->get<0>()].convert<std::string>())
return false;
break;
default:
throw IllegalStateException("Unknown comparison criteria.");
}
}
return false;
}
void Row::setFormatter(const RowFormatterPtr& pFormatter)
{
if (pFormatter.get())
_pFormatter = pFormatter;
else
_pFormatter = new SimpleRowFormatter;
}
void Row::setSortMap(const SortMapPtr& pSortMap)
{
if (pSortMap.get())
_pSortMap = pSortMap;
else
_pSortMap = new SortMap;
}
const std::string& Row::namesToString() const
{
if (!_pNames)
throw NullPointerException();
return _pFormatter->formatNames(names(), _nameStr);
}
void Row::formatNames() const
{
if (!_pNames)
throw NullPointerException();
return _pFormatter->formatNames(names());
}
} } // namespace Poco::Data

View File

@@ -1,230 +1,230 @@
//
// RowFilter.cpp
//
// $Id: //poco/Main/Data/src/RowFilter.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowFilter
//
// 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.
//
#include "Poco/Data/RowFilter.h"
#include "Poco/Data/RecordSet.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include <functional>
namespace Poco {
namespace Data {
RowFilter::RowFilter(RecordSet* pRecordSet): _pRecordSet(pRecordSet), _not(false)
{
poco_check_ptr(pRecordSet);
init();
_pRecordSet->filter(this);
}
RowFilter::RowFilter(Ptr pParent, LogicOperator op): _pRecordSet(0),
_pParent(pParent),
_not(false)
{
poco_check_ptr(_pParent.get());
init();
_pParent->addFilter(this, op);
}
void RowFilter::init()
{
_comparisons.insert(Comparisons::value_type("<", VALUE_LESS_THAN));
_comparisons.insert(Comparisons::value_type("<=", VALUE_LESS_THAN_OR_EQUAL));
_comparisons.insert(Comparisons::value_type("=", VALUE_EQUAL));
_comparisons.insert(Comparisons::value_type("==", VALUE_EQUAL));
_comparisons.insert(Comparisons::value_type(">", VALUE_GREATER_THAN));
_comparisons.insert(Comparisons::value_type(">=", VALUE_GREATER_THAN_OR_EQUAL));
_comparisons.insert(Comparisons::value_type("<>", VALUE_NOT_EQUAL));
_comparisons.insert(Comparisons::value_type("!=", VALUE_NOT_EQUAL));
_comparisons.insert(Comparisons::value_type("IS NULL", VALUE_IS_NULL));
duplicate();
}
RowFilter::~RowFilter()
{
release();
if (_pRecordSet) _pRecordSet->filter(0);
if (_pParent.get()) _pParent->removeFilter(this);
}
bool RowFilter::isAllowed(std::size_t row) const
{
Poco::Dynamic::Var retVal;
const RecordSet& rs = recordSet();
std::size_t columns = rs.columnCount();
ComparisonMap::const_iterator it = _comparisonMap.begin();
ComparisonMap::const_iterator end = _comparisonMap.end();
for (; it != end; ++it)
{
for (std::size_t col = 0; col < columns; ++col)
{
const std::string name = toUpper(rs.metaColumn(static_cast<UInt32>(col)).name());
if (_comparisonMap.find(name) == _comparisonMap.end()) continue;
Poco::Dynamic::Var ret;
CompT compOp = 0;
Poco::Dynamic::Var val = rs.value(col, row, false);
switch (it->second.get<1>())
{
case VALUE_LESS_THAN:
compOp = less; break;
case VALUE_LESS_THAN_OR_EQUAL:
compOp = lessOrEqual; break;
case VALUE_EQUAL:
compOp = equal; break;
case VALUE_GREATER_THAN:
compOp = greater; break;
case VALUE_GREATER_THAN_OR_EQUAL:
compOp = greaterOrEqual; break;
case VALUE_NOT_EQUAL:
compOp = notEqual; break;
case VALUE_IS_NULL:
compOp = isNull; break;
default:
throw IllegalStateException("Unsupported comparison criteria.");
}
doCompare(ret, val, compOp, it->second);
if (retVal.isEmpty()) retVal = ret;
else retVal = retVal || ret;
}
}
// iterate through children
FilterMap::const_iterator fIt = _filterMap.begin();
FilterMap::const_iterator fEnd = _filterMap.end();
for (; fIt != fEnd; ++fIt)
{
if (OP_OR == fIt->second)
{
if (retVal.isEmpty())
retVal = fIt->first->isAllowed(row);
else
retVal = retVal || fIt->first->isAllowed(row);
}
else if (OP_AND == fIt->second)
{
if (retVal.isEmpty())
retVal = fIt->first->isAllowed(row);
else
retVal = retVal && fIt->first->isAllowed(row);
}
else
throw IllegalStateException("Unknown logical operation.");
}
if (retVal.isEmpty()) retVal = true; // no filtering found
return (!_not) && retVal.extract<bool>();
}
int RowFilter::remove(const std::string& name)
{
poco_check_ptr (_pRecordSet);
_pRecordSet->moveFirst();
return static_cast<int>(_comparisonMap.erase(toUpper(name)));
}
RowFilter::Comparison RowFilter::getComparison(const std::string& comp) const
{
Comparisons::const_iterator it = _comparisons.find(toUpper(comp));
if (it == _comparisons.end())
throw NotFoundException("Comparison not found", comp);
return it->second;
}
void RowFilter::addFilter(const Ptr& pFilter, LogicOperator comparison)
{
poco_check_ptr (_pRecordSet);
pFilter->_pRecordSet = _pRecordSet;
_pRecordSet->moveFirst();
_filterMap.insert(FilterMap::value_type(pFilter, comparison));
}
void RowFilter::removeFilter(const Ptr& pFilter)
{
poco_check_ptr (_pRecordSet);
pFilter->_pRecordSet = 0;
_pRecordSet->moveFirst();
_filterMap.erase(pFilter);
}
void RowFilter::doCompare(Poco::Dynamic::Var& ret,
Poco::Dynamic::Var& val,
CompT comp,
const ComparisonEntry& ce)
{
if (ret.isEmpty()) ret = comp(val, ce.get<0>());
else
{
if (ce.get<2>() == OP_OR)
ret = ret || comp(val, ce.get<0>());
else if (ce.get<2>() == OP_AND)
ret = ret && comp(val, ce.get<0>());
else
throw IllegalStateException("Unknown logical operation.");
}
}
RecordSet& RowFilter::recordSet() const
{
if (!_pRecordSet)
{
Ptr pParent = _pParent;
while (pParent && !_pRecordSet)
_pRecordSet = pParent->_pRecordSet;
}
poco_check_ptr (_pRecordSet);
return *_pRecordSet;
}
} } // namespace Poco::Data
//
// RowFilter.cpp
//
// $Id: //poco/Main/Data/src/RowFilter.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowFilter
//
// 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.
//
#include "Poco/Data/RowFilter.h"
#include "Poco/Data/RecordSet.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include <functional>
namespace Poco {
namespace Data {
RowFilter::RowFilter(RecordSet* pRecordSet): _pRecordSet(pRecordSet), _not(false)
{
poco_check_ptr(pRecordSet);
init();
_pRecordSet->filter(this);
}
RowFilter::RowFilter(Ptr pParent, LogicOperator op): _pRecordSet(0),
_pParent(pParent),
_not(false)
{
poco_check_ptr(_pParent.get());
init();
_pParent->addFilter(this, op);
}
void RowFilter::init()
{
_comparisons.insert(Comparisons::value_type("<", VALUE_LESS_THAN));
_comparisons.insert(Comparisons::value_type("<=", VALUE_LESS_THAN_OR_EQUAL));
_comparisons.insert(Comparisons::value_type("=", VALUE_EQUAL));
_comparisons.insert(Comparisons::value_type("==", VALUE_EQUAL));
_comparisons.insert(Comparisons::value_type(">", VALUE_GREATER_THAN));
_comparisons.insert(Comparisons::value_type(">=", VALUE_GREATER_THAN_OR_EQUAL));
_comparisons.insert(Comparisons::value_type("<>", VALUE_NOT_EQUAL));
_comparisons.insert(Comparisons::value_type("!=", VALUE_NOT_EQUAL));
_comparisons.insert(Comparisons::value_type("IS NULL", VALUE_IS_NULL));
duplicate();
}
RowFilter::~RowFilter()
{
release();
if (_pRecordSet) _pRecordSet->filter(0);
if (_pParent.get()) _pParent->removeFilter(this);
}
bool RowFilter::isAllowed(std::size_t row) const
{
Poco::Dynamic::Var retVal;
const RecordSet& rs = recordSet();
std::size_t columns = rs.columnCount();
ComparisonMap::const_iterator it = _comparisonMap.begin();
ComparisonMap::const_iterator end = _comparisonMap.end();
for (; it != end; ++it)
{
for (std::size_t col = 0; col < columns; ++col)
{
const std::string name = toUpper(rs.metaColumn(static_cast<UInt32>(col)).name());
if (_comparisonMap.find(name) == _comparisonMap.end()) continue;
Poco::Dynamic::Var ret;
CompT compOp = 0;
Poco::Dynamic::Var val = rs.value(col, row, false);
switch (it->second.get<1>())
{
case VALUE_LESS_THAN:
compOp = less; break;
case VALUE_LESS_THAN_OR_EQUAL:
compOp = lessOrEqual; break;
case VALUE_EQUAL:
compOp = equal; break;
case VALUE_GREATER_THAN:
compOp = greater; break;
case VALUE_GREATER_THAN_OR_EQUAL:
compOp = greaterOrEqual; break;
case VALUE_NOT_EQUAL:
compOp = notEqual; break;
case VALUE_IS_NULL:
compOp = isNull; break;
default:
throw IllegalStateException("Unsupported comparison criteria.");
}
doCompare(ret, val, compOp, it->second);
if (retVal.isEmpty()) retVal = ret;
else retVal = retVal || ret;
}
}
// iterate through children
FilterMap::const_iterator fIt = _filterMap.begin();
FilterMap::const_iterator fEnd = _filterMap.end();
for (; fIt != fEnd; ++fIt)
{
if (OP_OR == fIt->second)
{
if (retVal.isEmpty())
retVal = fIt->first->isAllowed(row);
else
retVal = retVal || fIt->first->isAllowed(row);
}
else if (OP_AND == fIt->second)
{
if (retVal.isEmpty())
retVal = fIt->first->isAllowed(row);
else
retVal = retVal && fIt->first->isAllowed(row);
}
else
throw IllegalStateException("Unknown logical operation.");
}
if (retVal.isEmpty()) retVal = true; // no filtering found
return (!_not) && retVal.extract<bool>();
}
int RowFilter::remove(const std::string& name)
{
poco_check_ptr (_pRecordSet);
_pRecordSet->moveFirst();
return static_cast<int>(_comparisonMap.erase(toUpper(name)));
}
RowFilter::Comparison RowFilter::getComparison(const std::string& comp) const
{
Comparisons::const_iterator it = _comparisons.find(toUpper(comp));
if (it == _comparisons.end())
throw NotFoundException("Comparison not found", comp);
return it->second;
}
void RowFilter::addFilter(const Ptr& pFilter, LogicOperator comparison)
{
poco_check_ptr (_pRecordSet);
pFilter->_pRecordSet = _pRecordSet;
_pRecordSet->moveFirst();
_filterMap.insert(FilterMap::value_type(pFilter, comparison));
}
void RowFilter::removeFilter(const Ptr& pFilter)
{
poco_check_ptr (_pRecordSet);
pFilter->_pRecordSet = 0;
_pRecordSet->moveFirst();
_filterMap.erase(pFilter);
}
void RowFilter::doCompare(Poco::Dynamic::Var& ret,
Poco::Dynamic::Var& val,
CompT comp,
const ComparisonEntry& ce)
{
if (ret.isEmpty()) ret = comp(val, ce.get<0>());
else
{
if (ce.get<2>() == OP_OR)
ret = ret || comp(val, ce.get<0>());
else if (ce.get<2>() == OP_AND)
ret = ret && comp(val, ce.get<0>());
else
throw IllegalStateException("Unknown logical operation.");
}
}
RecordSet& RowFilter::recordSet() const
{
if (!_pRecordSet)
{
Ptr pParent = _pParent;
while (pParent && !_pRecordSet)
_pRecordSet = pParent->_pRecordSet;
}
poco_check_ptr (_pRecordSet);
return *_pRecordSet;
}
} } // namespace Poco::Data

View File

@@ -1,102 +1,102 @@
//
// RowFormatter.cpp
//
// $Id: //poco/Main/Data/src/RowFormatter.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowFormatter
//
// 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.
//
#include "Poco/Data/RowFormatter.h"
#include "Poco/Exception.h"
#include <iomanip>
namespace Poco {
namespace Data {
RowFormatter::RowFormatter(const std::string& prefix,
const std::string& postfix,
Mode mode):
_prefix(prefix),
_postfix(postfix),
_mode(mode),
_totalRowCount(0)
{
}
RowFormatter::~RowFormatter()
{
}
std::string& RowFormatter::formatNames(const NameVecPtr pNames, std::string& formattedNames)
{
formattedNames.clear();
return formattedNames;
}
void RowFormatter::formatNames(const NameVecPtr pNames)
{
return;
}
std::string& RowFormatter::formatValues(const ValueVec& vals, std::string& formattedValues)
{
formattedValues.clear();
return formattedValues;
}
void RowFormatter::formatValues(const ValueVec& vals)
{
return;
}
const std::string& RowFormatter::toString()
{
throw NotImplementedException("RowFormatter::toString()");
}
void RowFormatter::reset()
{
_prefix = "";
_postfix = "";
_totalRowCount = INVALID_ROW_COUNT;
}
} } // namespace Poco::Data
//
// RowFormatter.cpp
//
// $Id: //poco/Main/Data/src/RowFormatter.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowFormatter
//
// 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.
//
#include "Poco/Data/RowFormatter.h"
#include "Poco/Exception.h"
#include <iomanip>
namespace Poco {
namespace Data {
RowFormatter::RowFormatter(const std::string& prefix,
const std::string& postfix,
Mode mode):
_prefix(prefix),
_postfix(postfix),
_mode(mode),
_totalRowCount(0)
{
}
RowFormatter::~RowFormatter()
{
}
std::string& RowFormatter::formatNames(const NameVecPtr pNames, std::string& formattedNames)
{
formattedNames.clear();
return formattedNames;
}
void RowFormatter::formatNames(const NameVecPtr pNames)
{
return;
}
std::string& RowFormatter::formatValues(const ValueVec& vals, std::string& formattedValues)
{
formattedValues.clear();
return formattedValues;
}
void RowFormatter::formatValues(const ValueVec& vals)
{
return;
}
const std::string& RowFormatter::toString()
{
throw NotImplementedException("RowFormatter::toString()");
}
void RowFormatter::reset()
{
_prefix = "";
_postfix = "";
_totalRowCount = INVALID_ROW_COUNT;
}
} } // namespace Poco::Data

View File

@@ -1,229 +1,229 @@
//
// RowIterator.cpp
//
// $Id: //poco/Main/Data/src/RowIterator.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowIterator
//
// 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.
//
#include "Poco/Data/RowIterator.h"
#include "Poco/Data/RecordSet.h"
#undef min
#undef max
#include <limits>
namespace Poco {
namespace Data {
const int RowIterator::POSITION_END = std::numeric_limits<std::size_t>::max();
RowIterator::RowIterator(RecordSet* pRecordSet, bool positionEnd):
_pRecordSet(pRecordSet),
_position(positionEnd ? POSITION_END : 0)
{
}
RowIterator::RowIterator(const RowIterator& other):
_pRecordSet(other._pRecordSet),
_position(other._position)
{
}
RowIterator::~RowIterator()
{
}
RowIterator& RowIterator::operator = (const RowIterator& other)
{
RowIterator tmp(other);
swap(tmp);
return *this;
}
void RowIterator::swap(RowIterator& other)
{
using std::swap;
swap(_pRecordSet, other._pRecordSet);
swap(_position, other._position);
}
void RowIterator::increment() const
{
if (POSITION_END == _position)
throw RangeException("End of iterator reached.");
if (_position < _pRecordSet->subTotalRowCount() - 1)
++_position;
else
_position = POSITION_END;
if (_pRecordSet->getFilter() && POSITION_END != _position)
{
while (!_pRecordSet->isAllowed(_position))
{
increment();
if (POSITION_END == _position) break;
}
}
}
void RowIterator::decrement() const
{
if (0 == _position)
throw RangeException("Beginning of iterator reached.");
else if (POSITION_END == _position)
_position = _pRecordSet->subTotalRowCount() - 1;
else
--_position;
if (_pRecordSet->getFilter() && 0 != _position)
{
while (!_pRecordSet->isAllowed(_position))
{
decrement();
if (0 == _position) break;
}
}
}
void RowIterator::setPosition(std::size_t pos) const
{
if (_position == pos) return;
if (_pRecordSet->getFilter())
{
std::size_t start = _position;
if (_position > pos)
{
std::size_t end = _position - pos;
for (; start > end; --start)
{
if (pos) --pos;
else throw RangeException("Invalid position argument.");
}
}
else
{
std::size_t end = pos - _position;
for (; start < end; ++start)
{
if (_pRecordSet->subTotalRowCount() != pos) ++pos;
else throw RangeException("Invalid position argument.");
}
}
}
if (pos < _pRecordSet->subTotalRowCount())
_position = pos;
else if (pos == _pRecordSet->subTotalRowCount())
_position = POSITION_END;
else
throw RangeException("Invalid position argument.");
}
Row& RowIterator::operator * () const
{
if (POSITION_END == _position)
throw InvalidAccessException("End of iterator reached.");
return _pRecordSet->row(_position);
}
Row* RowIterator::operator -> () const
{
if (POSITION_END == _position)
throw InvalidAccessException("End of iterator reached.");
return &_pRecordSet->row(_position);
}
const RowIterator& RowIterator::operator ++ () const
{
increment();
return *this;
}
RowIterator RowIterator::operator ++ (int) const
{
RowIterator old(*this);
increment();
return old;
}
const RowIterator& RowIterator::operator -- () const
{
decrement();
return *this;
}
RowIterator RowIterator::operator -- (int) const
{
RowIterator old(*this);
decrement();
return old;
}
RowIterator RowIterator::operator + (std::size_t diff) const
{
RowIterator ri(*this);
ri.setPosition(_position + diff);
return ri;
}
RowIterator RowIterator::operator - (std::size_t diff) const
{
if (diff > _position) throw RangeException("Invalid position argument.");
RowIterator ri(*this);
ri.setPosition(_position - diff);
return ri;
}
} } // namespace Poco::Data
//
// RowIterator.cpp
//
// $Id: //poco/Main/Data/src/RowIterator.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowIterator
//
// 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.
//
#include "Poco/Data/RowIterator.h"
#include "Poco/Data/RecordSet.h"
#undef min
#undef max
#include <limits>
namespace Poco {
namespace Data {
const int RowIterator::POSITION_END = std::numeric_limits<std::size_t>::max();
RowIterator::RowIterator(RecordSet* pRecordSet, bool positionEnd):
_pRecordSet(pRecordSet),
_position(positionEnd ? POSITION_END : 0)
{
}
RowIterator::RowIterator(const RowIterator& other):
_pRecordSet(other._pRecordSet),
_position(other._position)
{
}
RowIterator::~RowIterator()
{
}
RowIterator& RowIterator::operator = (const RowIterator& other)
{
RowIterator tmp(other);
swap(tmp);
return *this;
}
void RowIterator::swap(RowIterator& other)
{
using std::swap;
swap(_pRecordSet, other._pRecordSet);
swap(_position, other._position);
}
void RowIterator::increment() const
{
if (POSITION_END == _position)
throw RangeException("End of iterator reached.");
if (_position < _pRecordSet->subTotalRowCount() - 1)
++_position;
else
_position = POSITION_END;
if (_pRecordSet->getFilter() && POSITION_END != _position)
{
while (!_pRecordSet->isAllowed(_position))
{
increment();
if (POSITION_END == _position) break;
}
}
}
void RowIterator::decrement() const
{
if (0 == _position)
throw RangeException("Beginning of iterator reached.");
else if (POSITION_END == _position)
_position = _pRecordSet->subTotalRowCount() - 1;
else
--_position;
if (_pRecordSet->getFilter() && 0 != _position)
{
while (!_pRecordSet->isAllowed(_position))
{
decrement();
if (0 == _position) break;
}
}
}
void RowIterator::setPosition(std::size_t pos) const
{
if (_position == pos) return;
if (_pRecordSet->getFilter())
{
std::size_t start = _position;
if (_position > pos)
{
std::size_t end = _position - pos;
for (; start > end; --start)
{
if (pos) --pos;
else throw RangeException("Invalid position argument.");
}
}
else
{
std::size_t end = pos - _position;
for (; start < end; ++start)
{
if (_pRecordSet->subTotalRowCount() != pos) ++pos;
else throw RangeException("Invalid position argument.");
}
}
}
if (pos < _pRecordSet->subTotalRowCount())
_position = pos;
else if (pos == _pRecordSet->subTotalRowCount())
_position = POSITION_END;
else
throw RangeException("Invalid position argument.");
}
Row& RowIterator::operator * () const
{
if (POSITION_END == _position)
throw InvalidAccessException("End of iterator reached.");
return _pRecordSet->row(_position);
}
Row* RowIterator::operator -> () const
{
if (POSITION_END == _position)
throw InvalidAccessException("End of iterator reached.");
return &_pRecordSet->row(_position);
}
const RowIterator& RowIterator::operator ++ () const
{
increment();
return *this;
}
RowIterator RowIterator::operator ++ (int) const
{
RowIterator old(*this);
increment();
return old;
}
const RowIterator& RowIterator::operator -- () const
{
decrement();
return *this;
}
RowIterator RowIterator::operator -- (int) const
{
RowIterator old(*this);
decrement();
return old;
}
RowIterator RowIterator::operator + (std::size_t diff) const
{
RowIterator ri(*this);
ri.setPosition(_position + diff);
return ri;
}
RowIterator RowIterator::operator - (std::size_t diff) const
{
if (diff > _position) throw RangeException("Invalid position argument.");
RowIterator ri(*this);
ri.setPosition(_position - diff);
return ri;
}
} } // namespace Poco::Data

View File

@@ -1,306 +1,306 @@
//
// SQLChannel.cpp
//
// $Id: //poco/Main/Data/src/SQLChannel.cpp#3 $
//
// Library: Net
// Package: Logging
// Module: SQLChannel
//
// 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.
//
#include "Poco/Data/SQLChannel.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/DateTime.h"
#include "Poco/LoggingFactory.h"
#include "Poco/Instantiator.h"
#include "Poco/NumberParser.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Format.h"
namespace Poco {
namespace Data {
using namespace Keywords;
const std::string SQLChannel::PROP_CONNECTOR("connector");
const std::string SQLChannel::PROP_CONNECT("connect");
const std::string SQLChannel::PROP_NAME("name");
const std::string SQLChannel::PROP_TABLE("table");
const std::string SQLChannel::PROP_ARCHIVE_TABLE("archive");
const std::string SQLChannel::PROP_MAX_AGE("keep");
const std::string SQLChannel::PROP_ASYNC("async");
const std::string SQLChannel::PROP_TIMEOUT("timeout");
const std::string SQLChannel::PROP_THROW("throw");
SQLChannel::SQLChannel():
_name("-"),
_table("T_POCO_LOG"),
_timeout(1000),
_throw(true),
_async(true)
{
}
SQLChannel::SQLChannel(const std::string& connector,
const std::string& connect,
const std::string& name):
_connector(connector),
_connect(connect),
_name(name),
_table("T_POCO_LOG"),
_timeout(1000),
_throw(true),
_async(true)
{
open();
}
SQLChannel::~SQLChannel()
{
close();
}
void SQLChannel::open()
{
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
_pSession = new Session(_connector, _connect);
initLogStatement();
}
void SQLChannel::close()
{
wait();
}
void SQLChannel::log(const Message& msg)
{
if (_async) logAsync(msg);
else logSync(msg);
}
void SQLChannel::logAsync(const Message& msg)
{
if (!_pSession || !_pSession->isConnected()) open();
std::size_t ret = wait();
if (0 == ret && !_pLogStatement->done() && !_pLogStatement->initialized())
{
if (_throw)
throw TimeoutException("Timed out waiting for previous statement completion");
else return;
}
logSync(msg);
}
void SQLChannel::logSync(const Message& msg)
{
if (_pArchiveStrategy) _pArchiveStrategy->archive();
_source = msg.getSource();
_pid = msg.getPid();
_thread = msg.getThread();
_tid = msg.getTid();
_priority = msg.getPriority();
_text = msg.getText();
_dateTime = msg.getTime();
if (_source.empty()) _source = _name;
try
{
_pLogStatement->execute();
}
catch (Exception&)
{
if (_throw) throw;
}
}
void SQLChannel::setProperty(const std::string& name, const std::string& value)
{
if (name == PROP_NAME)
{
_name = value;
if (_name.empty()) _name = "-";
}
else if (name == PROP_CONNECTOR)
{
_connector = value;
close(); open();
}
else if (name == PROP_CONNECT)
{
_connect = value;
close(); open();
}
else if (name == PROP_TABLE)
{
_table = value;
initLogStatement();
}
else if (name == PROP_ARCHIVE_TABLE)
{
if (value.empty())
{
_pArchiveStrategy = 0;
}
else if (_pArchiveStrategy)
{
_pArchiveStrategy->setDestination(value);
}
else
{
_pArchiveStrategy = new ArchiveByAgeStrategy(_connector, _connect, _table, value);
}
}
else if (name == PROP_MAX_AGE)
{
if (value.empty() || "forever" == value)
{
_pArchiveStrategy = 0;
}
else if (_pArchiveStrategy)
{
_pArchiveStrategy->setThreshold(value);
}
else
{
ArchiveByAgeStrategy* p = new ArchiveByAgeStrategy(_connector, _connect, _table);
p->setThreshold(value);
_pArchiveStrategy = p;
}
}
else if (name == PROP_ASYNC)
{
_async = isTrue(value);
initLogStatement();
}
else if (name == PROP_TIMEOUT)
{
if (value.empty() || '0' == value[0])
_timeout = Statement::WAIT_FOREVER;
else
_timeout = NumberParser::parse(value);
}
else if (name == PROP_THROW)
{
_throw = isTrue(value);
}
else
{
Channel::setProperty(name, value);
}
}
std::string SQLChannel::getProperty(const std::string& name) const
{
if (name == PROP_NAME)
{
if (_name != "-") return _name;
else return "";
}
else if (name == PROP_CONNECTOR)
{
return _connector;
}
else if (name == PROP_CONNECT)
{
return _connect;
}
else if (name == PROP_TABLE)
{
return _table;
}
else if (name == PROP_ARCHIVE_TABLE)
{
return _pArchiveStrategy ? _pArchiveStrategy->getDestination() : "" ;
}
else if (name == PROP_MAX_AGE)
{
return _pArchiveStrategy ? _pArchiveStrategy->getThreshold() : "forever";
}
else if (name == PROP_TIMEOUT)
{
return NumberFormatter::format(_timeout);
}
else if (name == PROP_THROW)
{
if (_throw) return "true";
else return "false";
}
else
{
return Channel::getProperty(name);
}
}
void SQLChannel::initLogStatement()
{
_pLogStatement = new Statement(*_pSession);
std::string sql;
Poco::format(sql, "INSERT INTO %s VALUES (?,?,?,?,?,?,?,?)", _table);
*_pLogStatement << sql,
use(_source),
use(_name),
use(_pid),
use(_thread),
use(_tid),
use(_priority),
use(_text),
use(_dateTime);
if (_async) _pLogStatement->setAsync();
}
void SQLChannel::registerChannel()
{
Poco::LoggingFactory::defaultFactory().registerChannelClass("SQLChannel",
new Poco::Instantiator<SQLChannel, Poco::Channel>);
}
} } // namespace Poco::Data
//
// SQLChannel.cpp
//
// $Id: //poco/Main/Data/src/SQLChannel.cpp#3 $
//
// Library: Net
// Package: Logging
// Module: SQLChannel
//
// 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.
//
#include "Poco/Data/SQLChannel.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/DateTime.h"
#include "Poco/LoggingFactory.h"
#include "Poco/Instantiator.h"
#include "Poco/NumberParser.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Format.h"
namespace Poco {
namespace Data {
using namespace Keywords;
const std::string SQLChannel::PROP_CONNECTOR("connector");
const std::string SQLChannel::PROP_CONNECT("connect");
const std::string SQLChannel::PROP_NAME("name");
const std::string SQLChannel::PROP_TABLE("table");
const std::string SQLChannel::PROP_ARCHIVE_TABLE("archive");
const std::string SQLChannel::PROP_MAX_AGE("keep");
const std::string SQLChannel::PROP_ASYNC("async");
const std::string SQLChannel::PROP_TIMEOUT("timeout");
const std::string SQLChannel::PROP_THROW("throw");
SQLChannel::SQLChannel():
_name("-"),
_table("T_POCO_LOG"),
_timeout(1000),
_throw(true),
_async(true)
{
}
SQLChannel::SQLChannel(const std::string& connector,
const std::string& connect,
const std::string& name):
_connector(connector),
_connect(connect),
_name(name),
_table("T_POCO_LOG"),
_timeout(1000),
_throw(true),
_async(true)
{
open();
}
SQLChannel::~SQLChannel()
{
close();
}
void SQLChannel::open()
{
if (_connector.empty() || _connect.empty())
throw IllegalStateException("Connector and connect string must be non-empty.");
_pSession = new Session(_connector, _connect);
initLogStatement();
}
void SQLChannel::close()
{
wait();
}
void SQLChannel::log(const Message& msg)
{
if (_async) logAsync(msg);
else logSync(msg);
}
void SQLChannel::logAsync(const Message& msg)
{
if (!_pSession || !_pSession->isConnected()) open();
std::size_t ret = wait();
if (0 == ret && !_pLogStatement->done() && !_pLogStatement->initialized())
{
if (_throw)
throw TimeoutException("Timed out waiting for previous statement completion");
else return;
}
logSync(msg);
}
void SQLChannel::logSync(const Message& msg)
{
if (_pArchiveStrategy) _pArchiveStrategy->archive();
_source = msg.getSource();
_pid = msg.getPid();
_thread = msg.getThread();
_tid = msg.getTid();
_priority = msg.getPriority();
_text = msg.getText();
_dateTime = msg.getTime();
if (_source.empty()) _source = _name;
try
{
_pLogStatement->execute();
}
catch (Exception&)
{
if (_throw) throw;
}
}
void SQLChannel::setProperty(const std::string& name, const std::string& value)
{
if (name == PROP_NAME)
{
_name = value;
if (_name.empty()) _name = "-";
}
else if (name == PROP_CONNECTOR)
{
_connector = value;
close(); open();
}
else if (name == PROP_CONNECT)
{
_connect = value;
close(); open();
}
else if (name == PROP_TABLE)
{
_table = value;
initLogStatement();
}
else if (name == PROP_ARCHIVE_TABLE)
{
if (value.empty())
{
_pArchiveStrategy = 0;
}
else if (_pArchiveStrategy)
{
_pArchiveStrategy->setDestination(value);
}
else
{
_pArchiveStrategy = new ArchiveByAgeStrategy(_connector, _connect, _table, value);
}
}
else if (name == PROP_MAX_AGE)
{
if (value.empty() || "forever" == value)
{
_pArchiveStrategy = 0;
}
else if (_pArchiveStrategy)
{
_pArchiveStrategy->setThreshold(value);
}
else
{
ArchiveByAgeStrategy* p = new ArchiveByAgeStrategy(_connector, _connect, _table);
p->setThreshold(value);
_pArchiveStrategy = p;
}
}
else if (name == PROP_ASYNC)
{
_async = isTrue(value);
initLogStatement();
}
else if (name == PROP_TIMEOUT)
{
if (value.empty() || '0' == value[0])
_timeout = Statement::WAIT_FOREVER;
else
_timeout = NumberParser::parse(value);
}
else if (name == PROP_THROW)
{
_throw = isTrue(value);
}
else
{
Channel::setProperty(name, value);
}
}
std::string SQLChannel::getProperty(const std::string& name) const
{
if (name == PROP_NAME)
{
if (_name != "-") return _name;
else return "";
}
else if (name == PROP_CONNECTOR)
{
return _connector;
}
else if (name == PROP_CONNECT)
{
return _connect;
}
else if (name == PROP_TABLE)
{
return _table;
}
else if (name == PROP_ARCHIVE_TABLE)
{
return _pArchiveStrategy ? _pArchiveStrategy->getDestination() : "" ;
}
else if (name == PROP_MAX_AGE)
{
return _pArchiveStrategy ? _pArchiveStrategy->getThreshold() : "forever";
}
else if (name == PROP_TIMEOUT)
{
return NumberFormatter::format(_timeout);
}
else if (name == PROP_THROW)
{
if (_throw) return "true";
else return "false";
}
else
{
return Channel::getProperty(name);
}
}
void SQLChannel::initLogStatement()
{
_pLogStatement = new Statement(*_pSession);
std::string sql;
Poco::format(sql, "INSERT INTO %s VALUES (?,?,?,?,?,?,?,?)", _table);
*_pLogStatement << sql,
use(_source),
use(_name),
use(_pid),
use(_thread),
use(_tid),
use(_priority),
use(_text),
use(_dateTime);
if (_async) _pLogStatement->setAsync();
}
void SQLChannel::registerChannel()
{
Poco::LoggingFactory::defaultFactory().registerChannelClass("SQLChannel",
new Poco::Instantiator<SQLChannel, Poco::Channel>);
}
} } // namespace Poco::Data

View File

@@ -1,100 +1,100 @@
//
// Session.cpp
//
// $Id: //poco/Main/Data/src/Session.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Session
//
// 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.
//
#include "Poco/Data/Session.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/String.h"
#include "Poco/URI.h"
#include <algorithm>
namespace Poco {
namespace Data {
Session::Session(Poco::AutoPtr<SessionImpl> pImpl):
_pImpl(pImpl),
_statementCreator(pImpl)
{
poco_check_ptr (pImpl.get());
}
Session::Session(const std::string& connector,
const std::string& connectionString,
std::size_t timeout)
{
Session newSession(SessionFactory::instance().create(connector, connectionString, timeout));
swap(newSession);
}
Session::Session(const std::string& connection,
std::size_t timeout)
{
Session newSession(SessionFactory::instance().create(connection, timeout));
swap(newSession);
}
Session::Session(const Session& other): _pImpl(other._pImpl),
_statementCreator(other._pImpl)
{
}
Session::~Session()
{
}
Session& Session::operator = (const Session& other)
{
Session tmp(other);
swap(tmp);
return *this;
}
void Session::swap(Session& other)
{
using std::swap;
swap(_statementCreator, other._statementCreator);
swap(_pImpl, other._pImpl);
}
} } // namespace Poco::Data
//
// Session.cpp
//
// $Id: //poco/Main/Data/src/Session.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Session
//
// 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.
//
#include "Poco/Data/Session.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/String.h"
#include "Poco/URI.h"
#include <algorithm>
namespace Poco {
namespace Data {
Session::Session(Poco::AutoPtr<SessionImpl> pImpl):
_pImpl(pImpl),
_statementCreator(pImpl)
{
poco_check_ptr (pImpl.get());
}
Session::Session(const std::string& connector,
const std::string& connectionString,
std::size_t timeout)
{
Session newSession(SessionFactory::instance().create(connector, connectionString, timeout));
swap(newSession);
}
Session::Session(const std::string& connection,
std::size_t timeout)
{
Session newSession(SessionFactory::instance().create(connection, timeout));
swap(newSession);
}
Session::Session(const Session& other): _pImpl(other._pImpl),
_statementCreator(other._pImpl)
{
}
Session::~Session()
{
}
Session& Session::operator = (const Session& other)
{
Session tmp(other);
swap(tmp);
return *this;
}
void Session::swap(Session& other)
{
using std::swap;
swap(_statementCreator, other._statementCreator);
swap(_pImpl, other._pImpl);
}
} } // namespace Poco::Data

View File

@@ -1,112 +1,112 @@
//
// SessionFactory.cpp
//
// $Id: //poco/Main/Data/src/SessionFactory.cpp#6 $
//
// Library: Data
// Package: DataCore
// Module: SessionFactory
//
// 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.
//
#include "Poco/Data/SessionFactory.h"
#include "Poco/URI.h"
#include "Poco/String.h"
namespace Poco {
namespace Data {
SessionFactory::SessionFactory()
{
}
SessionFactory::~SessionFactory()
{
}
SessionFactory& SessionFactory::instance()
{
static SessionFactory sf;
return sf;
}
void SessionFactory::add(Connector* pIn)
{
Poco::FastMutex::ScopedLock lock(_mutex);
SessionInfo info(pIn);
std::pair<Connectors::iterator, bool> res =
_connectors.insert(std::make_pair(toLower(pIn->name()), info));
if (!res.second) res.first->second.cnt++;
}
void SessionFactory::remove(const std::string& key)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Connectors::iterator it = _connectors.find(toLower(key));
poco_assert (_connectors.end() != it);
--(it->second.cnt);
if (it->second.cnt == 0) _connectors.erase(it);
}
Session SessionFactory::create(const std::string& key,
const std::string& connectionString,
std::size_t timeout)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Connectors::iterator it = _connectors.find(toLower(key));
poco_assert (_connectors.end() != it);
return Session(it->second.ptrSI->createSession(connectionString, timeout));
}
Session SessionFactory::create(const std::string& uri,
std::size_t timeout)
{
URI u(uri);
poco_assert (!u.getPath().empty());
return create(u.getScheme(), u.getPath().substr(1), timeout);
}
SessionFactory::SessionInfo::SessionInfo(Connector* pSI):
cnt(1),
ptrSI(pSI)
{
}
} } // namespace Poco::Data
//
// SessionFactory.cpp
//
// $Id: //poco/Main/Data/src/SessionFactory.cpp#6 $
//
// Library: Data
// Package: DataCore
// Module: SessionFactory
//
// 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.
//
#include "Poco/Data/SessionFactory.h"
#include "Poco/URI.h"
#include "Poco/String.h"
namespace Poco {
namespace Data {
SessionFactory::SessionFactory()
{
}
SessionFactory::~SessionFactory()
{
}
SessionFactory& SessionFactory::instance()
{
static SessionFactory sf;
return sf;
}
void SessionFactory::add(Connector* pIn)
{
Poco::FastMutex::ScopedLock lock(_mutex);
SessionInfo info(pIn);
std::pair<Connectors::iterator, bool> res =
_connectors.insert(std::make_pair(toLower(pIn->name()), info));
if (!res.second) res.first->second.cnt++;
}
void SessionFactory::remove(const std::string& key)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Connectors::iterator it = _connectors.find(toLower(key));
poco_assert (_connectors.end() != it);
--(it->second.cnt);
if (it->second.cnt == 0) _connectors.erase(it);
}
Session SessionFactory::create(const std::string& key,
const std::string& connectionString,
std::size_t timeout)
{
Poco::FastMutex::ScopedLock lock(_mutex);
Connectors::iterator it = _connectors.find(toLower(key));
poco_assert (_connectors.end() != it);
return Session(it->second.ptrSI->createSession(connectionString, timeout));
}
Session SessionFactory::create(const std::string& uri,
std::size_t timeout)
{
URI u(uri);
poco_assert (!u.getPath().empty());
return create(u.getScheme(), u.getPath().substr(1), timeout);
}
SessionFactory::SessionInfo::SessionInfo(Connector* pSI):
cnt(1),
ptrSI(pSI)
{
}
} } // namespace Poco::Data

View File

@@ -1,74 +1,74 @@
//
// SessionImpl.cpp
//
// $Id: //poco/Main/Data/src/SessionImpl.cpp#3 $
//
// Library: Data
// Package: DataCore
// Module: SessionImpl
//
// 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.
//
#include "Poco/Data/SessionImpl.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
SessionImpl::SessionImpl(const std::string& connectionString, std::size_t timeout):
_connectionString(connectionString),
_loginTimeout(timeout)
{
}
SessionImpl::~SessionImpl()
{
}
void SessionImpl::reconnect()
{
close();
open();
}
void SessionImpl::setConnectionString(const std::string& connectionString)
{
if (isConnected())
throw Poco::InvalidAccessException("Can not change connection string on connected session."
" Close the session first.");
_connectionString = connectionString;
}
} } // namespace Poco::Data
//
// SessionImpl.cpp
//
// $Id: //poco/Main/Data/src/SessionImpl.cpp#3 $
//
// Library: Data
// Package: DataCore
// Module: SessionImpl
//
// 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.
//
#include "Poco/Data/SessionImpl.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
SessionImpl::SessionImpl(const std::string& connectionString, std::size_t timeout):
_connectionString(connectionString),
_loginTimeout(timeout)
{
}
SessionImpl::~SessionImpl()
{
}
void SessionImpl::reconnect()
{
close();
open();
}
void SessionImpl::setConnectionString(const std::string& connectionString)
{
if (isConnected())
throw Poco::InvalidAccessException("Can not change connection string on connected session."
" Close the session first.");
_connectionString = connectionString;
}
} } // namespace Poco::Data

View File

@@ -1,317 +1,317 @@
//
// SessionPool.cpp
//
// $Id: //poco/Main/Data/src/SessionPool.cpp#3 $
//
// Library: Data
// Package: SessionPooling
// Module: SessionPool
//
// 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.
//
#include "Poco/Data/SessionPool.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/DataException.h"
#include <algorithm>
namespace Poco {
namespace Data {
SessionPool::SessionPool(const std::string& connector, const std::string& connectionString, int minSessions, int maxSessions, int idleTime):
_connector(connector),
_connectionString(connectionString),
_minSessions(minSessions),
_maxSessions(maxSessions),
_idleTime(idleTime),
_nSessions(0),
_janitorTimer(1000*idleTime, 1000*idleTime/4),
_shutdown(false)
{
Poco::TimerCallback<SessionPool> callback(*this, &SessionPool::onJanitorTimer);
_janitorTimer.start(callback);
}
SessionPool::~SessionPool()
{
shutdown();
}
Session SessionPool::get(const std::string& name, bool value)
{
Session s = get();
_addFeatureMap.insert(AddFeatureMap::value_type(s.impl(),
std::make_pair(name, s.getFeature(name))));
s.setFeature(name, value);
return s;
}
Session SessionPool::get()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
purgeDeadSessions();
if (_idleSessions.empty())
{
if (_nSessions < _maxSessions)
{
Session newSession(SessionFactory::instance().create(_connector, _connectionString));
applySettings(newSession.impl());
PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl()));
_idleSessions.push_front(pHolder);
++_nSessions;
}
else throw SessionPoolExhaustedException(_connector, _connectionString);
}
PooledSessionHolderPtr pHolder(_idleSessions.front());
PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder));
_activeSessions.push_front(pHolder);
_idleSessions.pop_front();
return Session(pPSI);
}
void SessionPool::purgeDeadSessions()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
for (; it != _idleSessions.end(); )
{
if (!(*it)->session()->isConnected())
{
it = _idleSessions.erase(it);
--_nSessions;
}
else ++it;
}
}
int SessionPool::capacity() const
{
return _maxSessions;
}
int SessionPool::used() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _activeSessions.size();
}
int SessionPool::idle() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _idleSessions.size();
}
int SessionPool::dead()
{
Poco::Mutex::ScopedLock lock(_mutex);
int count = 0;
SessionList::iterator it = _activeSessions.begin();
SessionList::iterator itEnd = _activeSessions.end();
for (; it != itEnd; ++it)
{
if (!(*it)->session()->isConnected())
++count;
}
return count;
}
int SessionPool::allocated() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return _nSessions;
}
int SessionPool::available() const
{
if (_shutdown) return 0;
return _maxSessions - used();
}
void SessionPool::setFeature(const std::string& name, bool state)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_nSessions > 0)
throw InvalidAccessException("Features can not be set after the first session was created.");
_featureMap.insert(FeatureMap::ValueType(name, state));
}
bool SessionPool::getFeature(const std::string& name)
{
FeatureMap::ConstIterator it = _featureMap.find(name);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_featureMap.end() == it)
throw NotFoundException("Feature not found:" + name);
return it->second;
}
void SessionPool::setProperty(const std::string& name, const Poco::Any& value)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_nSessions > 0)
throw InvalidAccessException("Properties can not be set after first session was created.");
_propertyMap.insert(PropertyMap::ValueType(name, value));
}
Poco::Any SessionPool::getProperty(const std::string& name)
{
PropertyMap::ConstIterator it = _propertyMap.find(name);
if (_propertyMap.end() == it)
throw NotFoundException("Property not found:" + name);
return it->second;
}
void SessionPool::applySettings(SessionImpl* pImpl)
{
FeatureMap::Iterator fmIt = _featureMap.begin();
FeatureMap::Iterator fmEnd = _featureMap.end();
for (; fmIt != fmEnd; ++fmIt) pImpl->setFeature(fmIt->first, fmIt->second);
PropertyMap::Iterator pmIt = _propertyMap.begin();
PropertyMap::Iterator pmEnd = _propertyMap.end();
for (; pmIt != pmEnd; ++pmIt) pImpl->setProperty(pmIt->first, pmIt->second);
}
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
if (it != _activeSessions.end())
{
if (pHolder->session()->isConnected())
{
// reverse settings applied at acquisition time, if any
AddPropertyMap::iterator pIt = _addPropertyMap.find(pHolder->session());
if (pIt != _addPropertyMap.end())
pHolder->session()->setProperty(pIt->second.first, pIt->second.second);
AddFeatureMap::iterator fIt = _addFeatureMap.find(pHolder->session());
if (fIt != _addFeatureMap.end())
pHolder->session()->setFeature(fIt->second.first, fIt->second.second);
// re-apply the default pool settings
applySettings(pHolder->session());
pHolder->access();
_idleSessions.push_front(pHolder);
}
else --_nSessions;
_activeSessions.erase(it);
}
else
{
poco_bugcheck_msg("Unknown session passed to SessionPool::putBack()");
}
}
void SessionPool::onJanitorTimer(Poco::Timer&)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
while (_nSessions > _minSessions && it != _idleSessions.end())
{
if ((*it)->idle() > _idleTime || !(*it)->session()->isConnected())
{
try { (*it)->session()->close(); }
catch (...) { }
it = _idleSessions.erase(it);
--_nSessions;
}
else ++it;
}
}
void SessionPool::shutdown()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
_shutdown = true;
_janitorTimer.stop();
closeAll(_idleSessions);
closeAll(_activeSessions);
}
void SessionPool::closeAll(SessionList& sessionList)
{
SessionList::iterator it = sessionList.begin();
for (; it != sessionList.end();)
{
try { (*it)->session()->close(); }
catch (...) { }
it = sessionList.erase(it);
if (_nSessions > 0) --_nSessions;
}
}
} } // namespace Poco::Data
//
// SessionPool.cpp
//
// $Id: //poco/Main/Data/src/SessionPool.cpp#3 $
//
// Library: Data
// Package: SessionPooling
// Module: SessionPool
//
// 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.
//
#include "Poco/Data/SessionPool.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/DataException.h"
#include <algorithm>
namespace Poco {
namespace Data {
SessionPool::SessionPool(const std::string& connector, const std::string& connectionString, int minSessions, int maxSessions, int idleTime):
_connector(connector),
_connectionString(connectionString),
_minSessions(minSessions),
_maxSessions(maxSessions),
_idleTime(idleTime),
_nSessions(0),
_janitorTimer(1000*idleTime, 1000*idleTime/4),
_shutdown(false)
{
Poco::TimerCallback<SessionPool> callback(*this, &SessionPool::onJanitorTimer);
_janitorTimer.start(callback);
}
SessionPool::~SessionPool()
{
shutdown();
}
Session SessionPool::get(const std::string& name, bool value)
{
Session s = get();
_addFeatureMap.insert(AddFeatureMap::value_type(s.impl(),
std::make_pair(name, s.getFeature(name))));
s.setFeature(name, value);
return s;
}
Session SessionPool::get()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
purgeDeadSessions();
if (_idleSessions.empty())
{
if (_nSessions < _maxSessions)
{
Session newSession(SessionFactory::instance().create(_connector, _connectionString));
applySettings(newSession.impl());
PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl()));
_idleSessions.push_front(pHolder);
++_nSessions;
}
else throw SessionPoolExhaustedException(_connector, _connectionString);
}
PooledSessionHolderPtr pHolder(_idleSessions.front());
PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder));
_activeSessions.push_front(pHolder);
_idleSessions.pop_front();
return Session(pPSI);
}
void SessionPool::purgeDeadSessions()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
for (; it != _idleSessions.end(); )
{
if (!(*it)->session()->isConnected())
{
it = _idleSessions.erase(it);
--_nSessions;
}
else ++it;
}
}
int SessionPool::capacity() const
{
return _maxSessions;
}
int SessionPool::used() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _activeSessions.size();
}
int SessionPool::idle() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return (int) _idleSessions.size();
}
int SessionPool::dead()
{
Poco::Mutex::ScopedLock lock(_mutex);
int count = 0;
SessionList::iterator it = _activeSessions.begin();
SessionList::iterator itEnd = _activeSessions.end();
for (; it != itEnd; ++it)
{
if (!(*it)->session()->isConnected())
++count;
}
return count;
}
int SessionPool::allocated() const
{
Poco::Mutex::ScopedLock lock(_mutex);
return _nSessions;
}
int SessionPool::available() const
{
if (_shutdown) return 0;
return _maxSessions - used();
}
void SessionPool::setFeature(const std::string& name, bool state)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_nSessions > 0)
throw InvalidAccessException("Features can not be set after the first session was created.");
_featureMap.insert(FeatureMap::ValueType(name, state));
}
bool SessionPool::getFeature(const std::string& name)
{
FeatureMap::ConstIterator it = _featureMap.find(name);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_featureMap.end() == it)
throw NotFoundException("Feature not found:" + name);
return it->second;
}
void SessionPool::setProperty(const std::string& name, const Poco::Any& value)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) throw InvalidAccessException("Session pull has been shut down.");
if (_nSessions > 0)
throw InvalidAccessException("Properties can not be set after first session was created.");
_propertyMap.insert(PropertyMap::ValueType(name, value));
}
Poco::Any SessionPool::getProperty(const std::string& name)
{
PropertyMap::ConstIterator it = _propertyMap.find(name);
if (_propertyMap.end() == it)
throw NotFoundException("Property not found:" + name);
return it->second;
}
void SessionPool::applySettings(SessionImpl* pImpl)
{
FeatureMap::Iterator fmIt = _featureMap.begin();
FeatureMap::Iterator fmEnd = _featureMap.end();
for (; fmIt != fmEnd; ++fmIt) pImpl->setFeature(fmIt->first, fmIt->second);
PropertyMap::Iterator pmIt = _propertyMap.begin();
PropertyMap::Iterator pmEnd = _propertyMap.end();
for (; pmIt != pmEnd; ++pmIt) pImpl->setProperty(pmIt->first, pmIt->second);
}
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
if (it != _activeSessions.end())
{
if (pHolder->session()->isConnected())
{
// reverse settings applied at acquisition time, if any
AddPropertyMap::iterator pIt = _addPropertyMap.find(pHolder->session());
if (pIt != _addPropertyMap.end())
pHolder->session()->setProperty(pIt->second.first, pIt->second.second);
AddFeatureMap::iterator fIt = _addFeatureMap.find(pHolder->session());
if (fIt != _addFeatureMap.end())
pHolder->session()->setFeature(fIt->second.first, fIt->second.second);
// re-apply the default pool settings
applySettings(pHolder->session());
pHolder->access();
_idleSessions.push_front(pHolder);
}
else --_nSessions;
_activeSessions.erase(it);
}
else
{
poco_bugcheck_msg("Unknown session passed to SessionPool::putBack()");
}
}
void SessionPool::onJanitorTimer(Poco::Timer&)
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
SessionList::iterator it = _idleSessions.begin();
while (_nSessions > _minSessions && it != _idleSessions.end())
{
if ((*it)->idle() > _idleTime || !(*it)->session()->isConnected())
{
try { (*it)->session()->close(); }
catch (...) { }
it = _idleSessions.erase(it);
--_nSessions;
}
else ++it;
}
}
void SessionPool::shutdown()
{
Poco::Mutex::ScopedLock lock(_mutex);
if (_shutdown) return;
_shutdown = true;
_janitorTimer.stop();
closeAll(_idleSessions);
closeAll(_activeSessions);
}
void SessionPool::closeAll(SessionList& sessionList)
{
SessionList::iterator it = sessionList.begin();
for (; it != sessionList.end();)
{
try { (*it)->session()->close(); }
catch (...) { }
it = sessionList.erase(it);
if (_nSessions > 0) --_nSessions;
}
}
} } // namespace Poco::Data

View File

@@ -1,128 +1,128 @@
//
// SessionPoolContainer.cpp
//
// $Id: //poco/Main/Data/src/SessionPoolContainer.cpp#3 $
//
// Library: Data
// Package: SessionPoolContainering
// Module: SessionPoolContainer
//
// 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.
//
#include "Poco/Data/SessionPoolContainer.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/DataException.h"
#include "Poco/URI.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include <algorithm>
using Poco::FastMutex;
namespace Poco {
namespace Data {
SessionPoolContainer::SessionPoolContainer()
{
}
SessionPoolContainer::~SessionPoolContainer()
{
}
void SessionPoolContainer::add(SessionPool* pPool)
{
poco_check_ptr (pPool);
FastMutex::ScopedLock lock(_mutex);
if (_sessionPools.find(pPool->name()) != _sessionPools.end())
throw SessionPoolExistsException("Session pool already exists: " + pPool->name());
pPool->duplicate();
_sessionPools.insert(SessionPoolMap::ValueType(pPool->name(), pPool));
}
Session SessionPoolContainer::add(const std::string& sessionKey,
const std::string& connectionString,
int minSessions,
int maxSessions,
int idleTime)
{
std::string name = SessionPool::name(sessionKey, connectionString);
FastMutex::ScopedLock lock(_mutex);
SessionPoolMap::Iterator it = _sessionPools.find(name);
// pool already exists, silently return a session from it
if (it != _sessionPools.end()) return it->second->get();
SessionPool* pSP =
new SessionPool(sessionKey, connectionString, minSessions, maxSessions, idleTime);
std::pair<SessionPoolMap::Iterator, bool> ins =
_sessionPools.insert(SessionPoolMap::ValueType(name, pSP));
return ins.first->second->get();
}
Session SessionPoolContainer::get(const std::string& name)
{
return getPool(name).get();
}
SessionPool& SessionPoolContainer::getPool(const std::string& name)
{
URI uri(name);
std::string path = uri.getPath();
poco_assert (!path.empty());
std::string n = Session::uri(uri.getScheme(), path.substr(1));
FastMutex::ScopedLock lock(_mutex);
SessionPoolMap::Iterator it = _sessionPools.find(n);
if (_sessionPools.end() == it) throw NotFoundException(n);
return *it->second;
}
void SessionPoolContainer::shutdown()
{
SessionPoolMap::Iterator it = _sessionPools.begin();
SessionPoolMap::Iterator end = _sessionPools.end();
for (; it != end; ++it) it->second->shutdown();
}
} } // namespace Poco::Data
//
// SessionPoolContainer.cpp
//
// $Id: //poco/Main/Data/src/SessionPoolContainer.cpp#3 $
//
// Library: Data
// Package: SessionPoolContainering
// Module: SessionPoolContainer
//
// 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.
//
#include "Poco/Data/SessionPoolContainer.h"
#include "Poco/Data/SessionFactory.h"
#include "Poco/Data/DataException.h"
#include "Poco/URI.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include <algorithm>
using Poco::FastMutex;
namespace Poco {
namespace Data {
SessionPoolContainer::SessionPoolContainer()
{
}
SessionPoolContainer::~SessionPoolContainer()
{
}
void SessionPoolContainer::add(SessionPool* pPool)
{
poco_check_ptr (pPool);
FastMutex::ScopedLock lock(_mutex);
if (_sessionPools.find(pPool->name()) != _sessionPools.end())
throw SessionPoolExistsException("Session pool already exists: " + pPool->name());
pPool->duplicate();
_sessionPools.insert(SessionPoolMap::ValueType(pPool->name(), pPool));
}
Session SessionPoolContainer::add(const std::string& sessionKey,
const std::string& connectionString,
int minSessions,
int maxSessions,
int idleTime)
{
std::string name = SessionPool::name(sessionKey, connectionString);
FastMutex::ScopedLock lock(_mutex);
SessionPoolMap::Iterator it = _sessionPools.find(name);
// pool already exists, silently return a session from it
if (it != _sessionPools.end()) return it->second->get();
SessionPool* pSP =
new SessionPool(sessionKey, connectionString, minSessions, maxSessions, idleTime);
std::pair<SessionPoolMap::Iterator, bool> ins =
_sessionPools.insert(SessionPoolMap::ValueType(name, pSP));
return ins.first->second->get();
}
Session SessionPoolContainer::get(const std::string& name)
{
return getPool(name).get();
}
SessionPool& SessionPoolContainer::getPool(const std::string& name)
{
URI uri(name);
std::string path = uri.getPath();
poco_assert (!path.empty());
std::string n = Session::uri(uri.getScheme(), path.substr(1));
FastMutex::ScopedLock lock(_mutex);
SessionPoolMap::Iterator it = _sessionPools.find(n);
if (_sessionPools.end() == it) throw NotFoundException(n);
return *it->second;
}
void SessionPoolContainer::shutdown()
{
SessionPoolMap::Iterator it = _sessionPools.begin();
SessionPoolMap::Iterator end = _sessionPools.end();
for (; it != end; ++it) it->second->shutdown();
}
} } // namespace Poco::Data

View File

@@ -1,130 +1,130 @@
//
// RowFormatter.cpp
//
// $Id: //poco/Main/Data/src/RowFormatter.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowFormatter
//
// 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.
//
#include "Poco/Data/SimpleRowFormatter.h"
#include "Poco/Exception.h"
#include <iomanip>
namespace Poco {
namespace Data {
SimpleRowFormatter::SimpleRowFormatter(std::streamsize columnWidth):
_colWidth(columnWidth), _rowCount(0)
{
}
SimpleRowFormatter::SimpleRowFormatter(const SimpleRowFormatter& other):
RowFormatter(other.prefix(), other.postfix()),
_colWidth(other._colWidth)
{
}
SimpleRowFormatter::~SimpleRowFormatter()
{
}
SimpleRowFormatter& SimpleRowFormatter::operator = (const SimpleRowFormatter& row)
{
SimpleRowFormatter tmp(row);
swap(tmp);
return *this;
}
void SimpleRowFormatter::swap(SimpleRowFormatter& other)
{
using std::swap;
setPrefix(other.prefix());
setPostfix(other.postfix());
swap(_colWidth, other._colWidth);
}
std::string& SimpleRowFormatter::formatNames(const NameVecPtr pNames, std::string& formattedNames)
{
_rowCount = 0;
std::ostringstream str;
std::string line(_colWidth * pNames->size(), '-');
NameVec::const_iterator it = pNames->begin();
NameVec::const_iterator end = pNames->end();
for (; it != end; ++it)
{
str << std::left << std::setw(_colWidth) << *it;
}
str << std::endl << line << std::endl;
return formattedNames = str.str();
}
std::string& SimpleRowFormatter::formatValues(const ValueVec& vals, std::string& formattedValues)
{
std::ostringstream str;
ValueVec::const_iterator it = vals.begin();
ValueVec::const_iterator end = vals.end();
for (; it != end; ++it)
{
if (it->isNumeric())
{
str << std::right
<< std::fixed
<< std::setprecision(2);
}
else str << std::left;
if (!it->isEmpty())
str << std::setw(_colWidth) << it->convert<std::string>();
else
str << std::setw(_colWidth) << "null";
}
str << std::endl;
++_rowCount;
return formattedValues = str.str();
}
} } // namespace Poco::Data
//
// RowFormatter.cpp
//
// $Id: //poco/Main/Data/src/RowFormatter.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: RowFormatter
//
// 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.
//
#include "Poco/Data/SimpleRowFormatter.h"
#include "Poco/Exception.h"
#include <iomanip>
namespace Poco {
namespace Data {
SimpleRowFormatter::SimpleRowFormatter(std::streamsize columnWidth):
_colWidth(columnWidth), _rowCount(0)
{
}
SimpleRowFormatter::SimpleRowFormatter(const SimpleRowFormatter& other):
RowFormatter(other.prefix(), other.postfix()),
_colWidth(other._colWidth)
{
}
SimpleRowFormatter::~SimpleRowFormatter()
{
}
SimpleRowFormatter& SimpleRowFormatter::operator = (const SimpleRowFormatter& row)
{
SimpleRowFormatter tmp(row);
swap(tmp);
return *this;
}
void SimpleRowFormatter::swap(SimpleRowFormatter& other)
{
using std::swap;
setPrefix(other.prefix());
setPostfix(other.postfix());
swap(_colWidth, other._colWidth);
}
std::string& SimpleRowFormatter::formatNames(const NameVecPtr pNames, std::string& formattedNames)
{
_rowCount = 0;
std::ostringstream str;
std::string line(_colWidth * pNames->size(), '-');
NameVec::const_iterator it = pNames->begin();
NameVec::const_iterator end = pNames->end();
for (; it != end; ++it)
{
str << std::left << std::setw(_colWidth) << *it;
}
str << std::endl << line << std::endl;
return formattedNames = str.str();
}
std::string& SimpleRowFormatter::formatValues(const ValueVec& vals, std::string& formattedValues)
{
std::ostringstream str;
ValueVec::const_iterator it = vals.begin();
ValueVec::const_iterator end = vals.end();
for (; it != end; ++it)
{
if (it->isNumeric())
{
str << std::right
<< std::fixed
<< std::setprecision(2);
}
else str << std::left;
if (!it->isEmpty())
str << std::setw(_colWidth) << it->convert<std::string>();
else
str << std::setw(_colWidth) << "null";
}
str << std::endl;
++_rowCount;
return formattedValues = str.str();
}
} } // namespace Poco::Data

View File

@@ -1,318 +1,318 @@
//
// Statement.cpp
//
// $Id: //poco/Main/Data/src/Statement.cpp#11 $
//
// Library: Data
// Package: DataCore
// Module: Statement
//
// 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.
//
#include "Poco/Data/Statement.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/Extraction.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/Bulk.h"
#include "Poco/Any.h"
#include "Poco/Tuple.h"
#include "Poco/ActiveMethod.h"
#include <algorithm>
namespace Poco {
namespace Data {
Statement::Statement(StatementImpl* pImpl):
_pImpl(pImpl),
_async(false)
{
poco_check_ptr (pImpl);
}
Statement::Statement(Session& session):
_async(false)
{
reset(session);
}
Statement::Statement(const Statement& stmt):
_pImpl(stmt._pImpl),
_async(stmt._async),
_pResult(stmt._pResult),
_pAsyncExec(stmt._pAsyncExec),
_arguments(stmt._arguments),
_pRowFormatter(stmt._pRowFormatter)
{
}
Statement::~Statement()
{
}
Statement& Statement::operator = (const Statement& stmt)
{
Statement tmp(stmt);
swap(tmp);
return *this;
}
void Statement::swap(Statement& other)
{
using std::swap;
swap(_pImpl, other._pImpl);
swap(_async, other._async);
swap(_pAsyncExec, other._pAsyncExec);
swap(_pResult, other._pResult);
_arguments.swap(other._arguments);
swap(_pRowFormatter, other._pRowFormatter);
}
Statement& Statement::reset(Session& session)
{
Statement stmt(session.createStatementImpl());
swap(stmt);
return *this;
}
std::size_t Statement::execute(bool reset)
{
Mutex::ScopedLock lock(_mutex);
bool isDone = done();
if (initialized() || paused() || isDone)
{
if (_arguments.size())
{
_pImpl->formatSQL(_arguments);
_arguments.clear();
}
if (!isAsync())
{
if (isDone) _pImpl->reset();
return _pImpl->execute(reset);
}
else
{
doAsyncExec();
return 0;
}
} else
throw InvalidAccessException("Statement still executing.");
}
const Statement::Result& Statement::executeAsync(bool reset)
{
Mutex::ScopedLock lock(_mutex);
if (initialized() || paused() || done())
return doAsyncExec(reset);
else
throw InvalidAccessException("Statement still executing.");
}
const Statement::Result& Statement::doAsyncExec(bool reset)
{
if (done()) _pImpl->reset();
if (!_pAsyncExec)
_pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
_pResult = new Result((*_pAsyncExec)(reset));
return *_pResult;
}
void Statement::setAsync(bool async)
{
_async = async;
if (_async && !_pAsyncExec)
_pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
}
std::size_t Statement::wait(long milliseconds)
{
if (!_pResult) return 0;
if (WAIT_FOREVER != milliseconds)
_pResult->wait(milliseconds);
else
_pResult->wait();
if (_pResult->exception())
throw *_pResult->exception();
return _pResult->data();
}
const std::string& Statement::getStorage() const
{
switch (storage())
{
case STORAGE_VECTOR:
return StatementImpl::VECTOR;
case STORAGE_LIST:
return StatementImpl::LIST;
case STORAGE_DEQUE:
return StatementImpl::DEQUE;
case STORAGE_UNKNOWN:
return StatementImpl::UNKNOWN;
}
throw IllegalStateException("Invalid storage setting.");
}
Statement& Statement::operator , (Manipulator manip)
{
manip(*this);
return *this;
}
Statement& Statement::addBind(AbstractBinding* pBind, bool duplicate)
{
if (pBind->isBulk())
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if(_pImpl->bulkBindingAllowed())
_pImpl->setBulkBinding();
else
throw InvalidAccessException("Bulk and non-bulk binding modes can not be mixed.");
}
else _pImpl->forbidBulk();
if (duplicate) pBind->duplicate();
_pImpl->addBind(pBind);
return *this;
}
Statement& Statement::addExtract(AbstractExtraction* pExtract, bool duplicate)
{
if (pExtract->isBulk())
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if(_pImpl->bulkExtractionAllowed())
{
Bulk b(pExtract->getLimit());
_pImpl->setBulkExtraction(b);
}
else
throw InvalidAccessException("Bulk and non-bulk extraction modes can not be mixed.");
}
else _pImpl->forbidBulk();
if (duplicate) pExtract->duplicate();
_pImpl->addExtract(pExtract);
return *this;
}
Statement& Statement::operator , (const Limit& extrLimit)
{
if (_pImpl->isBulkExtraction() && _pImpl->extractionLimit() != extrLimit)
throw InvalidArgumentException("Limit for bulk extraction already set.");
_pImpl->setExtractionLimit(extrLimit);
return *this;
}
Statement& Statement::operator , (const Range& extrRange)
{
if (_pImpl->isBulkExtraction())
throw InvalidAccessException("Can not set range for bulk extraction.");
_pImpl->setExtractionLimit(extrRange.lower());
_pImpl->setExtractionLimit(extrRange.upper());
return *this;
}
Statement& Statement::operator , (const Bulk& bulk)
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if (0 == _pImpl->extractions().size() &&
0 == _pImpl->bindings().size() &&
_pImpl->bulkExtractionAllowed() &&
_pImpl->bulkBindingAllowed())
{
_pImpl->setBulkExtraction(bulk);
_pImpl->setBulkBinding();
}
else
throw InvalidAccessException("Can not set bulk operations.");
return *this;
}
Statement& Statement::operator , (BulkFnType)
{
const Limit& limit(_pImpl->extractionLimit());
if (limit.isHardLimit() ||
limit.isLowerLimit() ||
Limit::LIMIT_UNLIMITED == limit.value())
{
throw InvalidAccessException("Bulk is only allowed with limited extraction,"
"non-hard and zero-based limits.");
}
Bulk bulk(limit);
_pImpl->setBulkExtraction(bulk);
_pImpl->setBulkBinding();
return *this;
}
Session Statement::session()
{
Poco::AutoPtr<SessionImpl> ps(&impl()->session(), true);
return Session(ps);
}
} } // namespace Poco::Data
//
// Statement.cpp
//
// $Id: //poco/Main/Data/src/Statement.cpp#11 $
//
// Library: Data
// Package: DataCore
// Module: Statement
//
// 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.
//
#include "Poco/Data/Statement.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/Extraction.h"
#include "Poco/Data/Session.h"
#include "Poco/Data/Bulk.h"
#include "Poco/Any.h"
#include "Poco/Tuple.h"
#include "Poco/ActiveMethod.h"
#include <algorithm>
namespace Poco {
namespace Data {
Statement::Statement(StatementImpl* pImpl):
_pImpl(pImpl),
_async(false)
{
poco_check_ptr (pImpl);
}
Statement::Statement(Session& session):
_async(false)
{
reset(session);
}
Statement::Statement(const Statement& stmt):
_pImpl(stmt._pImpl),
_async(stmt._async),
_pResult(stmt._pResult),
_pAsyncExec(stmt._pAsyncExec),
_arguments(stmt._arguments),
_pRowFormatter(stmt._pRowFormatter)
{
}
Statement::~Statement()
{
}
Statement& Statement::operator = (const Statement& stmt)
{
Statement tmp(stmt);
swap(tmp);
return *this;
}
void Statement::swap(Statement& other)
{
using std::swap;
swap(_pImpl, other._pImpl);
swap(_async, other._async);
swap(_pAsyncExec, other._pAsyncExec);
swap(_pResult, other._pResult);
_arguments.swap(other._arguments);
swap(_pRowFormatter, other._pRowFormatter);
}
Statement& Statement::reset(Session& session)
{
Statement stmt(session.createStatementImpl());
swap(stmt);
return *this;
}
std::size_t Statement::execute(bool reset)
{
Mutex::ScopedLock lock(_mutex);
bool isDone = done();
if (initialized() || paused() || isDone)
{
if (_arguments.size())
{
_pImpl->formatSQL(_arguments);
_arguments.clear();
}
if (!isAsync())
{
if (isDone) _pImpl->reset();
return _pImpl->execute(reset);
}
else
{
doAsyncExec();
return 0;
}
} else
throw InvalidAccessException("Statement still executing.");
}
const Statement::Result& Statement::executeAsync(bool reset)
{
Mutex::ScopedLock lock(_mutex);
if (initialized() || paused() || done())
return doAsyncExec(reset);
else
throw InvalidAccessException("Statement still executing.");
}
const Statement::Result& Statement::doAsyncExec(bool reset)
{
if (done()) _pImpl->reset();
if (!_pAsyncExec)
_pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
_pResult = new Result((*_pAsyncExec)(reset));
return *_pResult;
}
void Statement::setAsync(bool async)
{
_async = async;
if (_async && !_pAsyncExec)
_pAsyncExec = new AsyncExecMethod(_pImpl, &StatementImpl::execute);
}
std::size_t Statement::wait(long milliseconds)
{
if (!_pResult) return 0;
if (WAIT_FOREVER != milliseconds)
_pResult->wait(milliseconds);
else
_pResult->wait();
if (_pResult->exception())
throw *_pResult->exception();
return _pResult->data();
}
const std::string& Statement::getStorage() const
{
switch (storage())
{
case STORAGE_VECTOR:
return StatementImpl::VECTOR;
case STORAGE_LIST:
return StatementImpl::LIST;
case STORAGE_DEQUE:
return StatementImpl::DEQUE;
case STORAGE_UNKNOWN:
return StatementImpl::UNKNOWN;
}
throw IllegalStateException("Invalid storage setting.");
}
Statement& Statement::operator , (Manipulator manip)
{
manip(*this);
return *this;
}
Statement& Statement::addBind(AbstractBinding* pBind, bool duplicate)
{
if (pBind->isBulk())
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if(_pImpl->bulkBindingAllowed())
_pImpl->setBulkBinding();
else
throw InvalidAccessException("Bulk and non-bulk binding modes can not be mixed.");
}
else _pImpl->forbidBulk();
if (duplicate) pBind->duplicate();
_pImpl->addBind(pBind);
return *this;
}
Statement& Statement::addExtract(AbstractExtraction* pExtract, bool duplicate)
{
if (pExtract->isBulk())
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if(_pImpl->bulkExtractionAllowed())
{
Bulk b(pExtract->getLimit());
_pImpl->setBulkExtraction(b);
}
else
throw InvalidAccessException("Bulk and non-bulk extraction modes can not be mixed.");
}
else _pImpl->forbidBulk();
if (duplicate) pExtract->duplicate();
_pImpl->addExtract(pExtract);
return *this;
}
Statement& Statement::operator , (const Limit& extrLimit)
{
if (_pImpl->isBulkExtraction() && _pImpl->extractionLimit() != extrLimit)
throw InvalidArgumentException("Limit for bulk extraction already set.");
_pImpl->setExtractionLimit(extrLimit);
return *this;
}
Statement& Statement::operator , (const Range& extrRange)
{
if (_pImpl->isBulkExtraction())
throw InvalidAccessException("Can not set range for bulk extraction.");
_pImpl->setExtractionLimit(extrRange.lower());
_pImpl->setExtractionLimit(extrRange.upper());
return *this;
}
Statement& Statement::operator , (const Bulk& bulk)
{
if (!_pImpl->isBulkSupported())
throw InvalidAccessException("Bulk not supported by this session.");
if (0 == _pImpl->extractions().size() &&
0 == _pImpl->bindings().size() &&
_pImpl->bulkExtractionAllowed() &&
_pImpl->bulkBindingAllowed())
{
_pImpl->setBulkExtraction(bulk);
_pImpl->setBulkBinding();
}
else
throw InvalidAccessException("Can not set bulk operations.");
return *this;
}
Statement& Statement::operator , (BulkFnType)
{
const Limit& limit(_pImpl->extractionLimit());
if (limit.isHardLimit() ||
limit.isLowerLimit() ||
Limit::LIMIT_UNLIMITED == limit.value())
{
throw InvalidAccessException("Bulk is only allowed with limited extraction,"
"non-hard and zero-based limits.");
}
Bulk bulk(limit);
_pImpl->setBulkExtraction(bulk);
_pImpl->setBulkBinding();
return *this;
}
Session Statement::session()
{
Poco::AutoPtr<SessionImpl> ps(&impl()->session(), true);
return Session(ps);
}
} } // namespace Poco::Data

View File

@@ -1,82 +1,82 @@
//
// StatementCreator.cpp
//
// $Id: //poco/Main/Data/src/StatementCreator.cpp#4 $
//
// Library: Data
// Package: DataCore
// Module: StatementCreator
//
// 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.
//
#include "Poco/Data/StatementCreator.h"
#include <algorithm>
namespace Poco {
namespace Data {
StatementCreator::StatementCreator()
{
}
StatementCreator::StatementCreator(Poco::AutoPtr<SessionImpl> ptrImpl):
_ptrImpl(ptrImpl)
{
}
StatementCreator::StatementCreator(const StatementCreator& other):
_ptrImpl(other._ptrImpl)
{
}
StatementCreator& StatementCreator::operator = (const StatementCreator& other)
{
StatementCreator tmp(other);
swap(tmp);
return *this;
}
void StatementCreator::swap(StatementCreator& other)
{
using std::swap;
swap(_ptrImpl, other._ptrImpl);
}
StatementCreator::~StatementCreator()
{
}
} } // namespace Poco::Data
//
// StatementCreator.cpp
//
// $Id: //poco/Main/Data/src/StatementCreator.cpp#4 $
//
// Library: Data
// Package: DataCore
// Module: StatementCreator
//
// 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.
//
#include "Poco/Data/StatementCreator.h"
#include <algorithm>
namespace Poco {
namespace Data {
StatementCreator::StatementCreator()
{
}
StatementCreator::StatementCreator(Poco::AutoPtr<SessionImpl> ptrImpl):
_ptrImpl(ptrImpl)
{
}
StatementCreator::StatementCreator(const StatementCreator& other):
_ptrImpl(other._ptrImpl)
{
}
StatementCreator& StatementCreator::operator = (const StatementCreator& other)
{
StatementCreator tmp(other);
swap(tmp);
return *this;
}
void StatementCreator::swap(StatementCreator& other)
{
using std::swap;
swap(_ptrImpl, other._ptrImpl);
}
StatementCreator::~StatementCreator()
{
}
} } // namespace Poco::Data

View File

@@ -1,483 +1,483 @@
//
// StatementImpl.cpp
//
// $Id: //poco/Main/Data/src/StatementImpl.cpp#20 $
//
// Library: Data
// Package: DataCore
// Module: StatementImpl
//
// 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.
//
#include "Poco/Data/StatementImpl.h"
#include "Poco/Data/SessionImpl.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/AbstractBinder.h"
#include "Poco/Data/Extraction.h"
#include "Poco/Data/LOB.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Poco/SharedPtr.h"
#include "Poco/DateTime.h"
#include "Poco/Exception.h"
#include "Poco/Data/DataException.h"
using Poco::icompare;
namespace Poco {
namespace Data {
using namespace Keywords;
const std::string StatementImpl::VECTOR = "vector";
const std::string StatementImpl::LIST = "list";
const std::string StatementImpl::DEQUE = "deque";
const std::string StatementImpl::UNKNOWN = "unknown";
StatementImpl::StatementImpl(SessionImpl& rSession):
_state(ST_INITIALIZED),
_extrLimit(upperLimit((std::size_t) Limit::LIMIT_UNLIMITED, false)),
_lowerLimit(0),
_rSession(rSession),
_storage(STORAGE_UNKNOWN_IMPL),
_ostr(),
_curDataSet(0),
_bulkBinding(BULK_UNDEFINED),
_bulkExtraction(BULK_UNDEFINED)
{
if (!_rSession.isConnected())
throw NotConnectedException(_rSession.connectionString());
_extractors.resize(1);
_columnsExtracted.resize(1, 0);
_subTotalRowCount.resize(1, 0);
}
StatementImpl::~StatementImpl()
{
}
std::size_t StatementImpl::execute(const bool& reset)
{
if (reset) resetExtraction();
if (!_rSession.isConnected())
{
_state = ST_DONE;
throw NotConnectedException(_rSession.connectionString());
}
std::size_t lim = 0;
if (_lowerLimit > _extrLimit.value())
throw LimitException("Illegal Statement state. Upper limit must not be smaller than the lower limit.");
do
{
compile();
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
lim += executeWithoutLimit();
else
lim += executeWithLimit();
} while (canCompile());
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
_state = ST_DONE;
if (lim < _lowerLimit)
throw LimitException("Did not receive enough data.");
assignSubTotal(reset);
return lim;
}
void StatementImpl::assignSubTotal(bool reset)
{
if (_extractors.size() == _subTotalRowCount.size())
{
CountVec::iterator it = _subTotalRowCount.begin();
CountVec::iterator end = _subTotalRowCount.end();
for (int counter = 0; it != end; ++it, ++counter)
{
if (_extractors[counter].size())
{
if (reset)
*it += _extractors[counter][0]->numOfRowsHandled();
else
*it = _extractors[counter][0]->numOfRowsHandled();
}
}
}
}
std::size_t StatementImpl::executeWithLimit()
{
poco_assert (_state != ST_DONE);
std::size_t count = 0;
std::size_t limit = _extrLimit.value();
do
{
bind();
while (count < limit && hasNext())
count += next();
} while (count < limit && canBind());
if (!canBind() && (!hasNext() || limit == 0))
_state = ST_DONE;
else if (hasNext() && limit == count && _extrLimit.isHardLimit())
throw LimitException("HardLimit reached (retrieved more data than requested).");
else
_state = ST_PAUSED;
return count ? count : affectedRowCount();
}
std::size_t StatementImpl::executeWithoutLimit()
{
poco_assert (_state != ST_DONE);
std::size_t count = 0;
do
{
bind();
while (hasNext()) count += next();
} while (canBind());
return count ? count : affectedRowCount();
}
void StatementImpl::compile()
{
if (_state == ST_INITIALIZED ||
_state == ST_RESET ||
_state == ST_BOUND)
{
compileImpl();
_state = ST_COMPILED;
if (!extractions().size() && !isStoredProcedure())
{
std::size_t cols = columnsReturned();
if (cols) makeExtractors(cols);
}
fixupExtraction();
fixupBinding();
}
}
void StatementImpl::bind()
{
if (_state == ST_COMPILED)
{
bindImpl();
_state = ST_BOUND;
}
else if (_state == ST_BOUND)
{
if (!hasNext())
{
if (canBind()) bindImpl();
else _state = ST_DONE;
}
}
}
void StatementImpl::reset()
{
resetBinding();
resetExtraction();
_state = ST_RESET;
}
void StatementImpl::setExtractionLimit(const Limit& extrLimit)
{
if (!extrLimit.isLowerLimit())
_extrLimit = extrLimit;
else
_lowerLimit = extrLimit.value();
}
void StatementImpl::setBulkExtraction(const Bulk& b)
{
std::size_t limit = getExtractionLimit();
if (Limit::LIMIT_UNLIMITED != limit && b.size() != limit)
throw InvalidArgumentException("Can not set limit for statement.");
setExtractionLimit(b.limit());
_bulkExtraction = BULK_EXTRACTION;
}
void StatementImpl::fixupExtraction()
{
CountVec::iterator sIt = _subTotalRowCount.begin();
CountVec::iterator sEnd = _subTotalRowCount.end();
for (; sIt != sEnd; ++sIt) *sIt = 0;
if (_curDataSet >= _columnsExtracted.size())
{
_columnsExtracted.resize(_curDataSet + 1, 0);
_subTotalRowCount.resize(_curDataSet + 1, 0);
}
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
AbstractExtractor& ex = extractor();
for (; it != itEnd; ++it)
{
(*it)->setExtractor(&ex);
(*it)->setLimit(_extrLimit.value()),
_columnsExtracted[_curDataSet] += (int)(*it)->numOfColumnsHandled();
}
}
void StatementImpl::fixupBinding()
{
// no need to call binder().reset(); here will be called before each bind anyway
AbstractBindingVec::iterator it = bindings().begin();
AbstractBindingVec::iterator itEnd = bindings().end();
AbstractBinder& bin = binder();
for (; it != itEnd; ++it) (*it)->setBinder(&bin);
}
void StatementImpl::resetBinding()
{
AbstractBindingVec::iterator it = bindings().begin();
AbstractBindingVec::iterator itEnd = bindings().end();
for (; it != itEnd; ++it) (*it)->reset();
}
void StatementImpl::resetExtraction()
{
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
for (; it != itEnd; ++it) (*it)->reset();
poco_assert (_curDataSet < _columnsExtracted.size());
_columnsExtracted[_curDataSet] = 0;
}
void StatementImpl::setStorage(const std::string& storage)
{
if (0 == icompare(DEQUE, storage))
_storage = STORAGE_DEQUE_IMPL;
else if (0 == icompare(VECTOR, storage))
_storage = STORAGE_VECTOR_IMPL;
else if (0 == icompare(LIST, storage))
_storage = STORAGE_LIST_IMPL;
else if (0 == icompare(UNKNOWN, storage))
_storage = STORAGE_UNKNOWN_IMPL;
else
throw NotFoundException();
}
void StatementImpl::makeExtractors(std::size_t count)
{
for (int i = 0; i < count; ++i)
{
const MetaColumn& mc = metaColumn(i);
switch (mc.type())
{
case MetaColumn::FDT_BOOL:
addInternalExtract<bool>(mc); break;
case MetaColumn::FDT_INT8:
addInternalExtract<Int8>(mc); break;
case MetaColumn::FDT_UINT8:
addInternalExtract<UInt8>(mc); break;
case MetaColumn::FDT_INT16:
addInternalExtract<Int16>(mc); break;
case MetaColumn::FDT_UINT16:
addInternalExtract<UInt16>(mc); break;
case MetaColumn::FDT_INT32:
addInternalExtract<Int32>(mc); break;
case MetaColumn::FDT_UINT32:
addInternalExtract<UInt32>(mc); break;
case MetaColumn::FDT_INT64:
addInternalExtract<Int64>(mc); break;
case MetaColumn::FDT_UINT64:
addInternalExtract<UInt64>(mc); break;
case MetaColumn::FDT_FLOAT:
addInternalExtract<float>(mc); break;
case MetaColumn::FDT_DOUBLE:
addInternalExtract<double>(mc); break;
case MetaColumn::FDT_STRING:
addInternalExtract<std::string>(mc); break;
case MetaColumn::FDT_BLOB:
addInternalExtract<BLOB>(mc); break;
case MetaColumn::FDT_DATE:
addInternalExtract<Date>(mc); break;
case MetaColumn::FDT_TIME:
addInternalExtract<Time>(mc); break;
case MetaColumn::FDT_TIMESTAMP:
addInternalExtract<DateTime>(mc); break;
default:
throw Poco::InvalidArgumentException("Data type not supported.");
}
}
}
const MetaColumn& StatementImpl::metaColumn(const std::string& name) const
{
std::size_t cols = columnsReturned();
for (std::size_t i = 0; i < cols; ++i)
{
const MetaColumn& column = metaColumn(i);
if (0 == icompare(column.name(), name)) return column;
}
throw NotFoundException(format("Invalid column name: %s", name));
}
std::size_t StatementImpl::activateNextDataSet()
{
if (_curDataSet + 1 < dataSetCount())
return ++_curDataSet;
else
throw NoDataException("End of data sets reached.");
}
std::size_t StatementImpl::activatePreviousDataSet()
{
if (_curDataSet > 0)
return --_curDataSet;
else
throw NoDataException("Beginning of data sets reached.");
}
void StatementImpl::addExtract(AbstractExtraction* pExtraction)
{
poco_check_ptr (pExtraction);
std::size_t pos = pExtraction->position();
if (pos >= _extractors.size())
_extractors.resize(pos + 1);
pExtraction->setEmptyStringIsNull(
_rSession.getFeature("emptyStringIsNull"));
pExtraction->setForceEmptyString(
_rSession.getFeature("forceEmptyString"));
_extractors[pos].push_back(pExtraction);
}
void StatementImpl::removeBind(const std::string& name)
{
bool found = false;
AbstractBindingVec::iterator it = _bindings.begin();
for (; it != _bindings.end();)
{
if ((*it)->name() == name)
{
it = _bindings.erase(it);
found = true;
}
else ++it;
}
if (!found)
throw NotFoundException(name);
}
std::size_t StatementImpl::columnsExtracted(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = _curDataSet;
if (_columnsExtracted.size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _columnsExtracted.size());
return _columnsExtracted[dataSet];
}
return 0;
}
std::size_t StatementImpl::rowsExtracted(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = _curDataSet;
if (extractions().size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _extractors.size());
if (_extractors[dataSet].size() > 0)
return _extractors[dataSet][0]->numOfRowsHandled();
}
return 0;
}
std::size_t StatementImpl::subTotalRowCount(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = _curDataSet;
if (_subTotalRowCount.size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _subTotalRowCount.size());
return _subTotalRowCount[dataSet];
}
return 0;
}
void StatementImpl::formatSQL(std::vector<Any>& arguments)
{
std::string sql;
Poco::format(sql, _ostr.str(), arguments);
_ostr.str(""); _ostr << sql;
}
} } // namespace Poco::Data
//
// StatementImpl.cpp
//
// $Id: //poco/Main/Data/src/StatementImpl.cpp#20 $
//
// Library: Data
// Package: DataCore
// Module: StatementImpl
//
// 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.
//
#include "Poco/Data/StatementImpl.h"
#include "Poco/Data/SessionImpl.h"
#include "Poco/Data/DataException.h"
#include "Poco/Data/AbstractBinder.h"
#include "Poco/Data/Extraction.h"
#include "Poco/Data/LOB.h"
#include "Poco/Data/Date.h"
#include "Poco/Data/Time.h"
#include "Poco/SharedPtr.h"
#include "Poco/DateTime.h"
#include "Poco/Exception.h"
#include "Poco/Data/DataException.h"
using Poco::icompare;
namespace Poco {
namespace Data {
using namespace Keywords;
const std::string StatementImpl::VECTOR = "vector";
const std::string StatementImpl::LIST = "list";
const std::string StatementImpl::DEQUE = "deque";
const std::string StatementImpl::UNKNOWN = "unknown";
StatementImpl::StatementImpl(SessionImpl& rSession):
_state(ST_INITIALIZED),
_extrLimit(upperLimit((std::size_t) Limit::LIMIT_UNLIMITED, false)),
_lowerLimit(0),
_rSession(rSession),
_storage(STORAGE_UNKNOWN_IMPL),
_ostr(),
_curDataSet(0),
_bulkBinding(BULK_UNDEFINED),
_bulkExtraction(BULK_UNDEFINED)
{
if (!_rSession.isConnected())
throw NotConnectedException(_rSession.connectionString());
_extractors.resize(1);
_columnsExtracted.resize(1, 0);
_subTotalRowCount.resize(1, 0);
}
StatementImpl::~StatementImpl()
{
}
std::size_t StatementImpl::execute(const bool& reset)
{
if (reset) resetExtraction();
if (!_rSession.isConnected())
{
_state = ST_DONE;
throw NotConnectedException(_rSession.connectionString());
}
std::size_t lim = 0;
if (_lowerLimit > _extrLimit.value())
throw LimitException("Illegal Statement state. Upper limit must not be smaller than the lower limit.");
do
{
compile();
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
lim += executeWithoutLimit();
else
lim += executeWithLimit();
} while (canCompile());
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
_state = ST_DONE;
if (lim < _lowerLimit)
throw LimitException("Did not receive enough data.");
assignSubTotal(reset);
return lim;
}
void StatementImpl::assignSubTotal(bool reset)
{
if (_extractors.size() == _subTotalRowCount.size())
{
CountVec::iterator it = _subTotalRowCount.begin();
CountVec::iterator end = _subTotalRowCount.end();
for (int counter = 0; it != end; ++it, ++counter)
{
if (_extractors[counter].size())
{
if (reset)
*it += _extractors[counter][0]->numOfRowsHandled();
else
*it = _extractors[counter][0]->numOfRowsHandled();
}
}
}
}
std::size_t StatementImpl::executeWithLimit()
{
poco_assert (_state != ST_DONE);
std::size_t count = 0;
std::size_t limit = _extrLimit.value();
do
{
bind();
while (count < limit && hasNext())
count += next();
} while (count < limit && canBind());
if (!canBind() && (!hasNext() || limit == 0))
_state = ST_DONE;
else if (hasNext() && limit == count && _extrLimit.isHardLimit())
throw LimitException("HardLimit reached (retrieved more data than requested).");
else
_state = ST_PAUSED;
return count ? count : affectedRowCount();
}
std::size_t StatementImpl::executeWithoutLimit()
{
poco_assert (_state != ST_DONE);
std::size_t count = 0;
do
{
bind();
while (hasNext()) count += next();
} while (canBind());
return count ? count : affectedRowCount();
}
void StatementImpl::compile()
{
if (_state == ST_INITIALIZED ||
_state == ST_RESET ||
_state == ST_BOUND)
{
compileImpl();
_state = ST_COMPILED;
if (!extractions().size() && !isStoredProcedure())
{
std::size_t cols = columnsReturned();
if (cols) makeExtractors(cols);
}
fixupExtraction();
fixupBinding();
}
}
void StatementImpl::bind()
{
if (_state == ST_COMPILED)
{
bindImpl();
_state = ST_BOUND;
}
else if (_state == ST_BOUND)
{
if (!hasNext())
{
if (canBind()) bindImpl();
else _state = ST_DONE;
}
}
}
void StatementImpl::reset()
{
resetBinding();
resetExtraction();
_state = ST_RESET;
}
void StatementImpl::setExtractionLimit(const Limit& extrLimit)
{
if (!extrLimit.isLowerLimit())
_extrLimit = extrLimit;
else
_lowerLimit = extrLimit.value();
}
void StatementImpl::setBulkExtraction(const Bulk& b)
{
std::size_t limit = getExtractionLimit();
if (Limit::LIMIT_UNLIMITED != limit && b.size() != limit)
throw InvalidArgumentException("Can not set limit for statement.");
setExtractionLimit(b.limit());
_bulkExtraction = BULK_EXTRACTION;
}
void StatementImpl::fixupExtraction()
{
CountVec::iterator sIt = _subTotalRowCount.begin();
CountVec::iterator sEnd = _subTotalRowCount.end();
for (; sIt != sEnd; ++sIt) *sIt = 0;
if (_curDataSet >= _columnsExtracted.size())
{
_columnsExtracted.resize(_curDataSet + 1, 0);
_subTotalRowCount.resize(_curDataSet + 1, 0);
}
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
AbstractExtractor& ex = extractor();
for (; it != itEnd; ++it)
{
(*it)->setExtractor(&ex);
(*it)->setLimit(_extrLimit.value()),
_columnsExtracted[_curDataSet] += (int)(*it)->numOfColumnsHandled();
}
}
void StatementImpl::fixupBinding()
{
// no need to call binder().reset(); here will be called before each bind anyway
AbstractBindingVec::iterator it = bindings().begin();
AbstractBindingVec::iterator itEnd = bindings().end();
AbstractBinder& bin = binder();
for (; it != itEnd; ++it) (*it)->setBinder(&bin);
}
void StatementImpl::resetBinding()
{
AbstractBindingVec::iterator it = bindings().begin();
AbstractBindingVec::iterator itEnd = bindings().end();
for (; it != itEnd; ++it) (*it)->reset();
}
void StatementImpl::resetExtraction()
{
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
for (; it != itEnd; ++it) (*it)->reset();
poco_assert (_curDataSet < _columnsExtracted.size());
_columnsExtracted[_curDataSet] = 0;
}
void StatementImpl::setStorage(const std::string& storage)
{
if (0 == icompare(DEQUE, storage))
_storage = STORAGE_DEQUE_IMPL;
else if (0 == icompare(VECTOR, storage))
_storage = STORAGE_VECTOR_IMPL;
else if (0 == icompare(LIST, storage))
_storage = STORAGE_LIST_IMPL;
else if (0 == icompare(UNKNOWN, storage))
_storage = STORAGE_UNKNOWN_IMPL;
else
throw NotFoundException();
}
void StatementImpl::makeExtractors(std::size_t count)
{
for (int i = 0; i < count; ++i)
{
const MetaColumn& mc = metaColumn(i);
switch (mc.type())
{
case MetaColumn::FDT_BOOL:
addInternalExtract<bool>(mc); break;
case MetaColumn::FDT_INT8:
addInternalExtract<Int8>(mc); break;
case MetaColumn::FDT_UINT8:
addInternalExtract<UInt8>(mc); break;
case MetaColumn::FDT_INT16:
addInternalExtract<Int16>(mc); break;
case MetaColumn::FDT_UINT16:
addInternalExtract<UInt16>(mc); break;
case MetaColumn::FDT_INT32:
addInternalExtract<Int32>(mc); break;
case MetaColumn::FDT_UINT32:
addInternalExtract<UInt32>(mc); break;
case MetaColumn::FDT_INT64:
addInternalExtract<Int64>(mc); break;
case MetaColumn::FDT_UINT64:
addInternalExtract<UInt64>(mc); break;
case MetaColumn::FDT_FLOAT:
addInternalExtract<float>(mc); break;
case MetaColumn::FDT_DOUBLE:
addInternalExtract<double>(mc); break;
case MetaColumn::FDT_STRING:
addInternalExtract<std::string>(mc); break;
case MetaColumn::FDT_BLOB:
addInternalExtract<BLOB>(mc); break;
case MetaColumn::FDT_DATE:
addInternalExtract<Date>(mc); break;
case MetaColumn::FDT_TIME:
addInternalExtract<Time>(mc); break;
case MetaColumn::FDT_TIMESTAMP:
addInternalExtract<DateTime>(mc); break;
default:
throw Poco::InvalidArgumentException("Data type not supported.");
}
}
}
const MetaColumn& StatementImpl::metaColumn(const std::string& name) const
{
std::size_t cols = columnsReturned();
for (std::size_t i = 0; i < cols; ++i)
{
const MetaColumn& column = metaColumn(i);
if (0 == icompare(column.name(), name)) return column;
}
throw NotFoundException(format("Invalid column name: %s", name));
}
std::size_t StatementImpl::activateNextDataSet()
{
if (_curDataSet + 1 < dataSetCount())
return ++_curDataSet;
else
throw NoDataException("End of data sets reached.");
}
std::size_t StatementImpl::activatePreviousDataSet()
{
if (_curDataSet > 0)
return --_curDataSet;
else
throw NoDataException("Beginning of data sets reached.");
}
void StatementImpl::addExtract(AbstractExtraction* pExtraction)
{
poco_check_ptr (pExtraction);
std::size_t pos = pExtraction->position();
if (pos >= _extractors.size())
_extractors.resize(pos + 1);
pExtraction->setEmptyStringIsNull(
_rSession.getFeature("emptyStringIsNull"));
pExtraction->setForceEmptyString(
_rSession.getFeature("forceEmptyString"));
_extractors[pos].push_back(pExtraction);
}
void StatementImpl::removeBind(const std::string& name)
{
bool found = false;
AbstractBindingVec::iterator it = _bindings.begin();
for (; it != _bindings.end();)
{
if ((*it)->name() == name)
{
it = _bindings.erase(it);
found = true;
}
else ++it;
}
if (!found)
throw NotFoundException(name);
}
std::size_t StatementImpl::columnsExtracted(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = _curDataSet;
if (_columnsExtracted.size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _columnsExtracted.size());
return _columnsExtracted[dataSet];
}
return 0;
}
std::size_t StatementImpl::rowsExtracted(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = _curDataSet;
if (extractions().size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _extractors.size());
if (_extractors[dataSet].size() > 0)
return _extractors[dataSet][0]->numOfRowsHandled();
}
return 0;
}
std::size_t StatementImpl::subTotalRowCount(int dataSet) const
{
if (USE_CURRENT_DATA_SET == dataSet) dataSet = _curDataSet;
if (_subTotalRowCount.size() > 0)
{
poco_assert (dataSet >= 0 && dataSet < _subTotalRowCount.size());
return _subTotalRowCount[dataSet];
}
return 0;
}
void StatementImpl::formatSQL(std::vector<Any>& arguments)
{
std::string sql;
Poco::format(sql, _ostr.str(), arguments);
_ostr.str(""); _ostr << sql;
}
} } // namespace Poco::Data

View File

@@ -1,147 +1,147 @@
//
// Time.cpp
//
// $Id: //poco/Main/Data/src/Time.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Time
//
// 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.
//
#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 {
namespace Data {
Time::Time()
{
DateTime dt;
assign(dt.hour(), dt.minute(), dt.second());
}
Time::Time(int hour, int minute, int second)
{
assign(hour, minute, second);
}
Time::Time(const DateTime& dt)
{
assign(dt.hour(), dt.minute(), dt.second());
}
Time::~Time()
{
}
void Time::assign(int hour, int minute, int second)
{
if (hour < 0 || hour > 23)
throw InvalidArgumentException("Hour must be between 0 and 23.");
if (minute < 0 || minute > 59)
throw InvalidArgumentException("Minute must be between 0 and 59.");
if (second < 0 || second > 59)
throw InvalidArgumentException("Second must be between 0 and 59.");
_hour = hour;
_minute = minute;
_second = second;
}
bool Time::operator < (const Time& time)
{
int hour = time.hour();
if (_hour < hour) return true;
else if (_hour > hour) return false;
else // hours equal
{
int minute = time.minute();
if (_minute < minute) return true;
else
if (_minute > minute) return false;
else // minutes equal
if (_second < time.second()) return true;
}
return false;
}
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
//
// Time.cpp
//
// $Id: //poco/Main/Data/src/Time.cpp#5 $
//
// Library: Data
// Package: DataCore
// Module: Time
//
// 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.
//
#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 {
namespace Data {
Time::Time()
{
DateTime dt;
assign(dt.hour(), dt.minute(), dt.second());
}
Time::Time(int hour, int minute, int second)
{
assign(hour, minute, second);
}
Time::Time(const DateTime& dt)
{
assign(dt.hour(), dt.minute(), dt.second());
}
Time::~Time()
{
}
void Time::assign(int hour, int minute, int second)
{
if (hour < 0 || hour > 23)
throw InvalidArgumentException("Hour must be between 0 and 23.");
if (minute < 0 || minute > 59)
throw InvalidArgumentException("Minute must be between 0 and 59.");
if (second < 0 || second > 59)
throw InvalidArgumentException("Second must be between 0 and 59.");
_hour = hour;
_minute = minute;
_second = second;
}
bool Time::operator < (const Time& time)
{
int hour = time.hour();
if (_hour < hour) return true;
else if (_hour > hour) return false;
else // hours equal
{
int minute = time.minute();
if (_minute < minute) return true;
else
if (_minute > minute) return false;
else // minutes equal
if (_second < time.second()) return true;
}
return false;
}
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

View File

@@ -1,134 +1,134 @@
//
// Transaction.cpp
//
// $Id: //poco/Main/Data/src/Transaction.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: Transaction
//
// 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.
//
#include "Poco/Data/Transaction.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
Transaction::Transaction(Poco::Data::Session& rSession, Poco::Logger* pLogger):
_rSession(rSession),
_pLogger(pLogger)
{
begin();
}
Transaction::Transaction(Poco::Data::Session& rSession, bool start):
_rSession(rSession),
_pLogger(0)
{
if (start) begin();
}
Transaction::~Transaction()
{
if (_rSession.isTransaction())
{
try
{
if (_pLogger)
_pLogger->debug("Rolling back transaction.");
_rSession.rollback();
}
catch (...)
{
if (_pLogger)
_pLogger->error("Error while rolling back database transaction.");
}
}
}
void Transaction::begin()
{
if (!_rSession.isTransaction())
_rSession.begin();
else
throw InvalidAccessException("Transaction in progress.");
}
void Transaction::execute(const std::string& sql, bool doCommit)
{
if (!_rSession.isTransaction()) _rSession.begin();
_rSession << sql, Keywords::now;
if (doCommit) commit();
}
void Transaction::execute(const std::vector<std::string>& sql)
{
try
{
std::vector<std::string>::const_iterator it = sql.begin();
std::vector<std::string>::const_iterator end = sql.end();
for (; it != end; ++it) execute(*it, it + 1 == end ? true : false);
return;
}
catch (Exception& ex)
{
if (_pLogger) _pLogger->error(ex.displayText());
}
rollback();
}
void Transaction::commit()
{
if (_pLogger)
_pLogger->debug("Committing transaction.");
_rSession.commit();
}
void Transaction::rollback()
{
if (_pLogger)
_pLogger->debug("Rolling back transaction.");
_rSession.rollback();
}
} } // namespace Poco::Data
//
// Transaction.cpp
//
// $Id: //poco/Main/Data/src/Transaction.cpp#1 $
//
// Library: Data
// Package: DataCore
// Module: Transaction
//
// 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.
//
#include "Poco/Data/Transaction.h"
#include "Poco/Exception.h"
namespace Poco {
namespace Data {
Transaction::Transaction(Poco::Data::Session& rSession, Poco::Logger* pLogger):
_rSession(rSession),
_pLogger(pLogger)
{
begin();
}
Transaction::Transaction(Poco::Data::Session& rSession, bool start):
_rSession(rSession),
_pLogger(0)
{
if (start) begin();
}
Transaction::~Transaction()
{
if (_rSession.isTransaction())
{
try
{
if (_pLogger)
_pLogger->debug("Rolling back transaction.");
_rSession.rollback();
}
catch (...)
{
if (_pLogger)
_pLogger->error("Error while rolling back database transaction.");
}
}
}
void Transaction::begin()
{
if (!_rSession.isTransaction())
_rSession.begin();
else
throw InvalidAccessException("Transaction in progress.");
}
void Transaction::execute(const std::string& sql, bool doCommit)
{
if (!_rSession.isTransaction()) _rSession.begin();
_rSession << sql, Keywords::now;
if (doCommit) commit();
}
void Transaction::execute(const std::vector<std::string>& sql)
{
try
{
std::vector<std::string>::const_iterator it = sql.begin();
std::vector<std::string>::const_iterator end = sql.end();
for (; it != end; ++it) execute(*it, it + 1 == end ? true : false);
return;
}
catch (Exception& ex)
{
if (_pLogger) _pLogger->error(ex.displayText());
}
rollback();
}
void Transaction::commit()
{
if (_pLogger)
_pLogger->debug("Committing transaction.");
_rSession.commit();
}
void Transaction::rollback()
{
if (_pLogger)
_pLogger->debug("Rolling back transaction.");
_rSession.rollback();
}
} } // namespace Poco::Data