diff options
author | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
---|---|---|
committer | monster <monster@ydb.tech> | 2022-07-07 14:41:37 +0300 |
commit | 06e5c21a835c0e923506c4ff27929f34e00761c2 (patch) | |
tree | 75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /contrib/libs/poco/Foundation | |
parent | 03f024c4412e3aa613bb543cf1660176320ba8f4 (diff) | |
download | ydb-06e5c21a835c0e923506c4ff27929f34e00761c2.tar.gz |
fix ya.make
Diffstat (limited to 'contrib/libs/poco/Foundation')
58 files changed, 1 insertions, 13975 deletions
diff --git a/contrib/libs/poco/Foundation/.yandex_meta/licenses.list.txt b/contrib/libs/poco/Foundation/.yandex_meta/licenses.list.txt deleted file mode 100644 index e7a072fd1f..0000000000 --- a/contrib/libs/poco/Foundation/.yandex_meta/licenses.list.txt +++ /dev/null @@ -1,375 +0,0 @@ -====================BSD-3-Clause==================== - /// licensed under the BSD license. - - -====================BSD-3-Clause==================== -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// 4. Neither the name of the University nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. - - -====================BSL-1.0==================== -// 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. - - -====================BSL-1.0==================== -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. - - -====================BSL-1.0==================== -// SPDX-License-Identifier: BSL-1.0 - - -====================BSL-1.0==================== -Boost Software License - Version 1.0 - August 17th, 2003 - -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. - ---------------------------------------------------------------------------- -Note: -Individual files contain the following tag instead of the full license text. - - SPDX-License-Identifier: BSL-1.0 - -This enables machine processing of license information based on the SPDX -License Identifiers that are here available: http://spdx.org/licenses/ - -====================COPYRIGHT==================== - /// Copyright 2001-2004 Unicode, Inc. - - -====================COPYRIGHT==================== - /// Code taken from the Boost 1.33.1 library. Original copyright by Kevlin Henney. Modified for Poco - /// by Applied Informatics. - - -====================COPYRIGHT==================== -// (C) Copyright Nicolai M. Josuttis 2001. -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. - - -====================COPYRIGHT==================== -// Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -// rights reserved. - - -====================COPYRIGHT==================== -// Copyright (c) 1983, 1993 -// The Regents of the University of California. All rights reserved. - - -====================COPYRIGHT==================== -// Copyright (c) 2001 by Andrei Alexandrescu - - -====================COPYRIGHT==================== -// Copyright (c) 2004-20011, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2009, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2010, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2012, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2014, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2004-2016, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2005-2008, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2006-2016, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2008, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2009, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2009-2010, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2010, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2010-2012, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2013, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2014, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright (c) 2015, Applied Informatics Software Engineering GmbH. -// and Contributors. - - -====================COPYRIGHT==================== -// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved. - - -====================File: CONTRIBUTORS==================== -Guenter Obiltschnig -Alex Fabijanic -Peter Schojer -Ferdinand Beyer -Krzysztof Burghardt -Claus Dabringer -Caleb Epstein -Eran Hammer-Lahav -Chris Johnson -Sergey Kholodilov -Ryan Kraay -Larry Lewis -Andrew J. P. Maclean -Andrew Marlow -Paschal Mushubi -Jiang Shan -David Shawley -Sergey Skorokhodov -Tom Tan -Sergey N. Yatskevich -Marc Chevrier -Philippe Cuvillier -Marian Krivos -Franky Braem -Philip Prindeville -Anton Yabchinskiy -Rangel Reale -Fabrizio Duhem -Patrick White -Mike Naquin -Roger Meier -Mathaus Mendel -Arturo Castro -Adrian Imboden -Matej Knopp -Patrice Tarabbia -Lucas Clemente -Karl Reid -Pascal Bach -Cristian Thiago Moecke -Sergei Nikulov -Aaron Kaluszka -Iyed Bennour -Scott Davis -Kristin Cowalcijk -Yuval Kashtan -Christopher Baker -Scott Davis -Jeff Adams -Martin Osborne -Björn Schramke -Francis Andre - - -====================NCSA==================== -// This file is distributed under the University of Illinois Open Source License - - -====================Public-Domain==================== -// Based on the public domain implementation by Peter C. Gutmann - - -====================RSA-MD==================== -// License to copy and use this software is granted provided that it -// is identified as the "RSA Data Security, Inc. MD5 Message-Digest -// Algorithm" in all material mentioning or referencing this software -// or this function. -// -// License is also granted to make and use derivative works provided -// that such works are identified as "derived from the RSA Data -// Security, Inc. MD5 Message-Digest Algorithm" in all material -// mentioning or referencing the derived work. -// -// RSA Data Security, Inc. makes no representations concerning either -// the merchantability of this software or the suitability of this -// software for any particular purpose. It is provided "as is" -// without express or implied warranty of any kind. -// -// These notices must be retained in any copies of any part of this -// documentation and/or software. - - -====================RSA-MD4==================== -// License to copy and use this software is granted provided that it -// is identified as the "RSA Data Security, Inc. MD4 Message-Digest -// Algorithm" in all material mentioning or referencing this software -// or this function. -// -// License is also granted to make and use derivative works provided -// that such works are identified as "derived from the RSA Data -// Security, Inc. MD4 Message-Digest Algorithm" in all material -// mentioning or referencing the derived work. -// -// RSA Data Security, Inc. makes no representations concerning either -// the merchantability of this software or the suitability of this -// software for any particular purpose. It is provided "as is" -// without express or implied warranty of any kind. -// -// These notices must be retained in any copies of any part of this -// documentation and/or software. diff --git a/contrib/libs/poco/Foundation/CMakeLists.txt b/contrib/libs/poco/Foundation/CMakeLists.txt index e8c98bfd99..c031ddb850 100644 --- a/contrib/libs/poco/Foundation/CMakeLists.txt +++ b/contrib/libs/poco/Foundation/CMakeLists.txt @@ -6,6 +6,6 @@ # original buildsystem will not be accepted. -if (UNIX AND NOT APPLE) +if (UNIX) include(CMakeLists.linux.txt) endif() diff --git a/contrib/libs/poco/Foundation/include/Poco/AbstractCache.h b/contrib/libs/poco/Foundation/include/Poco/AbstractCache.h deleted file mode 100644 index 37cfc25b1e..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/AbstractCache.h +++ /dev/null @@ -1,366 +0,0 @@ -// -// AbstractCache.h -// -// Library: Foundation -// Package: Cache -// Module: AbstractCache -// -// Definition of the AbstractCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_AbstractCache_INCLUDED -#define Foundation_AbstractCache_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/Mutex.h" -#include "Poco/Exception.h" -#include "Poco/FIFOEvent.h" -#include "Poco/EventArgs.h" -#include "Poco/Delegate.h" -#include "Poco/SharedPtr.h" -#include <map> -#include <set> -#include <cstddef> - - -namespace Poco { - - -template <class TKey, class TValue, class TStrategy, class TMutex = FastMutex, class TEventMutex = FastMutex> -class AbstractCache - /// An AbstractCache is the interface of all caches. -{ -public: - FIFOEvent<const KeyValueArgs<TKey, TValue >, TEventMutex > Add; - FIFOEvent<const KeyValueArgs<TKey, TValue >, TEventMutex > Update; - FIFOEvent<const TKey, TEventMutex> Remove; - FIFOEvent<const TKey, TEventMutex> Get; - FIFOEvent<const EventArgs, TEventMutex> Clear; - - typedef std::map<TKey, SharedPtr<TValue > > DataHolder; - typedef typename DataHolder::iterator Iterator; - typedef typename DataHolder::const_iterator ConstIterator; - typedef std::set<TKey> KeySet; - - AbstractCache() - { - initialize(); - } - - AbstractCache(const TStrategy& strat): _strategy(strat) - { - initialize(); - } - - virtual ~AbstractCache() - { - try - { - uninitialize(); - } - catch (...) - { - poco_unexpected(); - } - } - - void add(const TKey& key, const TValue& val) - /// Adds the key value pair to the cache. - /// If for the key already an entry exists, it will be overwritten. - { - typename TMutex::ScopedLock lock(_mutex); - doAdd(key, val); - } - - void update(const TKey& key, const TValue& val) - /// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail! - /// If for the key already an entry exists, it will be overwritten. - /// The difference to add is that no remove or add events are thrown in this case, - /// just a simply silent update is performed - /// If the key doesnot exist the behavior is equal to add, ie. an add event is thrown - { - typename TMutex::ScopedLock lock(_mutex); - doUpdate(key, val); - } - - void add(const TKey& key, SharedPtr<TValue > val) - /// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail! - /// If for the key already an entry exists, it will be overwritten, ie. first a remove event - /// is thrown, then a add event - { - typename TMutex::ScopedLock lock(_mutex); - doAdd(key, val); - } - - void update(const TKey& key, SharedPtr<TValue > val) - /// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail! - /// If for the key already an entry exists, it will be overwritten. - /// The difference to add is that no remove or add events are thrown in this case, - /// just an Update is thrown - /// If the key doesnot exist the behavior is equal to add, ie. an add event is thrown - { - typename TMutex::ScopedLock lock(_mutex); - doUpdate(key, val); - } - - void remove(const TKey& key) - /// Removes an entry from the cache. If the entry is not found, - /// the remove is ignored. - { - typename TMutex::ScopedLock lock(_mutex); - Iterator it = _data.find(key); - doRemove(it); - } - - bool has(const TKey& key) const - /// Returns true if the cache contains a value for the key. - { - typename TMutex::ScopedLock lock(_mutex); - return doHas(key); - } - - SharedPtr<TValue> get(const TKey& key) - /// Returns a SharedPtr of the value. The SharedPointer will remain valid - /// even when cache replacement removes the element. - /// If for the key no value exists, an empty SharedPtr is returned. - { - typename TMutex::ScopedLock lock(_mutex); - return doGet (key); - } - - void clear() - /// Removes all elements from the cache. - { - typename TMutex::ScopedLock lock(_mutex); - doClear(); - } - - std::size_t size() - /// Returns the number of cached elements - { - typename TMutex::ScopedLock lock(_mutex); - doReplace(); - return _data.size(); - } - - void forceReplace() - /// Forces cache replacement. Note that Poco's cache strategy use for efficiency reason no background thread - /// which periodically triggers cache replacement. Cache Replacement is only started when the cache is modified - /// from outside, i.e. add is called, or when a user tries to access an cache element via get. - /// In some cases, i.e. expire based caching where for a long time no access to the cache happens, - /// it might be desirable to be able to trigger cache replacement manually. - { - typename TMutex::ScopedLock lock(_mutex); - doReplace(); - } - - std::set<TKey> getAllKeys() - /// Returns a copy of all keys stored in the cache - { - typename TMutex::ScopedLock lock(_mutex); - doReplace(); - ConstIterator it = _data.begin(); - ConstIterator itEnd = _data.end(); - std::set<TKey> result; - for (; it != itEnd; ++it) - result.insert(it->first); - - return result; - } - -protected: - mutable FIFOEvent<ValidArgs<TKey> > IsValid; - mutable FIFOEvent<KeySet> Replace; - - void initialize() - /// Sets up event registration. - { - Add += Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onAdd); - Update += Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onUpdate); - Remove += Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onRemove); - Get += Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onGet); - Clear += Delegate<TStrategy, const EventArgs>(&_strategy, &TStrategy::onClear); - IsValid += Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid); - Replace += Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace); - } - - void uninitialize() - /// Reverts event registration. - { - Add -= Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onAdd ); - Update -= Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onUpdate); - Remove -= Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onRemove); - Get -= Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onGet); - Clear -= Delegate<TStrategy, const EventArgs>(&_strategy, &TStrategy::onClear); - IsValid -= Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid); - Replace -= Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace); - } - - void doAdd(const TKey& key, const TValue& val) - /// Adds the key value pair to the cache. - /// If for the key already an entry exists, it will be overwritten. - { - Iterator it = _data.find(key); - doRemove(it); - - KeyValueArgs<TKey, TValue> args(key, val); - Add.notify(this, args); - _data.insert(std::make_pair(key, SharedPtr<TValue>(new TValue(val)))); - - doReplace(); - } - - void doAdd(const TKey& key, SharedPtr<TValue>& val) - /// Adds the key value pair to the cache. - /// If for the key already an entry exists, it will be overwritten. - { - Iterator it = _data.find(key); - doRemove(it); - - KeyValueArgs<TKey, TValue> args(key, *val); - Add.notify(this, args); - _data.insert(std::make_pair(key, val)); - - doReplace(); - } - - void doUpdate(const TKey& key, const TValue& val) - /// Adds the key value pair to the cache. - /// If for the key already an entry exists, it will be overwritten. - { - KeyValueArgs<TKey, TValue> args(key, val); - Iterator it = _data.find(key); - if (it == _data.end()) - { - Add.notify(this, args); - _data.insert(std::make_pair(key, SharedPtr<TValue>(new TValue(val)))); - } - else - { - Update.notify(this, args); - it->second = SharedPtr<TValue>(new TValue(val)); - } - - doReplace(); - } - - void doUpdate(const TKey& key, SharedPtr<TValue>& val) - /// Adds the key value pair to the cache. - /// If for the key already an entry exists, it will be overwritten. - { - KeyValueArgs<TKey, TValue> args(key, *val); - Iterator it = _data.find(key); - if (it == _data.end()) - { - Add.notify(this, args); - _data.insert(std::make_pair(key, val)); - } - else - { - Update.notify(this, args); - it->second = val; - } - - doReplace(); - } - - void doRemove(Iterator it) - /// Removes an entry from the cache. If the entry is not found - /// the remove is ignored. - { - if (it != _data.end()) - { - Remove.notify(this, it->first); - _data.erase(it); - } - } - - bool doHas(const TKey& key) const - /// Returns true if the cache contains a value for the key - { - // ask the strategy if the key is valid - ConstIterator it = _data.find(key); - bool result = false; - - if (it != _data.end()) - { - ValidArgs<TKey> args(key); - IsValid.notify(this, args); - result = args.isValid(); - } - - return result; - } - - SharedPtr<TValue> doGet(const TKey& key) - /// Returns a SharedPtr of the cache entry, returns 0 if for - /// the key no value was found - { - Iterator it = _data.find(key); - SharedPtr<TValue> result; - - if (it != _data.end()) - { - // inform all strategies that a read-access to an element happens - Get.notify(this, key); - // ask all strategies if the key is valid - ValidArgs<TKey> args(key); - IsValid.notify(this, args); - - if (!args.isValid()) - { - doRemove(it); - } - else - { - result = it->second; - } - } - - return result; - } - - void doClear() - { - static EventArgs _emptyArgs; - Clear.notify(this, _emptyArgs); - _data.clear(); - } - - void doReplace() - { - std::set<TKey> delMe; - Replace.notify(this, delMe); - // delMe contains the to be removed elements - typename std::set<TKey>::const_iterator it = delMe.begin(); - typename std::set<TKey>::const_iterator endIt = delMe.end(); - - for (; it != endIt; ++it) - { - Iterator itH = _data.find(*it); - doRemove(itH); - } - } - - TStrategy _strategy; - mutable DataHolder _data; - mutable TMutex _mutex; - -private: - AbstractCache(const AbstractCache& aCache); - AbstractCache& operator = (const AbstractCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_AbstractCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/AbstractPriorityDelegate.h b/contrib/libs/poco/Foundation/include/Poco/AbstractPriorityDelegate.h deleted file mode 100644 index c27bc0c3f4..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/AbstractPriorityDelegate.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// AbstractPriorityDelegate.h -// -// Library: Foundation -// Package: Events -// Module: AbstractPriorityDelegate -// -// Implementation of the AbstractPriorityDelegate template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_AbstractPriorityDelegate_INCLUDED -#define Foundation_AbstractPriorityDelegate_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/AbstractDelegate.h" - - -namespace Poco { - - -template <class TArgs> -class AbstractPriorityDelegate: public AbstractDelegate<TArgs> - /// Base class for PriorityDelegate and PriorityExpire. - /// - /// Extends AbstractDelegate with a priority value. -{ -public: - AbstractPriorityDelegate(int prio): - _priority(prio) - { - } - - AbstractPriorityDelegate(const AbstractPriorityDelegate& del): - AbstractDelegate<TArgs>(del), - _priority(del._priority) - { - } - - virtual ~AbstractPriorityDelegate() - { - } - - int priority() const - { - return _priority; - } - -protected: - int _priority; -}; - - -} // namespace Poco - - -#endif // Foundation_AbstractPriorityDelegate_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/AbstractStrategy.h b/contrib/libs/poco/Foundation/include/Poco/AbstractStrategy.h deleted file mode 100644 index 8d0ac25a22..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/AbstractStrategy.h +++ /dev/null @@ -1,77 +0,0 @@ -// -// AbstractStrategy.h -// -// Library: Foundation -// Package: Cache -// Module: AbstractCache -// -// Definition of the AbstractStrategy class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_AbstractStrategy_INCLUDED -#define Foundation_AbstractStrategy_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/EventArgs.h" -#include <set> - - -namespace Poco { - - -template <class TKey, class TValue> -class AbstractStrategy - /// An AbstractStrategy is the interface for all strategies. -{ -public: - AbstractStrategy() - { - } - - virtual ~AbstractStrategy() - { - } - - virtual void onUpdate(const void* pSender, const KeyValueArgs <TKey, TValue>& args) - /// Updates an existing entry. - { - onRemove(pSender,args.key()); - onAdd(pSender, args); - } - - virtual void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key) = 0; - /// Adds the key to the strategy. - /// If for the key already an entry exists, an exception will be thrown. - - virtual void onRemove(const void* pSender, const TKey& key) = 0; - /// Removes an entry from the strategy. If the entry is not found - /// the remove is ignored. - - virtual void onGet(const void* pSender, const TKey& key) = 0; - /// Informs the strategy that a read-access happens to an element. - - virtual void onClear(const void* pSender, const EventArgs& args) = 0; - /// Removes all elements from the cache. - - virtual void onIsValid(const void* pSender, ValidArgs<TKey>& key) = 0; - /// Used to query if a key is still valid (i.e. cached). - - virtual void onReplace(const void* pSender, std::set<TKey>& elemsToRemove) = 0; - /// Used by the Strategy to indicate which elements should be removed from - /// the cache. Note that onReplace does not change the current list of keys. - /// The cache object is reponsible to remove the elements. -}; - - -} // namespace Poco - - -#endif // Foundation_AbstractStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/AccessExpirationDecorator.h b/contrib/libs/poco/Foundation/include/Poco/AccessExpirationDecorator.h deleted file mode 100644 index 9978185ffc..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/AccessExpirationDecorator.h +++ /dev/null @@ -1,83 +0,0 @@ -// -// AccessExpirationDecorator.h -// -// Library: Foundation -// Package: Cache -// Module: AccessExpirationDecorator -// -// Implementation of the AccessExpirationDecorator template. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_AccessExpirationDecorator_INCLUDED -#define Foundation_AccessExpirationDecorator_INCLUDED - - -#include "Poco/Timestamp.h" -#include "Poco/Timespan.h" - - -namespace Poco { - - -template <typename TArgs> -class AccessExpirationDecorator - /// AccessExpirationDecorator adds an expiration method to values so that they can be used - /// with the UniqueAccessExpireCache -{ -public: - AccessExpirationDecorator(): - _value(), - _span() - { - } - - AccessExpirationDecorator(const TArgs& p, const Poco::Timespan::TimeDiff& diffInMs): - /// Creates an element that will expire in diff milliseconds - _value(p), - _span(diffInMs*1000) - { - } - - AccessExpirationDecorator(const TArgs& p, const Poco::Timespan& timeSpan): - /// Creates an element that will expire after the given timeSpan - _value(p), - _span(timeSpan) - { - } - - - ~AccessExpirationDecorator() - { - } - - const Poco::Timespan& getTimeout() const - { - return _span; - } - - const TArgs& value() const - { - return _value; - } - - TArgs& value() - { - return _value; - } - -private: - TArgs _value; - Timespan _span; -}; - - -} // namespace Poco - - -#endif // Foundation_AccessExpirationDecorator_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/AccessExpireCache.h b/contrib/libs/poco/Foundation/include/Poco/AccessExpireCache.h deleted file mode 100644 index bb5c571526..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/AccessExpireCache.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// AccessExpireCache.h -// -// Library: Foundation -// Package: Cache -// Module: AccessExpireCache -// -// Definition of the AccessExpireCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_AccessExpireCache_INCLUDED -#define Foundation_AccessExpireCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/AccessExpireStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class AccessExpireCache: public AbstractCache<TKey, TValue, AccessExpireStrategy<TKey, TValue>, TMutex, TEventMutex> - /// An AccessExpireCache caches entries for a fixed time period (per default 10 minutes). - /// Entries expire when they are not accessed with get() during this time period. Each access resets - /// the start time for expiration. - /// Be careful when using an AccessExpireCache. A cache is often used - /// like cache.has(x) followed by cache.get x). Note that it could happen - /// that the "has" call works, then the current execution thread gets descheduled, time passes, - /// the entry gets invalid, thus leading to an empty SharedPtr being returned - /// when "get" is invoked. -{ -public: - AccessExpireCache(Timestamp::TimeDiff expire = 600000): - AbstractCache<TKey, TValue, AccessExpireStrategy<TKey, TValue>, TMutex, TEventMutex>(AccessExpireStrategy<TKey, TValue>(expire)) - { - } - - ~AccessExpireCache() - { - } - -private: - AccessExpireCache(const AccessExpireCache& aCache); - AccessExpireCache& operator = (const AccessExpireCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_AccessExpireCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/AccessExpireLRUCache.h b/contrib/libs/poco/Foundation/include/Poco/AccessExpireLRUCache.h deleted file mode 100644 index 278cbbccd1..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/AccessExpireLRUCache.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// AccessExpireLRUCache.h -// -// Library: Foundation -// Package: Cache -// Module: AccessExpireLRUCache -// -// Definition of the AccessExpireLRUCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_AccessExpireLRUCache_INCLUDED -#define Foundation_AccessExpireLRUCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/StrategyCollection.h" -#include "Poco/AccessExpireStrategy.h" -#include "Poco/LRUStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class AccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex> - /// An AccessExpireLRUCache combines LRU caching and time based expire caching. - /// It cache entries for a fixed time period (per default 10 minutes) - /// but also limits the size of the cache (per default: 1024). -{ -public: - AccessExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000): - AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex >(StrategyCollection<TKey, TValue>()) - { - this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); - this->_strategy.pushBack(new AccessExpireStrategy<TKey, TValue>(expire)); - } - - ~AccessExpireLRUCache() - { - } - -private: - AccessExpireLRUCache(const AccessExpireLRUCache& aCache); - AccessExpireLRUCache& operator = (const AccessExpireLRUCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_AccessExpireLRUCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/AccessExpireStrategy.h b/contrib/libs/poco/Foundation/include/Poco/AccessExpireStrategy.h deleted file mode 100644 index 3bfa45c21f..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/AccessExpireStrategy.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// AccessExpireStrategy.h -// -// Library: Foundation -// Package: Cache -// Module: AccessExpireStrategy -// -// Definition of the AccessExpireStrategy class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_AccessExpireStrategy_INCLUDED -#define Foundation_AccessExpireStrategy_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/ExpireStrategy.h" -#include "Poco/Bugcheck.h" -#include "Poco/Timestamp.h" -#include "Poco/EventArgs.h" -#include <set> -#include <map> - - -namespace Poco { - - -template < - class TKey, - class TValue -> -class AccessExpireStrategy: public ExpireStrategy<TKey, TValue> - /// An AccessExpireStrategy implements time and access based expiration of cache entries -{ -public: - AccessExpireStrategy(Timestamp::TimeDiff expireTimeInMilliSec): ExpireStrategy<TKey, TValue>(expireTimeInMilliSec) - /// Create an expire strategy. Note that the smallest allowed caching time is 25ms. - /// Anything lower than that is not useful with current operating systems. - { - } - - ~AccessExpireStrategy() - { - } - - void onGet(const void*, const TKey& key) - { - // get triggers an update to the expiration time - typename ExpireStrategy<TKey, TValue>::Iterator it = this->_keys.find(key); - if (it != this->_keys.end()) - { - if (!it->second->first.isElapsed(this->_expireTime)) // don't extend if already expired - { - this->_keyIndex.erase(it->second); - Timestamp now; - typename ExpireStrategy<TKey, TValue>::IndexIterator itIdx = - this->_keyIndex.insert(typename ExpireStrategy<TKey, TValue>::TimeIndex::value_type(now, key)); - it->second = itIdx; - } - } - } -}; - - -} // namespace Poco - - -#endif // Foundation_AccessExpireStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/Activity.h b/contrib/libs/poco/Foundation/include/Poco/Activity.h deleted file mode 100644 index a7297f144f..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/Activity.h +++ /dev/null @@ -1,208 +0,0 @@ -// -// Activity.h -// -// Library: Foundation -// Package: Threading -// Module: ActiveObjects -// -// Definition of the Activity template class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_Activity_INCLUDED -#define Foundation_Activity_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/RunnableAdapter.h" -#include "Poco/ThreadPool.h" -#include "Poco/Event.h" -#include "Poco/Mutex.h" - - -namespace Poco { - - -template <class C> -class Activity: public Runnable - /// This template class helps to implement active objects. - /// An active object uses threads to decouple method - /// execution from method invocation, or to perform tasks - /// autonomously, without intervention of a caller. - /// - /// An activity is a (typically longer running) method - /// that executes within its own task. Activities can - /// be started automatically (upon object construction) - /// or manually at a later time. Activities can also - /// be stopped at any time. However, to make stopping - /// an activity work, the method implementing the - /// activity has to check periodically whether it - /// has been requested to stop, and if so, return. - /// Activities are stopped before the object they belong to is - /// destroyed. Methods implementing activities cannot have arguments - /// or return values. - /// - /// Activity objects are used as follows: - /// - /// class ActiveObject - /// { - /// public: - /// ActiveObject(): - /// _activity(this, &ActiveObject::runActivity) - /// { - /// ... - /// } - /// - /// ... - /// - /// protected: - /// void runActivity() - /// { - /// while (!_activity.isStopped()) - /// { - /// ... - /// } - /// } - /// - /// private: - /// Activity<ActiveObject> _activity; - /// }; -{ -public: - typedef RunnableAdapter<C> RunnableAdapterType; - typedef typename RunnableAdapterType::Callback Callback; - - Activity(C* pOwner, Callback method): - _pOwner(pOwner), - _runnable(*pOwner, method), - _stopped(true), - _running(false), - _done(false) - /// Creates the activity. Call start() to - /// start it. - { - poco_check_ptr (pOwner); - } - - ~Activity() - /// Stops and destroys the activity. - { - try - { - stop(); - wait(); - } - catch (...) - { - poco_unexpected(); - } - } - - void start() - /// Starts the activity by acquiring a - /// thread for it from the default thread pool. - { - start(ThreadPool::defaultPool()); - } - - void start(ThreadPool& pool) - { - FastMutex::ScopedLock lock(_mutex); - - if (!_running) - { - _done.reset(); - _stopped = false; - _running = true; - try - { - pool.start(*this); - } - catch (...) - { - _running = false; - throw; - } - } - } - - void stop() - /// Requests to stop the activity. - { - FastMutex::ScopedLock lock(_mutex); - - _stopped = true; - } - - void wait() - /// Waits for the activity to complete. - { - if (_running) - { - _done.wait(); - } - } - - void wait(long milliseconds) - /// Waits the given interval for the activity to complete. - /// An TimeoutException is thrown if the activity does not - /// complete within the given interval. - { - if (_running) - { - _done.wait(milliseconds); - } - } - - bool isStopped() const - /// Returns true if the activity has been requested to stop. - { - return _stopped; - } - - bool isRunning() const - /// Returns true if the activity is running. - { - return _running; - } - -protected: - void run() - { - try - { - _runnable.run(); - } - catch (...) - { - _running = false; - _done.set(); - throw; - } - _running = false; - _done.set(); - } - -private: - Activity(); - Activity(const Activity&); - Activity& operator = (const Activity&); - - C* _pOwner; - RunnableAdapterType _runnable; - volatile bool _stopped; - volatile bool _running; - Event _done; - FastMutex _mutex; -}; - - -} // namespace Poco - - -#endif // Foundation_Activity_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/Array.h b/contrib/libs/poco/Foundation/include/Poco/Array.h deleted file mode 100644 index 76e5faed89..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/Array.h +++ /dev/null @@ -1,249 +0,0 @@ -// -// Array.h -// -// Library: Foundation -// Package: Core -// Module: Array -// -// Definition of the Array class -// -// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// -// ------------------------------------------------------------------------------ -// (C) Copyright Nicolai M. Josuttis 2001. -// Permission to copy, use, modify, sell and distribute this software -// is granted provided this copyright notice appears in all copies. -// This software is provided "as is" without express or implied -// warranty, and with no claim as to its suitability for any purpose. -// ------------------------------------------------------------------------------ - - -#ifndef Foundation_Array_INCLUDED -#define Foundation_Array_INCLUDED - -#include "Poco/Exception.h" -#include "Poco/Bugcheck.h" -#include <algorithm> - -namespace Poco { - -template<class T, std::size_t N> -class Array - /// STL container like C-style array replacement class. - /// - /// This implementation is based on the idea of Nicolai Josuttis. - /// His original implementation can be found at http://www.josuttis.com/cppcode/array.html . -{ - -public: - - typedef T value_type; - typedef T* iterator; - typedef const T* const_iterator; - typedef T& reference; - typedef const T& const_reference; - typedef std::size_t size_type; - typedef std::ptrdiff_t difference_type; - - iterator begin() - { - return elems; - } - - const_iterator begin() const - { - return elems; - } - - iterator end() - { - return elems+N; - } - - const_iterator end() const - { - return elems+N; - } - - typedef std::reverse_iterator<iterator> reverse_iterator; - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - - reverse_iterator rbegin() - { - return reverse_iterator(end()); - } - - const_reverse_iterator rbegin() const - { - return const_reverse_iterator(end()); - } - - reverse_iterator rend() - { - return reverse_iterator(begin()); - } - - const_reverse_iterator rend() const - { - return const_reverse_iterator(begin()); - } - - reference operator[](size_type i) - /// Element access without range check. If the index is not small than the given size, the behavior is undefined. - { - poco_assert( i < N && "out of range" ); - return elems[i]; - } - - const_reference operator[](size_type i) const - /// Element access without range check. If the index is not small than the given size, the behavior is undefined. - { - poco_assert( i < N && "out of range" ); - return elems[i]; - } - - reference at(size_type i) - /// Element access with range check. Throws Poco::InvalidArgumentException if the index is over range. - { - if(i>=size()) - throw Poco::InvalidArgumentException("Array::at() range check failed: index is over range"); - return elems[i]; - } - - const_reference at(size_type i) const - /// Element access with range check. Throws Poco::InvalidArgumentException if the index is over range. - { - if(i>=size()) - throw Poco::InvalidArgumentException("Array::at() range check failed: index is over range"); - return elems[i]; - } - - reference front() - { - return elems[0]; - } - - const_reference front() const - { - return elems[0]; - } - - reference back() - { - return elems[N-1]; - } - - const_reference back() const - { - return elems[N-1]; - } - - static size_type size() - { - return N; - } - - static bool empty() - { - return false; - } - - static size_type max_size() - { - return N; - } - - enum { static_size = N }; - - void swap (Array<T,N>& y) { - std::swap_ranges(begin(),end(),y.begin()); - } - - const T* data() const - /// Direct access to data (read-only) - { - return elems; - } - - T* data() - { - return elems; - } - - T* c_array(){ - /// Use array as C array (direct read/write access to data) - return elems; - } - - template <typename Other> - Array<T,N>& operator= (const Array<Other,N>& rhs) - /// Assignment with type conversion - { - std::copy(rhs.begin(),rhs.end(), begin()); - return *this; - } - - void assign (const T& value) - /// Assign one value to all elements - { - std::fill_n(begin(),size(),value); - } - -public: - - T elems[N]; - /// Fixed-size array of elements of type T, public specifier used to make this class a aggregate. - -}; - -// comparisons -template<class T, std::size_t N> -bool operator== (const Array<T,N>& x, const Array<T,N>& y) -{ - return std::equal(x.begin(), x.end(), y.begin()); -} - -template<class T, std::size_t N> -bool operator< (const Array<T,N>& x, const Array<T,N>& y) -{ - return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); -} - -template<class T, std::size_t N> -bool operator!= (const Array<T,N>& x, const Array<T,N>& y) -{ - return !(x==y); -} - -template<class T, std::size_t N> -bool operator> (const Array<T,N>& x, const Array<T,N>& y) -{ - return y<x; -} - -template<class T, std::size_t N> -bool operator<= (const Array<T,N>& x, const Array<T,N>& y) -{ - return !(y<x); -} - -template<class T, std::size_t N> -bool operator>= (const Array<T,N>& x, const Array<T,N>& y) -{ - return !(x<y); -} - -template<class T, std::size_t N> -inline void swap (Array<T,N>& x, Array<T,N>& y) - /// global swap() -{ - x.swap(y); -} - -}// namespace Poco - -#endif // Foundation_Array_INCLUDED - diff --git a/contrib/libs/poco/Foundation/include/Poco/ClassLibrary.h b/contrib/libs/poco/Foundation/include/Poco/ClassLibrary.h deleted file mode 100644 index 14b10acb3d..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ClassLibrary.h +++ /dev/null @@ -1,101 +0,0 @@ -// -// ClassLibrary.h -// -// Library: Foundation -// Package: SharedLibrary -// Module: ClassLoader -// -// Definitions for class libraries. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ClassLibrary_INCLUDED -#define Foundation_ClassLibrary_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Manifest.h" -#include <typeinfo> - - -#if defined(_WIN32) - #define POCO_LIBRARY_API __declspec(dllexport) -#else - #define POCO_LIBRARY_API -#endif - - -// -// the entry points for every class library -// -extern "C" -{ - bool POCO_LIBRARY_API pocoBuildManifest(Poco::ManifestBase* pManifest); - void POCO_LIBRARY_API pocoInitializeLibrary(); - void POCO_LIBRARY_API pocoUninitializeLibrary(); -} - - -// -// additional support for named manifests -// -#define POCO_DECLARE_NAMED_MANIFEST(name) \ -extern "C" \ -{ \ - bool POCO_LIBRARY_API POCO_JOIN(pocoBuildManifest, name)(Poco::ManifestBase* pManifest); \ -} - - -// -// Macros to automatically implement pocoBuildManifest -// -// usage: -// -// POCO_BEGIN_MANIFEST(MyBaseClass) -// POCO_EXPORT_CLASS(MyFirstClass) -// POCO_EXPORT_CLASS(MySecondClass) -// ... -// POCO_END_MANIFEST -// -#define POCO_BEGIN_MANIFEST_IMPL(fnName, base) \ - bool fnName(Poco::ManifestBase* pManifest_) \ - { \ - typedef base _Base; \ - typedef Poco::Manifest<_Base> _Manifest; \ - std::string requiredType(typeid(_Manifest).name()); \ - std::string actualType(pManifest_->className()); \ - if (requiredType == actualType) \ - { \ - Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_); - - -#define POCO_BEGIN_MANIFEST(base) \ - POCO_BEGIN_MANIFEST_IMPL(pocoBuildManifest, base) - - -#define POCO_BEGIN_NAMED_MANIFEST(name, base) \ - POCO_DECLARE_NAMED_MANIFEST(name) \ - POCO_BEGIN_MANIFEST_IMPL(POCO_JOIN(pocoBuildManifest, name), base) - - -#define POCO_END_MANIFEST \ - return true; \ - } \ - else return false; \ - } - - -#define POCO_EXPORT_CLASS(cls) \ - pManifest->insert(new Poco::MetaObject<cls, _Base>(#cls)); - - -#define POCO_EXPORT_SINGLETON(cls) \ - pManifest->insert(new Poco::MetaSingleton<cls, _Base>(#cls)); - - -#endif // Foundation_ClassLibrary_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/ClassLoader.h b/contrib/libs/poco/Foundation/include/Poco/ClassLoader.h deleted file mode 100644 index 450aec2928..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ClassLoader.h +++ /dev/null @@ -1,365 +0,0 @@ -// -// ClassLoader.h -// -// Library: Foundation -// Package: SharedLibrary -// Module: ClassLoader -// -// Definition of the ClassLoader class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ClassLoader_INCLUDED -#define Foundation_ClassLoader_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/MetaObject.h" -#include "Poco/Manifest.h" -#include "Poco/SharedLibrary.h" -#include "Poco/Mutex.h" -#include "Poco/Exception.h" -#include <map> - - -namespace Poco { - - -template <class Base> -class ClassLoader - /// The ClassLoader loads C++ classes from shared libraries - /// at runtime. It must be instantiated with a root class - /// of the loadable classes. - /// For a class to be loadable from a library, the library - /// must provide a Manifest of all the classes it contains. - /// The Manifest for a shared library can be easily built - /// with the help of the macros in the header file - /// "Foundation/ClassLibrary.h". - /// - /// Starting with POCO release 1.3, a class library can - /// export multiple manifests. In addition to the default - /// (unnamed) manifest, multiple named manifests can - /// be exported, each having a different base class. - /// - /// There is one important restriction: one instance of - /// ClassLoader can only load one manifest from a class - /// library. -{ -public: - typedef AbstractMetaObject<Base> Meta; - typedef Manifest<Base> Manif; - typedef void (*InitializeLibraryFunc)(); - typedef void (*UninitializeLibraryFunc)(); - typedef bool (*BuildManifestFunc)(ManifestBase*); - - struct LibraryInfo - { - SharedLibrary* pLibrary; - const Manif* pManifest; - int refCount; - }; - typedef std::map<std::string, LibraryInfo> LibraryMap; - - class Iterator - /// The ClassLoader's very own iterator class. - { - public: - typedef std::pair<std::string, const Manif*> Pair; - - Iterator(const typename LibraryMap::const_iterator& it) - { - _it = it; - } - Iterator(const Iterator& it) - { - _it = it._it; - } - ~Iterator() - { - } - Iterator& operator = (const Iterator& it) - { - _it = it._it; - return *this; - } - inline bool operator == (const Iterator& it) const - { - return _it == it._it; - } - inline bool operator != (const Iterator& it) const - { - return _it != it._it; - } - Iterator& operator ++ () // prefix - { - ++_it; - return *this; - } - Iterator operator ++ (int) // postfix - { - Iterator result(_it); - ++_it; - return result; - } - inline const Pair* operator * () const - { - _pair.first = _it->first; - _pair.second = _it->second.pManifest; - return &_pair; - } - inline const Pair* operator -> () const - { - _pair.first = _it->first; - _pair.second = _it->second.pManifest; - return &_pair; - } - - private: - typename LibraryMap::const_iterator _it; - mutable Pair _pair; - }; - - ClassLoader() - /// Creates the ClassLoader. - { - } - - virtual ~ClassLoader() - /// Destroys the ClassLoader. - { - for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it) - { - delete it->second.pLibrary; - delete it->second.pManifest; - } - } - - void loadLibrary(const std::string& path, const std::string& manifest) - /// Loads a library from the given path, using the given manifest. - /// Does nothing if the library is already loaded. - /// Throws a LibraryLoadException if the library - /// cannot be loaded or does not have a Manifest. - /// If the library exports a function named "pocoInitializeLibrary", - /// this function is executed. - /// If called multiple times for the same library, - /// the number of calls to unloadLibrary() must be the same - /// for the library to become unloaded. - { - FastMutex::ScopedLock lock(_mutex); - - typename LibraryMap::iterator it = _map.find(path); - if (it == _map.end()) - { - LibraryInfo li; - li.pLibrary = 0; - li.pManifest = 0; - li.refCount = 1; - try - { - li.pLibrary = new SharedLibrary(path); - li.pManifest = new Manif(); - std::string pocoBuildManifestSymbol("pocoBuildManifest"); - pocoBuildManifestSymbol.append(manifest); - if (li.pLibrary->hasSymbol("pocoInitializeLibrary")) - { - InitializeLibraryFunc initializeLibrary = (InitializeLibraryFunc) li.pLibrary->getSymbol("pocoInitializeLibrary"); - initializeLibrary(); - } - if (li.pLibrary->hasSymbol(pocoBuildManifestSymbol)) - { - BuildManifestFunc buildManifest = (BuildManifestFunc) li.pLibrary->getSymbol(pocoBuildManifestSymbol); - if (buildManifest(const_cast<Manif*>(li.pManifest))) - _map[path] = li; - else - throw LibraryLoadException(std::string("Manifest class mismatch in ") + path, manifest); - } - else throw LibraryLoadException(std::string("No manifest in ") + path, manifest); - } - catch (...) - { - delete li.pLibrary; - delete li.pManifest; - throw; - } - } - else - { - ++it->second.refCount; - } - } - - void loadLibrary(const std::string& path) - /// Loads a library from the given path. Does nothing - /// if the library is already loaded. - /// Throws a LibraryLoadException if the library - /// cannot be loaded or does not have a Manifest. - /// If the library exports a function named "pocoInitializeLibrary", - /// this function is executed. - /// If called multiple times for the same library, - /// the number of calls to unloadLibrary() must be the same - /// for the library to become unloaded. - /// - /// Equivalent to loadLibrary(path, ""). - { - loadLibrary(path, ""); - } - - void unloadLibrary(const std::string& path) - /// Unloads the given library. - /// Be extremely cautious when unloading shared libraries. - /// If objects from the library are still referenced somewhere, - /// a total crash is very likely. - /// If the library exports a function named "pocoUninitializeLibrary", - /// this function is executed before it is unloaded. - /// If loadLibrary() has been called multiple times for the same - /// library, the number of calls to unloadLibrary() must be the same - /// for the library to become unloaded. - { - FastMutex::ScopedLock lock(_mutex); - - typename LibraryMap::iterator it = _map.find(path); - if (it != _map.end()) - { - if (--it->second.refCount == 0) - { - if (it->second.pLibrary->hasSymbol("pocoUninitializeLibrary")) - { - UninitializeLibraryFunc uninitializeLibrary = (UninitializeLibraryFunc) it->second.pLibrary->getSymbol("pocoUninitializeLibrary"); - uninitializeLibrary(); - } - delete it->second.pManifest; - it->second.pLibrary->unload(); - delete it->second.pLibrary; - _map.erase(it); - } - } - else throw NotFoundException(path); - } - - const Meta* findClass(const std::string& className) const - /// Returns a pointer to the MetaObject for the given - /// class, or a null pointer if the class is not known. - { - FastMutex::ScopedLock lock(_mutex); - - for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it) - { - const Manif* pManif = it->second.pManifest; - typename Manif::Iterator itm = pManif->find(className); - if (itm != pManif->end()) - return *itm; - } - return 0; - } - - const Meta& classFor(const std::string& className) const - /// Returns a reference to the MetaObject for the given - /// class. Throws a NotFoundException if the class - /// is not known. - { - const Meta* pMeta = findClass(className); - if (pMeta) - return *pMeta; - else - throw NotFoundException(className); - } - - Base* create(const std::string& className) const - /// Creates an instance of the given class. - /// Throws a NotFoundException if the class - /// is not known. - { - return classFor(className).create(); - } - - Base& instance(const std::string& className) const - /// Returns a reference to the sole instance of - /// the given class. The class must be a singleton, - /// otherwise an InvalidAccessException will be thrown. - /// Throws a NotFoundException if the class - /// is not known. - { - return classFor(className).instance(); - } - - bool canCreate(const std::string& className) const - /// Returns true if create() can create new instances - /// of the class. - { - return classFor(className).canCreate(); - } - - void destroy(const std::string& className, Base* pObject) const - /// Destroys the object pObject points to. - /// Does nothing if object is not found. - { - classFor(className).destroy(pObject); - } - - bool isAutoDelete(const std::string& className, Base* pObject) const - /// Returns true if the object is automatically - /// deleted by its meta object. - { - return classFor(className).isAutoDelete(pObject); - } - - const Manif* findManifest(const std::string& path) const - /// Returns a pointer to the Manifest for the given - /// library, or a null pointer if the library has not been loaded. - { - FastMutex::ScopedLock lock(_mutex); - - typename LibraryMap::const_iterator it = _map.find(path); - if (it != _map.end()) - return it->second.pManifest; - else - return 0; - } - - const Manif& manifestFor(const std::string& path) const - /// Returns a reference to the Manifest for the given library - /// Throws a NotFoundException if the library has not been loaded. - { - const Manif* pManif = findManifest(path); - if (pManif) - return *pManif; - else - throw NotFoundException(path); - } - - bool isLibraryLoaded(const std::string& path) const - /// Returns true if the library with the given name - /// has already been loaded. - { - return findManifest(path) != 0; - } - - Iterator begin() const - { - FastMutex::ScopedLock lock(_mutex); - - return Iterator(_map.begin()); - } - - Iterator end() const - { - FastMutex::ScopedLock lock(_mutex); - - return Iterator(_map.end()); - } - -private: - LibraryMap _map; - mutable FastMutex _mutex; -}; - - -} // namespace Poco - - -#endif // Foundation_ClassLoader_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/Dynamic/Pair.h b/contrib/libs/poco/Foundation/include/Poco/Dynamic/Pair.h deleted file mode 100644 index c64eececeb..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/Dynamic/Pair.h +++ /dev/null @@ -1,412 +0,0 @@ -// -// Pair.h -// -// Library: Foundation -// Package: Dynamic -// Module: Pair -// -// Definition of the Pair class. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_Pair_INCLUDED -#define Foundation_Pair_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Dynamic/Var.h" -#include "Poco/Dynamic/VarHolder.h" -#include <utility> - - -namespace Poco { -namespace Dynamic { - - -template <typename K> -class Pair - /// Pair allows to define a pair of values. -{ -public: - typedef typename std::pair<K, Var> Data; - - Pair(): _data() - /// Creates an empty Pair - { - } - - Pair(const Pair& other): _data(other._data) - /// Creates the Pair from another pair. - { - } - - Pair(const Data& val): _data(val) - /// Creates the Pair from the given value. - { - } - - template <typename T> - Pair(const std::pair<K, T>& val): _data(std::make_pair(val.first, val.second)) - /// Creates Pair form standard pair. - { - } - - template <typename T> - Pair(const K& first, const T& second): _data(std::make_pair(first, second)) - /// Creates pair from two values. - { - } - - virtual ~Pair() - /// Destroys the Pair. - { - } - - Pair& swap(Pair& other) - /// Swaps the content of the two Pairs. - { - std::swap(_data, other._data); - return *this; - } - - Pair& operator = (const Pair& other) - /// Copy constructs Pair from another pair. - { - Pair(other).swap(*this); - return *this; - } - - inline const K& first() const - /// Returns the first member of the pair. - { - return _data.first; - } - - inline const Var& second() const - /// Returns the second member of the pair. - { - return _data.second; - } - - std::string toString() - { - std::string str; - Var(*this).convert<std::string>(str); - return str; - } - -private: - Data _data; -}; - - -template <> -class VarHolderImpl<Pair<std::string> >: public VarHolder -{ -public: - VarHolderImpl(const Pair<std::string>& val): _val(val) - { - } - - ~VarHolderImpl() - { - } - - const std::type_info& type() const - { - return typeid(Pair<std::string>); - } - - void convert(Int8& val) const - { - throw BadCastException("Cannot cast Pair type to Int8"); - } - - void convert(Int16& val) const - { - throw BadCastException("Cannot cast Pair type to Int16"); - } - - void convert(Int32& val) const - { - throw BadCastException("Cannot cast Pair type to Int32"); - } - - void convert(Int64& val) const - { - throw BadCastException("Cannot cast Pair type to Int64"); - } - - void convert(UInt8& val) const - { - throw BadCastException("Cannot cast Pair type to UInt8"); - } - - void convert(UInt16& val) const - { - throw BadCastException("Cannot cast Pair type to UInt16"); - } - - void convert(UInt32& val) const - { - throw BadCastException("Cannot cast Pair type to UInt32"); - } - - void convert(UInt64& val) const - { - throw BadCastException("Cannot cast Pair type to UInt64"); - } - - void convert(bool& val) const - { - throw BadCastException("Cannot cast Pair type to bool"); - } - - void convert(float& val) const - { - throw BadCastException("Cannot cast Pair type to float"); - } - - void convert(double& val) const - { - throw BadCastException("Cannot cast Pair type to double"); - } - - void convert(char& val) const - { - throw BadCastException("Cannot cast Pair type to char"); - } - - void convert(std::string& val) const - { - // Serialize in JSON format: equals an object - // JSON format definition: { string ':' value } string:value pair n-times, sep. by ',' - val.append("{ "); - Var key(_val.first()); - Impl::appendJSONKey(val, key); - val.append(" : "); - Impl::appendJSONValue(val, _val.second()); - val.append(" }"); - } - - void convert(Poco::DateTime&) const - { - throw BadCastException("Pair -> Poco::DateTime"); - } - - void convert(Poco::LocalDateTime&) const - { - throw BadCastException("Pair -> Poco::LocalDateTime"); - } - - void convert(Poco::Timestamp&) const - { - throw BadCastException("Pair -> Poco::Timestamp"); - } - - VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const - { - return cloneHolder(pVarHolder, _val); - } - - const Pair<std::string>& value() const - { - return _val; - } - - bool isArray() const - { - return false; - } - - bool isStruct() const - { - return false; - } - - bool isInteger() const - { - return false; - } - - bool isSigned() const - { - return false; - } - - bool isNumeric() const - { - return false; - } - - bool isString() const - { - return false; - } - -private: - Pair<std::string> _val; -}; - - -template <> -class VarHolderImpl<Pair<int> >: public VarHolder -{ -public: - VarHolderImpl(const Pair<int>& val): _val(val) - { - } - - ~VarHolderImpl() - { - } - - const std::type_info& type() const - { - return typeid(Pair<int>); - } - - void convert(Int8& val) const - { - throw BadCastException("Cannot cast Pair type to Int8"); - } - - void convert(Int16& val) const - { - throw BadCastException("Cannot cast Pair type to Int16"); - } - - void convert(Int32& val) const - { - throw BadCastException("Cannot cast Pair type to Int32"); - } - - void convert(Int64& val) const - { - throw BadCastException("Cannot cast Pair type to Int64"); - } - - void convert(UInt8& val) const - { - throw BadCastException("Cannot cast Pair type to UInt8"); - } - - void convert(UInt16& val) const - { - throw BadCastException("Cannot cast Pair type to UInt16"); - } - - void convert(UInt32& val) const - { - throw BadCastException("Cannot cast Pair type to UInt32"); - } - - void convert(UInt64& val) const - { - throw BadCastException("Cannot cast Pair type to UInt64"); - } - - void convert(bool& val) const - { - throw BadCastException("Cannot cast Pair type to bool"); - } - - void convert(float& val) const - { - throw BadCastException("Cannot cast Pair type to float"); - } - - void convert(double& val) const - { - throw BadCastException("Cannot cast Pair type to double"); - } - - void convert(char& val) const - { - throw BadCastException("Cannot cast Pair type to char"); - } - - void convert(std::string& val) const - { - // Serialize in JSON format: equals an object - // JSON format definition: { string ':' value } string:value pair n-times, sep. by ',' - val.append("{ "); - Var key(_val.first()); - Impl::appendJSONKey(val, key); - val.append(" : "); - Impl::appendJSONValue(val, _val.second()); - val.append(" }"); - } - - void convert(Poco::DateTime&) const - { - throw BadCastException("Pair -> Poco::DateTime"); - } - - void convert(Poco::LocalDateTime&) const - { - throw BadCastException("Pair -> Poco::LocalDateTime"); - } - - void convert(Poco::Timestamp&) const - { - throw BadCastException("Pair -> Poco::Timestamp"); - } - - VarHolder* clone(Placeholder<VarHolder>* pVarHolder = 0) const - { - return cloneHolder(pVarHolder, _val); - } - - const Pair<int>& value() const - { - return _val; - } - - bool isArray() const - { - return false; - } - - bool isStruct() const - { - return false; - } - - bool isInteger() const - { - return false; - } - - bool isSigned() const - { - return false; - } - - bool isNumeric() const - { - return false; - } - - bool isString() const - { - return false; - } - -private: - Pair<int> _val; -}; - - -} // namespace Dynamic - - -} // namespace Poco - - -#endif // Foundation_Pair_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/DynamicAny.h b/contrib/libs/poco/Foundation/include/Poco/DynamicAny.h deleted file mode 100644 index 214a296792..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/DynamicAny.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// DynamicAny.h -// -// Library: Foundation -// Package: Dynamic -// Module: Var -// -// Forward header for Var class to maintain backward compatibility. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_DynamicAny_INCLUDED -#define Foundation_DynamicAny_INCLUDED - -//@ deprecated -#include "Poco/Dynamic/Var.h" - - -#endif // Foundation_DynamicAny_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/DynamicAnyHolder.h b/contrib/libs/poco/Foundation/include/Poco/DynamicAnyHolder.h deleted file mode 100644 index 4400af3ec9..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/DynamicAnyHolder.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// DynamicAnyHolder.h -// -// Library: Foundation -// Package: Dynamic -// Module: VarHolder -// -// Forward header for VarHolder class to maintain backward compatibility -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_DynamicAnyHolder_INCLUDED -#define Foundation_DynamicAnyHolder_INCLUDED - -//@ deprecated -#include "Poco/Dynamic/VarHolder.h" - - -#endif // Foundation_DynamicAnyHolder_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/DynamicStruct.h b/contrib/libs/poco/Foundation/include/Poco/DynamicStruct.h deleted file mode 100644 index 1f0fb56b75..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/DynamicStruct.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// DynamicStruct.h -// -// Library: Foundation -// Package: Dynamic -// Module: Struct -// -// Forward header for Struct class to maintain backward compatibility. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_DynamicStruct_INCLUDED -#define Foundation_DynamicStruct_INCLUDED - -//@ deprecated -#include "Poco/Dynamic/Struct.h" - - -#endif // Foundation_DynamicStruct_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/Environment_WIN32U.h b/contrib/libs/poco/Foundation/include/Poco/Environment_WIN32U.h deleted file mode 100644 index b54afb2e89..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/Environment_WIN32U.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// Environment_WIN32U.h -// -// Library: Foundation -// Package: Core -// Module: Environment -// -// Definition of the EnvironmentImpl class for WIN32. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_Environment_WIN32U_INCLUDED -#define Foundation_Environment_WIN32U_INCLUDED - - -#include "Poco/Foundation.h" - - -namespace Poco { - - -class Foundation_API EnvironmentImpl -{ -public: - typedef UInt8 NodeId[6]; /// Ethernet address. - - static std::string getImpl(const std::string& name); - static bool hasImpl(const std::string& name); - static void setImpl(const std::string& name, const std::string& value); - static std::string osNameImpl(); - static std::string osDisplayNameImpl(); - static std::string osVersionImpl(); - static std::string osArchitectureImpl(); - static std::string nodeNameImpl(); - static void nodeIdImpl(NodeId& id); - static unsigned processorCountImpl(); -}; - - -} // namespace Poco - - -#endif // Foundation_Environment_WIN32U_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/ExpirationDecorator.h b/contrib/libs/poco/Foundation/include/Poco/ExpirationDecorator.h deleted file mode 100644 index 2e9d40a638..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ExpirationDecorator.h +++ /dev/null @@ -1,92 +0,0 @@ -// -// ExpirationDecorator.h -// -// Library: Foundation -// Package: Events -// Module: ExpirationDecorator -// -// Implementation of the ExpirationDecorator template. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ExpirationDecorator_INCLUDED -#define Foundation_ExpirationDecorator_INCLUDED - - -#include "Poco/Timestamp.h" -#include "Poco/Timespan.h" - - -namespace Poco { - - -template <typename TArgs> -class ExpirationDecorator - /// ExpirationDecorator adds an expiration method to values so that they can be used - /// with the UniqueExpireCache. -{ -public: - ExpirationDecorator(): - _value(), - _expiresAt() - { - } - - ExpirationDecorator(const TArgs& p, const Poco::Timespan::TimeDiff& diffInMs): - /// Creates an element that will expire in diff milliseconds - _value(p), - _expiresAt() - { - _expiresAt += (diffInMs*1000); - } - - ExpirationDecorator(const TArgs& p, const Poco::Timespan& timeSpan): - /// Creates an element that will expire after the given timeSpan - _value(p), - _expiresAt() - { - _expiresAt += timeSpan.totalMicroseconds(); - } - - ExpirationDecorator(const TArgs& p, const Poco::Timestamp& timeStamp): - /// Creates an element that will expire at the given time point - _value(p), - _expiresAt(timeStamp) - { - } - - - ~ExpirationDecorator() - { - } - - const Poco::Timestamp& getExpiration() const - { - return _expiresAt; - } - - const TArgs& value() const - { - return _value; - } - - TArgs& value() - { - return _value; - } - -private: - TArgs _value; - Timestamp _expiresAt; -}; - - -} // namespace Poco - - -#endif // Foundation_ExpirationDecorator_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/ExpireCache.h b/contrib/libs/poco/Foundation/include/Poco/ExpireCache.h deleted file mode 100644 index 41f0482b30..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ExpireCache.h +++ /dev/null @@ -1,65 +0,0 @@ -// -// ExpireCache.h -// -// Library: Foundation -// Package: Cache -// Module: ExpireCache -// -// Definition of the ExpireCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ExpireCache_INCLUDED -#define Foundation_ExpireCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/ExpireStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue>, TMutex, TEventMutex> - /// An ExpireCache caches entries for a fixed time period (per default 10 minutes). - /// Entries expire independently of the access pattern, i.e. after a constant time. - /// If you require your objects to expire after they were not accessed for a given time - /// period use a Poco::AccessExpireCache. - /// - /// Be careful when using an ExpireCache. A cache is often used - /// like cache.has(x) followed by cache.get x). Note that it could happen - /// that the "has" call works, then the current execution thread gets descheduled, time passes, - /// the entry gets invalid, thus leading to an empty SharedPtr being returned - /// when "get" is invoked. -{ -public: - ExpireCache(Timestamp::TimeDiff expire = 600000): - AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue>, TMutex, TEventMutex>(ExpireStrategy<TKey, TValue>(expire)) - { - } - - ~ExpireCache() - { - } - -private: - ExpireCache(const ExpireCache& aCache); - ExpireCache& operator = (const ExpireCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_ExpireCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h b/contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h deleted file mode 100644 index d79281a8e8..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ExpireLRUCache.h +++ /dev/null @@ -1,62 +0,0 @@ -// -// ExpireLRUCache.h -// -// Library: Foundation -// Package: Cache -// Module: ExpireLRUCache -// -// Definition of the ExpireLRUCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ExpireLRUCache_INCLUDED -#define Foundation_ExpireLRUCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/StrategyCollection.h" -#include "Poco/ExpireStrategy.h" -#include "Poco/LRUStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex> - /// An ExpireLRUCache combines LRU caching and time based expire caching. - /// It cache entries for a fixed time period (per default 10 minutes) - /// but also limits the size of the cache (per default: 1024). -{ -public: - ExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000): - AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>(StrategyCollection<TKey, TValue>()) - { - this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); - this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire)); - } - - ~ExpireLRUCache() - { - } - -private: - ExpireLRUCache(const ExpireLRUCache& aCache); - ExpireLRUCache& operator = (const ExpireLRUCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_ExpireLRUCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/ExpireStrategy.h b/contrib/libs/poco/Foundation/include/Poco/ExpireStrategy.h deleted file mode 100644 index 40e49eae8c..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ExpireStrategy.h +++ /dev/null @@ -1,132 +0,0 @@ -// -// ExpireStrategy.h -// -// Library: Foundation -// Package: Cache -// Module: ExpireStrategy -// -// Definition of the ExpireStrategy class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ExpireStrategy_INCLUDED -#define Foundation_ExpireStrategy_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/AbstractStrategy.h" -#include "Poco/Bugcheck.h" -#include "Poco/Timestamp.h" -#include "Poco/EventArgs.h" -#include <set> -#include <map> - - -namespace Poco { - - -template < - class TKey, - class TValue -> -class ExpireStrategy: public AbstractStrategy<TKey, TValue> - /// An ExpireStrategy implements time based expiration of cache entries -{ -public: - typedef std::multimap<Timestamp, TKey> TimeIndex; - typedef typename TimeIndex::iterator IndexIterator; - typedef typename TimeIndex::const_iterator ConstIndexIterator; - typedef std::map<TKey, IndexIterator> Keys; - typedef typename Keys::iterator Iterator; - -public: - ExpireStrategy(Timestamp::TimeDiff expireTimeInMilliSec): _expireTime(expireTimeInMilliSec * 1000) - /// Create an expire strategy. Note that the smallest allowed caching time is 25ms. - /// Anything lower than that is not useful with current operating systems. - { - if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms"); - } - - ~ExpireStrategy() - { - } - - void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args) - { - Timestamp now; - typename TimeIndex::value_type tiValue(now, args.key()); - IndexIterator it = _keyIndex.insert(tiValue); - typename Keys::value_type kValue(args.key(), it); - std::pair<Iterator, bool> stat = _keys.insert(kValue); - if (!stat.second) - { - _keyIndex.erase(stat.first->second); - stat.first->second = it; - } - } - - void onRemove(const void*, const TKey& key) - { - Iterator it = _keys.find(key); - if (it != _keys.end()) - { - _keyIndex.erase(it->second); - _keys.erase(it); - } - } - - void onGet(const void*, const TKey& /*key*/) - { - // get triggers no changes in an expire - } - - void onClear(const void*, const EventArgs& /*args*/) - { - _keys.clear(); - _keyIndex.clear(); - } - - void onIsValid(const void*, ValidArgs<TKey>& args) - { - Iterator it = _keys.find(args.key()); - if (it != _keys.end()) - { - if (it->second->first.isElapsed(_expireTime)) - { - args.invalidate(); - } - } - else //not found: probably removed by onReplace - args.invalidate(); - } - - void onReplace(const void*, std::set<TKey>& elemsToRemove) - { - // Note: replace only informs the cache which elements - // it would like to remove! - // it does not remove them on its own! - IndexIterator it = _keyIndex.begin(); - while (it != _keyIndex.end() && it->first.isElapsed(_expireTime)) - { - elemsToRemove.insert(it->second); - ++it; - } - } - -protected: - Timestamp::TimeDiff _expireTime; - Keys _keys; /// For faster replacement of keys, the iterator points to the _keyIndex map - TimeIndex _keyIndex; /// Maps time to key value -}; - - -} // namespace Poco - - -#endif // Foundation_ExpireStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/FIFOEvent.h b/contrib/libs/poco/Foundation/include/Poco/FIFOEvent.h deleted file mode 100644 index 404044c392..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/FIFOEvent.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// FIFOEvent.h -// -// Library: Foundation -// Package: Events -// Module: FIFOEvent -// -// Implementation of the FIFOEvent template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_FIFOEvent_INCLUDED -#define Foundation_FIFOEvent_INCLUDED - - -#include "Poco/AbstractEvent.h" -#include "Poco/FIFOStrategy.h" -#include "Poco/AbstractDelegate.h" - - -namespace Poco { - - -//@ deprecated -template <class TArgs, class TMutex = FastMutex> -class FIFOEvent: public AbstractEvent < - TArgs, - FIFOStrategy<TArgs, AbstractDelegate<TArgs> >, - AbstractDelegate<TArgs>, - TMutex -> - /// A FIFOEvent uses internally a FIFOStrategy which guarantees - /// that delegates are invoked in the order they were added to - /// the event. - /// - /// Note that as of release 1.4.2, this is the default behavior - /// implemented by BasicEvent, so this class is provided - /// for backwards compatibility only. -{ -public: - FIFOEvent() - { - } - - ~FIFOEvent() - { - } - -private: - FIFOEvent(const FIFOEvent& e); - FIFOEvent& operator = (const FIFOEvent& e); -}; - - -} // namespace Poco - - -#endif // Foundation_FIFOEvent_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/FIFOStrategy.h b/contrib/libs/poco/Foundation/include/Poco/FIFOStrategy.h deleted file mode 100644 index 79c2276043..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/FIFOStrategy.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// FIFOStrategy.h -// -// Library: Foundation -// Package: Events -// Module: FIFOStragegy -// -// Implementation of the FIFOStrategy template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_FIFOStrategy_INCLUDED -#define Foundation_FIFOStrategy_INCLUDED - - -#include "Poco/DefaultStrategy.h" - - -namespace Poco { - - -//@ deprecated -template <class TArgs, class TDelegate> -class FIFOStrategy: public DefaultStrategy<TArgs, TDelegate> - /// Note: As of release 1.4.2, DefaultStrategy already - /// implements FIFO behavior, so this class is provided - /// for backwards compatibility only. -{ -public: - FIFOStrategy() - { - } - - FIFOStrategy(const FIFOStrategy& s): - DefaultStrategy<TArgs, TDelegate>(s) - { - } - - ~FIFOStrategy() - { - } - - FIFOStrategy& operator = (const FIFOStrategy& s) - { - DefaultStrategy<TArgs, TDelegate>::operator = (s); - return *this; - } -}; - - -} // namespace Poco - - -#endif // Foundation_FIFOStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/FunctionPriorityDelegate.h b/contrib/libs/poco/Foundation/include/Poco/FunctionPriorityDelegate.h deleted file mode 100644 index 60e6592048..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/FunctionPriorityDelegate.h +++ /dev/null @@ -1,450 +0,0 @@ -// -// FunctionPriorityDelegate.h -// -// Library: Foundation -// Package: Events -// Module: FunctionPriorityDelegate -// -// Implementation of the FunctionPriorityDelegate template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_FunctionPriorityDelegate_INCLUDED -#define Foundation_FunctionPriorityDelegate_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/AbstractPriorityDelegate.h" -#include "Poco/Mutex.h" - - -namespace Poco { - - -template <class TArgs, bool useSender = true, bool senderIsConst = true> -class FunctionPriorityDelegate: public AbstractPriorityDelegate<TArgs> - /// Wraps a freestanding function or static member function - /// for use as a PriorityDelegate. -{ -public: - typedef void (*NotifyFunction)(const void*, TArgs&); - - FunctionPriorityDelegate(NotifyFunction function, int prio): - AbstractPriorityDelegate<TArgs>(prio), - _function(function) - { - } - - FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate): - AbstractPriorityDelegate<TArgs>(delegate), - _function(delegate._function) - { - } - - FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_function = delegate._function; - this->_priority = delegate._priority; - } - return *this; - } - - ~FunctionPriorityDelegate() - { - } - - bool notify(const void* sender, TArgs& arguments) - { - Mutex::ScopedLock lock(_mutex); - if (_function) - { - (*_function)(sender, arguments); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<TArgs>& other) const - { - const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _function == pOtherDelegate->_function; - } - - AbstractDelegate<TArgs>* clone() const - { - return new FunctionPriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _function = 0; - } - -protected: - NotifyFunction _function; - Mutex _mutex; - -private: - FunctionPriorityDelegate(); -}; - - -template <class TArgs> -class FunctionPriorityDelegate<TArgs, true, false>: public AbstractPriorityDelegate<TArgs> -{ -public: - typedef void (*NotifyFunction)(void*, TArgs&); - - FunctionPriorityDelegate(NotifyFunction function, int prio): - AbstractPriorityDelegate<TArgs>(prio), - _function(function) - { - } - - FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate): - AbstractPriorityDelegate<TArgs>(delegate), - _function(delegate._function) - { - } - - FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_function = delegate._function; - this->_priority = delegate._priority; - } - return *this; - } - - ~FunctionPriorityDelegate() - { - } - - bool notify(const void* sender, TArgs& arguments) - { - Mutex::ScopedLock lock(_mutex); - if (_function) - { - (*_function)(const_cast<void*>(sender), arguments); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<TArgs>& other) const - { - const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _function == pOtherDelegate->_function; - } - - AbstractDelegate<TArgs>* clone() const - { - return new FunctionPriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _function = 0; - } - -protected: - NotifyFunction _function; - Mutex _mutex; - -private: - FunctionPriorityDelegate(); -}; - - -template <class TArgs> -class FunctionPriorityDelegate<TArgs, false>: public AbstractPriorityDelegate<TArgs> -{ -public: - typedef void (*NotifyFunction)(TArgs&); - - FunctionPriorityDelegate(NotifyFunction function, int prio): - AbstractPriorityDelegate<TArgs>(prio), - _function(function) - { - } - - FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate): - AbstractPriorityDelegate<TArgs>(delegate), - _function(delegate._function) - { - } - - FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_function = delegate._function; - this->_priority = delegate._priority; - } - return *this; - } - - ~FunctionPriorityDelegate() - { - } - - bool notify(const void* sender, TArgs& arguments) - { - Mutex::ScopedLock lock(_mutex); - if (_function) - { - (*_function)(arguments); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<TArgs>& other) const - { - const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _function == pOtherDelegate->_function; - } - - AbstractDelegate<TArgs>* clone() const - { - return new FunctionPriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _function = 0; - } - -protected: - NotifyFunction _function; - Mutex _mutex; - -private: - FunctionPriorityDelegate(); -}; - - -template <> -class FunctionPriorityDelegate<void, true, true>: public AbstractPriorityDelegate<void> - /// Wraps a freestanding function or static member function - /// for use as a PriorityDelegate. -{ -public: - typedef void (*NotifyFunction)(const void*); - - FunctionPriorityDelegate(NotifyFunction function, int prio): - AbstractPriorityDelegate<void>(prio), - _function(function) - { - } - - FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate): - AbstractPriorityDelegate<void>(delegate), - _function(delegate._function) - { - } - - FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_function = delegate._function; - this->_priority = delegate._priority; - } - return *this; - } - - ~FunctionPriorityDelegate() - { - } - - bool notify(const void* sender) - { - Mutex::ScopedLock lock(_mutex); - if (_function) - { - (*_function)(sender); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<void>& other) const - { - const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _function == pOtherDelegate->_function; - } - - AbstractDelegate<void>* clone() const - { - return new FunctionPriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _function = 0; - } - -protected: - NotifyFunction _function; - Mutex _mutex; - -private: - FunctionPriorityDelegate(); -}; - - -template <> -class FunctionPriorityDelegate<void, true, false>: public AbstractPriorityDelegate<void> -{ -public: - typedef void (*NotifyFunction)(void*); - - FunctionPriorityDelegate(NotifyFunction function, int prio): - AbstractPriorityDelegate<void>(prio), - _function(function) - { - } - - FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate): - AbstractPriorityDelegate<void>(delegate), - _function(delegate._function) - { - } - - FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_function = delegate._function; - this->_priority = delegate._priority; - } - return *this; - } - - ~FunctionPriorityDelegate() - { - } - - bool notify(const void* sender) - { - Mutex::ScopedLock lock(_mutex); - if (_function) - { - (*_function)(const_cast<void*>(sender)); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<void>& other) const - { - const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _function == pOtherDelegate->_function; - } - - AbstractDelegate<void>* clone() const - { - return new FunctionPriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _function = 0; - } - -protected: - NotifyFunction _function; - Mutex _mutex; - -private: - FunctionPriorityDelegate(); -}; - - -template <> -class FunctionPriorityDelegate<void, false>: public AbstractPriorityDelegate<void> -{ -public: - typedef void (*NotifyFunction)(); - - FunctionPriorityDelegate(NotifyFunction function, int prio): - AbstractPriorityDelegate<void>(prio), - _function(function) - { - } - - FunctionPriorityDelegate(const FunctionPriorityDelegate& delegate): - AbstractPriorityDelegate<void>(delegate), - _function(delegate._function) - { - } - - FunctionPriorityDelegate& operator = (const FunctionPriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_function = delegate._function; - this->_priority = delegate._priority; - } - return *this; - } - - ~FunctionPriorityDelegate() - { - } - - bool notify(const void* sender) - { - Mutex::ScopedLock lock(_mutex); - if (_function) - { - (*_function)(); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<void>& other) const - { - const FunctionPriorityDelegate* pOtherDelegate = dynamic_cast<const FunctionPriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _function == pOtherDelegate->_function; - } - - AbstractDelegate<void>* clone() const - { - return new FunctionPriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _function = 0; - } - -protected: - NotifyFunction _function; - Mutex _mutex; - -private: - FunctionPriorityDelegate(); -}; - - -} // namespace Poco - - -#endif // Foundation_FunctionPriorityDelegate_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/HashFunction.h b/contrib/libs/poco/Foundation/include/Poco/HashFunction.h deleted file mode 100644 index c451d0699d..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/HashFunction.h +++ /dev/null @@ -1,57 +0,0 @@ -// -// HashFunction.h -// -// Library: Foundation -// Package: Hashing -// Module: HashFunction -// -// Definition of the HashFunction class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_HashFunction_INCLUDED -#define Foundation_HashFunction_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Hash.h" - - -namespace Poco { - - -//@ deprecated -template <class T> -struct HashFunction - /// A generic hash function. -{ - UInt32 operator () (T key, UInt32 maxValue) const - /// Returns the hash value for the given key. - { - return static_cast<UInt32>(Poco::hash(key)) % maxValue; - } -}; - - -//@ deprecated -template <> -struct HashFunction<std::string> - /// A generic hash function. -{ - UInt32 operator () (const std::string& key, UInt32 maxValue) const - /// Returns the hash value for the given key. - { - return static_cast<UInt32>(Poco::hash(key)) % maxValue; - } -}; - - -} // namespace Poco - - -#endif // Foundation_HashFunctions_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/HashMap.h b/contrib/libs/poco/Foundation/include/Poco/HashMap.h deleted file mode 100644 index 5153f2b164..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/HashMap.h +++ /dev/null @@ -1,228 +0,0 @@ -// -// HashMap.h -// -// Library: Foundation -// Package: Hashing -// Module: HashMap -// -// Definition of the HashMap class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_HashMap_INCLUDED -#define Foundation_HashMap_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/LinearHashTable.h" -#include "Poco/Exception.h" -#include <utility> - - -namespace Poco { - - -template <class Key, class Value> -struct HashMapEntry - /// This class template is used internally by HashMap. -{ - Key first; - Value second; - - HashMapEntry(): - first(), - second() - { - } - - HashMapEntry(const Key& key): - first(key), - second() - { - } - - HashMapEntry(const Key& key, const Value& value): - first(key), - second(value) - { - } - - bool operator == (const HashMapEntry& entry) const - { - return first == entry.first; - } - - bool operator != (const HashMapEntry& entry) const - { - return first != entry.first; - } -}; - - -template <class HME, class KeyHashFunc> -struct HashMapEntryHash - /// This class template is used internally by HashMap. -{ - std::size_t operator () (const HME& entry) const - { - return _func(entry.first); - } - -private: - KeyHashFunc _func; -}; - - -template <class Key, class Mapped, class HashFunc = Hash<Key> > -class HashMap - /// This class implements a map using a LinearHashTable. - /// - /// A HashMap can be used just like a std::map. -{ -public: - typedef Key KeyType; - typedef Mapped MappedType; - typedef Mapped& Reference; - typedef const Mapped& ConstReference; - typedef Mapped* Pointer; - typedef const Mapped* ConstPointer; - - typedef HashMapEntry<Key, Mapped> ValueType; - typedef std::pair<KeyType, MappedType> PairType; - - typedef HashMapEntryHash<ValueType, HashFunc> HashType; - typedef LinearHashTable<ValueType, HashType> HashTable; - - typedef typename HashTable::Iterator Iterator; - typedef typename HashTable::ConstIterator ConstIterator; - - HashMap() - /// Creates an empty HashMap. - { - } - - HashMap(std::size_t initialReserve): - _table(initialReserve) - /// Creates the HashMap with room for initialReserve entries. - { - } - - HashMap& operator = (const HashMap& map) - /// Assigns another HashMap. - { - HashMap tmp(map); - swap(tmp); - return *this; - } - - void swap(HashMap& map) - /// Swaps the HashMap with another one. - { - _table.swap(map._table); - } - - ConstIterator begin() const - { - return _table.begin(); - } - - ConstIterator end() const - { - return _table.end(); - } - - Iterator begin() - { - return _table.begin(); - } - - Iterator end() - { - return _table.end(); - } - - ConstIterator find(const KeyType& key) const - { - ValueType value(key); - return _table.find(value); - } - - Iterator find(const KeyType& key) - { - ValueType value(key); - return _table.find(value); - } - - std::size_t count(const KeyType& key) const - { - ValueType value(key); - return _table.find(value) != _table.end() ? 1 : 0; - } - - std::pair<Iterator, bool> insert(const PairType& pair) - { - ValueType value(pair.first, pair.second); - return _table.insert(value); - } - - std::pair<Iterator, bool> insert(const ValueType& value) - { - return _table.insert(value); - } - - void erase(Iterator it) - { - _table.erase(it); - } - - void erase(const KeyType& key) - { - Iterator it = find(key); - _table.erase(it); - } - - void clear() - { - _table.clear(); - } - - std::size_t size() const - { - return _table.size(); - } - - bool empty() const - { - return _table.empty(); - } - - ConstReference operator [] (const KeyType& key) const - { - ConstIterator it = _table.find(key); - if (it != _table.end()) - return it->second; - else - throw NotFoundException(); - } - - Reference operator [] (const KeyType& key) - { - ValueType value(key); - std::pair<Iterator, bool> res = _table.insert(value); - return res.first->second; - } - -private: - HashTable _table; -}; - - -} // namespace Poco - - -#endif // Foundation_HashMap_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/HashSet.h b/contrib/libs/poco/Foundation/include/Poco/HashSet.h deleted file mode 100644 index e24560c001..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/HashSet.h +++ /dev/null @@ -1,177 +0,0 @@ -// -// HashSet.h -// -// Library: Foundation -// Package: Hashing -// Module: HashSet -// -// Definition of the HashSet class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_HashSet_INCLUDED -#define Foundation_HashSet_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/LinearHashTable.h" - - -namespace Poco { - - -template <class Value, class HashFunc = Hash<Value> > -class HashSet - /// This class implements a set using a LinearHashTable. - /// - /// A HashSet can be used just like a std::set. -{ -public: - typedef Value ValueType; - typedef Value& Reference; - typedef const Value& ConstReference; - typedef Value* Pointer; - typedef const Value* ConstPointer; - typedef HashFunc Hash; - - typedef LinearHashTable<ValueType, Hash> HashTable; - - typedef typename HashTable::Iterator Iterator; - typedef typename HashTable::ConstIterator ConstIterator; - - HashSet() - /// Creates an empty HashSet. - { - } - - HashSet(std::size_t initialReserve): - _table(initialReserve) - /// Creates the HashSet, using the given initialReserve. - { - } - - HashSet(const HashSet& set): - _table(set._table) - /// Creates the HashSet by copying another one. - { - } - - ~HashSet() - /// Destroys the HashSet. - { - } - - HashSet& operator = (const HashSet& table) - /// Assigns another HashSet. - { - HashSet tmp(table); - swap(tmp); - return *this; - } - - void swap(HashSet& set) - /// Swaps the HashSet with another one. - { - _table.swap(set._table); - } - - ConstIterator begin() const - /// Returns an iterator pointing to the first entry, if one exists. - { - return _table.begin(); - } - - ConstIterator end() const - /// Returns an iterator pointing to the end of the table. - { - return _table.end(); - } - - Iterator begin() - /// Returns an iterator pointing to the first entry, if one exists. - { - return _table.begin(); - } - - Iterator end() - /// Returns an iterator pointing to the end of the table. - { - return _table.end(); - } - - ConstIterator find(const ValueType& value) const - /// Finds an entry in the table. - { - return _table.find(value); - } - - Iterator find(const ValueType& value) - /// Finds an entry in the table. - { - return _table.find(value); - } - - std::size_t count(const ValueType& value) const - /// Returns the number of elements with the given - /// value, with is either 1 or 0. - { - return _table.count(value); - } - - std::pair<Iterator, bool> insert(const ValueType& value) - /// Inserts an element into the set. - /// - /// If the element already exists in the set, - /// a pair(iterator, false) with iterator pointing to the - /// existing element is returned. - /// Otherwise, the element is inserted an a - /// pair(iterator, true) with iterator - /// pointing to the new element is returned. - { - return _table.insert(value); - } - - void erase(Iterator it) - /// Erases the element pointed to by it. - { - _table.erase(it); - } - - void erase(const ValueType& value) - /// Erases the element with the given value, if it exists. - { - _table.erase(value); - } - - void clear() - /// Erases all elements. - { - _table.clear(); - } - - std::size_t size() const - /// Returns the number of elements in the table. - { - return _table.size(); - } - - bool empty() const - /// Returns true iff the table is empty. - { - return _table.empty(); - } - -private: - HashTable _table; -}; - - -} // namespace Poco - - -#endif // Foundation_HashSet_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/HashTable.h b/contrib/libs/poco/Foundation/include/Poco/HashTable.h deleted file mode 100644 index e71af1e12c..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/HashTable.h +++ /dev/null @@ -1,369 +0,0 @@ -// -// HashTable.h -// -// Library: Foundation -// Package: Hashing -// Module: HashTable -// -// Definition of the HashTable class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_HashTable_INCLUDED -#define Foundation_HashTable_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Exception.h" -#include "Poco/HashFunction.h" -#include "Poco/HashStatistic.h" -#include <vector> -#include <map> -#include <cstddef> -#include <cstring> - - -namespace Poco { - - -//@ deprecated -template <class Key, class Value, class KeyHashFunction = HashFunction<Key> > -class HashTable - /// A HashTable stores a key value pair that can be looked up via a hashed key. - /// - /// Collision handling is done via overflow maps(!). With small hash tables performance of this - /// data struct will be closer to that a map than a hash table, i.e. slower. On the plus side, - /// this class offers remove operations. Also HashTable full errors are not possible. If a fast - /// HashTable implementation is needed and the remove operation is not required, use SimpleHashTable - /// instead. - /// - /// This class is NOT thread safe. -{ -public: - typedef std::map<Key, Value> HashEntryMap; - typedef HashEntryMap** HashTableVector; - - typedef typename HashEntryMap::const_iterator ConstIterator; - typedef typename HashEntryMap::iterator Iterator; - - HashTable(UInt32 initialSize = 251): - _entries(0), - _size(0), - _maxCapacity(initialSize) - /// Creates the HashTable. - { - _entries = new HashEntryMap*[initialSize]; - memset(_entries, '\0', sizeof(HashEntryMap*)*initialSize); - } - - HashTable(const HashTable& ht): - _entries(new HashEntryMap*[ht._maxCapacity]), - _size(ht._size), - _maxCapacity(ht._maxCapacity) - { - for (UInt32 i = 0; i < _maxCapacity; ++i) - { - if (ht._entries[i]) - _entries[i] = new HashEntryMap(ht._entries[i]->begin(), ht._entries[i]->end()); - else - _entries[i] = 0; - } - } - - ~HashTable() - /// Destroys the HashTable. - { - clear(); - } - - HashTable& operator = (const HashTable& ht) - { - if (this != &ht) - { - clear(); - _maxCapacity = ht._maxCapacity; - poco_assert_dbg (_entries == 0); - _entries = new HashEntryMap*[_maxCapacity]; - _size = ht._size; - - for (UInt32 i = 0; i < _maxCapacity; ++i) - { - if (ht._entries[i]) - _entries[i] = new HashEntryMap(ht._entries[i]->begin(), ht._entries[i]->end()); - else - _entries[i] = 0; - } - } - return *this; - } - - void clear() - { - if (!_entries) - return; - for (UInt32 i = 0; i < _maxCapacity; ++i) - { - delete _entries[i]; - } - delete[] _entries; - _entries = 0; - _size = 0; - _maxCapacity = 0; - } - - UInt32 insert(const Key& key, const Value& value) - /// Returns the hash value of the inserted item. - /// Throws an exception if the entry was already inserted - { - UInt32 hsh = hash(key); - insertRaw(key, hsh, value); - return hsh; - } - - Value& insertRaw(const Key& key, UInt32 hsh, const Value& value) - /// Returns the hash value of the inserted item. - /// Throws an exception if the entry was already inserted - { - if (!_entries[hsh]) - _entries[hsh] = new HashEntryMap(); - std::pair<typename HashEntryMap::iterator, bool> res(_entries[hsh]->insert(std::make_pair(key, value))); - if (!res.second) - throw InvalidArgumentException("HashTable::insert, key already exists."); - _size++; - return res.first->second; - } - - UInt32 update(const Key& key, const Value& value) - /// Returns the hash value of the inserted item. - /// Replaces an existing entry if it finds one - { - UInt32 hsh = hash(key); - updateRaw(key, hsh, value); - return hsh; - } - - void updateRaw(const Key& key, UInt32 hsh, const Value& value) - /// Returns the hash value of the inserted item. - /// Replaces an existing entry if it finds one - { - if (!_entries[hsh]) - _entries[hsh] = new HashEntryMap(); - std::pair<Iterator, bool> res = _entries[hsh]->insert(std::make_pair(key, value)); - if (res.second == false) - res.first->second = value; - else - _size++; - } - - void remove(const Key& key) - { - UInt32 hsh = hash(key); - removeRaw(key, hsh); - } - - void removeRaw(const Key& key, UInt32 hsh) - /// Performance version, allows to specify the hash value - { - if (_entries[hsh]) - { - _size -= _entries[hsh]->erase(key); - } - } - - UInt32 hash(const Key& key) const - { - return _hash(key, _maxCapacity); - } - - const Value& get(const Key& key) const - /// Throws an exception if the value does not exist - { - UInt32 hsh = hash(key); - return getRaw(key, hsh); - } - - const Value& getRaw(const Key& key, UInt32 hsh) const - /// Throws an exception if the value does not exist - { - if (!_entries[hsh]) - throw InvalidArgumentException("key not found"); - - ConstIterator it = _entries[hsh]->find(key); - if (it == _entries[hsh]->end()) - throw InvalidArgumentException("key not found"); - - return it->second; - } - - Value& get(const Key& key) - /// Throws an exception if the value does not exist - { - UInt32 hsh = hash(key); - return const_cast<Value&>(getRaw(key, hsh)); - } - - const Value& operator [] (const Key& key) const - { - return get(key); - } - - Value& operator [] (const Key& key) - { - UInt32 hsh = hash(key); - - if (!_entries[hsh]) - return insertRaw(key, hsh, Value()); - - ConstIterator it = _entries[hsh]->find(key); - if (it == _entries[hsh]->end()) - return insertRaw(key, hsh, Value()); - - return it->second; - } - - const Key& getKeyRaw(const Key& key, UInt32 hsh) - /// Throws an exception if the key does not exist. returns a reference to the internally - /// stored key. Useful when someone does an insert and wants for performance reason only to store - /// a pointer to the key in another collection - { - if (!_entries[hsh]) - throw InvalidArgumentException("key not found"); - ConstIterator it = _entries[hsh]->find(key); - if (it == _entries[hsh]->end()) - throw InvalidArgumentException("key not found"); - return it->first; - } - - bool get(const Key& key, Value& v) const - /// Sets v to the found value, returns false if no value was found - { - UInt32 hsh = hash(key); - return getRaw(key, hsh, v); - } - - bool getRaw(const Key& key, UInt32 hsh, Value& v) const - /// Sets v to the found value, returns false if no value was found - { - if (!_entries[hsh]) - return false; - - ConstIterator it = _entries[hsh]->find(key); - if (it == _entries[hsh]->end()) - return false; - - v = it->second; - return true; - } - - bool exists(const Key& key) - { - UInt32 hsh = hash(key); - return existsRaw(key, hsh); - } - - bool existsRaw(const Key& key, UInt32 hsh) - { - return _entries[hsh] && (_entries[hsh]->end() != _entries[hsh]->find(key)); - } - - std::size_t size() const - /// Returns the number of elements already inserted into the HashTable - { - return _size; - } - - UInt32 maxCapacity() const - { - return _maxCapacity; - } - - void resize(UInt32 newSize) - /// Resizes the hashtable, rehashes all existing entries. Expensive! - { - if (_maxCapacity != newSize) - { - HashTableVector cpy = _entries; - _entries = 0; - UInt32 oldSize = _maxCapacity; - _maxCapacity = newSize; - _entries = new HashEntryMap*[_maxCapacity]; - memset(_entries, '\0', sizeof(HashEntryMap*)*_maxCapacity); - - if (_size == 0) - { - // no data was yet inserted - delete[] cpy; - return; - } - _size = 0; - for (UInt32 i = 0; i < oldSize; ++i) - { - if (cpy[i]) - { - ConstIterator it = cpy[i]->begin(); - ConstIterator itEnd = cpy[i]->end(); - for (; it != itEnd; ++it) - { - insert(it->first, it->second); - } - delete cpy[i]; - } - } - delete[] cpy; - } - } - - HashStatistic currentState(bool details = false) const - /// Returns the current internal state - { - UInt32 numberOfEntries = (UInt32)_size; - UInt32 numZeroEntries = 0; - UInt32 maxEntriesPerHash = 0; - std::vector<UInt32> detailedEntriesPerHash; - #ifdef _DEBUG - UInt32 totalSize = 0; - #endif - for (UInt32 i = 0; i < _maxCapacity; ++i) - { - if (_entries[i]) - { - UInt32 size = (UInt32)_entries[i]->size(); - poco_assert_dbg(size != 0); - if (size > maxEntriesPerHash) - maxEntriesPerHash = size; - if (details) - detailedEntriesPerHash.push_back(size); - #ifdef _DEBUG - totalSize += size; - #endif - } - else - { - numZeroEntries++; - if (details) - detailedEntriesPerHash.push_back(0); - } - } - #ifdef _DEBUG - poco_assert_dbg(totalSize == numberOfEntries); - #endif - return HashStatistic(_maxCapacity, numberOfEntries, numZeroEntries, maxEntriesPerHash, detailedEntriesPerHash); - } - -private: - HashTableVector _entries; - std::size_t _size; - UInt32 _maxCapacity; - KeyHashFunction _hash; -}; - - -} // namespace Poco - - -#endif // Foundation_HashTable_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/KeyValueArgs.h b/contrib/libs/poco/Foundation/include/Poco/KeyValueArgs.h deleted file mode 100644 index cdcc4e1cec..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/KeyValueArgs.h +++ /dev/null @@ -1,73 +0,0 @@ -// -// KeyValueArgs.h -// -// Library: Foundation -// Package: Cache -// Module: KeyValueArgs -// -// Definition of the KeyValueArgs class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_KeyValueArgs_INCLUDED -#define Foundation_KeyValueArgs_INCLUDED - - -#include "Poco/Foundation.h" - - -namespace Poco { - - -template <class TKey, class TValue> -class KeyValueArgs - /// Simply event arguments class to transfer a key and a value via an event call. - /// Note that key and value are *NOT* copied, only references to them are stored. -{ -public: - KeyValueArgs(const TKey& aKey, const TValue& aVal): - _key(aKey), - _value(aVal) - { - } - - KeyValueArgs(const KeyValueArgs& args): - _key(args._key), - _value(args._value) - { - } - - ~KeyValueArgs() - { - } - - const TKey& key() const - /// Returns a reference to the key, - { - return _key; - } - - const TValue& value() const - /// Returns a Reference to the value. - { - return _value; - } - -protected: - const TKey& _key; - const TValue& _value; - -private: - KeyValueArgs& operator = (const KeyValueArgs& args); -}; - - -} // namespace Poco - - -#endif // Foundation_KeyValueArgs_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/LRUCache.h b/contrib/libs/poco/Foundation/include/Poco/LRUCache.h deleted file mode 100644 index 7f8f0debd9..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/LRUCache.h +++ /dev/null @@ -1,56 +0,0 @@ -// -// LRUCache.h -// -// Library: Foundation -// Package: Cache -// Module: LRUCache -// -// Definition of the LRUCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_LRUCache_INCLUDED -#define Foundation_LRUCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/LRUStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue>, TMutex, TEventMutex> - /// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries. -{ -public: - LRUCache(long size = 1024): - AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue>, TMutex, TEventMutex>(LRUStrategy<TKey, TValue>(size)) - { - } - - ~LRUCache() - { - } - -private: - LRUCache(const LRUCache& aCache); - LRUCache& operator = (const LRUCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_LRUCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/LRUStrategy.h b/contrib/libs/poco/Foundation/include/Poco/LRUStrategy.h deleted file mode 100644 index 795623872e..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/LRUStrategy.h +++ /dev/null @@ -1,140 +0,0 @@ -// -// LRUStrategy.h -// -// Library: Foundation -// Package: Cache -// Module: LRUStrategy -// -// Definition of the LRUStrategy class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_LRUStrategy_INCLUDED -#define Foundation_LRUStrategy_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/AbstractStrategy.h" -#include "Poco/EventArgs.h" -#include "Poco/Exception.h" -#include <list> -#include <map> -#include <cstddef> - - -namespace Poco { - - -template <class TKey, class TValue> -class LRUStrategy: public AbstractStrategy<TKey, TValue> - /// An LRUStrategy implements least recently used cache replacement. -{ -public: - typedef std::list<TKey> Keys; - typedef typename Keys::iterator Iterator; - typedef typename Keys::const_iterator ConstIterator; - typedef std::map<TKey, Iterator> KeyIndex; - typedef typename KeyIndex::iterator IndexIterator; - typedef typename KeyIndex::const_iterator ConstIndexIterator; - -public: - LRUStrategy(std::size_t size): - _size(size) - { - if (_size < 1) throw InvalidArgumentException("size must be > 0"); - } - - ~LRUStrategy() - { - } - - void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args) - { - _keys.push_front(args.key()); - std::pair<IndexIterator, bool> stat = _keyIndex.insert(std::make_pair(args.key(), _keys.begin())); - if (!stat.second) - { - stat.first->second = _keys.begin(); - } - } - - void onRemove(const void*, const TKey& key) - { - IndexIterator it = _keyIndex.find(key); - - if (it != _keyIndex.end()) - { - _keys.erase(it->second); - _keyIndex.erase(it); - } - } - - void onGet(const void*, const TKey& key) - { - // LRU: in case of an hit, move to begin - IndexIterator it = _keyIndex.find(key); - - if (it != _keyIndex.end()) - { - _keys.splice(_keys.begin(), _keys, it->second); //_keys.erase(it->second)+_keys.push_front(key); - it->second = _keys.begin(); - } - } - - void onClear(const void*, const EventArgs& /*args*/) - { - _keys.clear(); - _keyIndex.clear(); - } - - void onIsValid(const void*, ValidArgs<TKey>& args) - { - if (_keyIndex.find(args.key()) == _keyIndex.end()) - { - args.invalidate(); - } - } - - void onReplace(const void*, std::set<TKey>& elemsToRemove) - { - // Note: replace only informs the cache which elements - // it would like to remove! - // it does not remove them on its own! - std::size_t curSize = _keyIndex.size(); - - if (curSize < _size) - { - return; - } - - std::size_t diff = curSize - _size; - Iterator it = --_keys.end(); //--keys can never be invoked on an empty list due to the minSize==1 requirement of LRU - std::size_t i = 0; - - while (i++ < diff) - { - elemsToRemove.insert(*it); - if (it != _keys.begin()) - { - --it; - } - } - } - -protected: - std::size_t _size; /// Number of keys the cache can store. - Keys _keys; - KeyIndex _keyIndex; /// For faster access to _keys -}; - - -} // namespace Poco - - -#endif // Foundation_LRUStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/LinearHashTable.h b/contrib/libs/poco/Foundation/include/Poco/LinearHashTable.h deleted file mode 100644 index ac18b4b95a..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/LinearHashTable.h +++ /dev/null @@ -1,503 +0,0 @@ -// -// LinearHashTable.h -// -// Library: Foundation -// Package: Hashing -// Module: LinearHashTable -// -// Definition of the LinearHashTable class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_LinearHashTable_INCLUDED -#define Foundation_LinearHashTable_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Hash.h" -#include <functional> -#include <algorithm> -#include <vector> -#include <utility> -#include <cstddef> - - -namespace Poco { - - -template <class Value, class HashFunc = Hash<Value> > -class LinearHashTable - /// This class implements a linear hash table. - /// - /// In a linear hash table, the available address space - /// grows or shrinks dynamically. A linar hash table thus - /// supports any number of insertions or deletions without - /// lookup or insertion performance deterioration. - /// - /// Linear hashing was discovered by Witold Litwin in 1980 - /// and described in the paper LINEAR HASHING: A NEW TOOL FOR FILE AND TABLE ADDRESSING. - /// - /// For more information on linear hashing, see <http://en.wikipedia.org/wiki/Linear_hash>. - /// - /// The LinearHashTable is not thread safe. - /// - /// Value must support comparison for equality. - /// - /// Find, insert and delete operations are basically O(1) with regard - /// to the total number of elements in the table, and O(N) with regard - /// to the number of elements in the bucket where the element is stored. - /// On average, every bucket stores one element; the exact number depends - /// on the quality of the hash function. In most cases, the maximum number of - /// elements in a bucket should not exceed 3. -{ -public: - typedef Value ValueType; - typedef Value& Reference; - typedef const Value& ConstReference; - typedef Value* Pointer; - typedef const Value* ConstPointer; - typedef HashFunc Hash; - typedef std::vector<Value> Bucket; - typedef std::vector<Bucket> BucketVec; - typedef typename Bucket::iterator BucketIterator; - typedef typename BucketVec::iterator BucketVecIterator; - - class ConstIterator: public std::iterator<std::forward_iterator_tag, Value> - { - public: - ConstIterator(): _initialized(false) - { - } - - ConstIterator(const BucketVecIterator& vecIt, const BucketVecIterator& endIt, const BucketIterator& buckIt): - _vecIt(vecIt), - _endIt(endIt), - _buckIt(buckIt), - _initialized(true) - { - } - - ConstIterator(const ConstIterator& it): - _vecIt(it._vecIt), - _endIt(it._endIt), - _buckIt(it._buckIt), - _initialized(it._initialized) - - { - } - - ConstIterator& operator = (const ConstIterator& it) - { - ConstIterator tmp(it); - swap(tmp); - return *this; - } - - void swap(ConstIterator& it) - { - using std::swap; - // uninitialized iterators crash when swapped - if (_initialized) - { - swap(_vecIt, it._vecIt); - swap(_endIt, it._endIt); - swap(_buckIt, it._buckIt); - swap(_initialized, it._initialized); - } - else - { - _vecIt = it._vecIt; - _endIt = it._endIt; - _buckIt = it._buckIt; - _initialized = it._initialized; - } - } - - bool operator == (const ConstIterator& it) const - { - return _vecIt == it._vecIt && (_vecIt == _endIt || _buckIt == it._buckIt); - } - - bool operator != (const ConstIterator& it) const - { - return _vecIt != it._vecIt || (_vecIt != _endIt && _buckIt != it._buckIt); - } - - const typename Bucket::value_type& operator * () const - { - return *_buckIt; - } - - const typename Bucket::value_type* operator -> () const - { - return &*_buckIt; - } - - ConstIterator& operator ++ () // prefix - { - if (_vecIt != _endIt) - { - ++_buckIt; - while (_vecIt != _endIt && _buckIt == _vecIt->end()) - { - ++_vecIt; - if (_vecIt != _endIt) _buckIt = _vecIt->begin(); - } - } - return *this; - } - - ConstIterator operator ++ (int) // postfix - { - ConstIterator tmp(*this); - ++*this; - return tmp; - } - - protected: - BucketVecIterator _vecIt; - BucketVecIterator _endIt; - BucketIterator _buckIt; - bool _initialized; - - friend class LinearHashTable; - }; - - class Iterator: public ConstIterator - { - public: - Iterator() - { - } - - Iterator(const BucketVecIterator& vecIt, const BucketVecIterator& endIt, const BucketIterator& buckIt): - ConstIterator(vecIt, endIt, buckIt) - { - } - - Iterator(const Iterator& it): - ConstIterator(it) - { - } - - Iterator& operator = (const Iterator& it) - { - Iterator tmp(it); - ConstIterator::swap(tmp); - return *this; - } - - void swap(Iterator& it) - { - ConstIterator::swap(it); - } - - typename Bucket::value_type& operator * () - { - return *this->_buckIt; - } - - const typename Bucket::value_type& operator * () const - { - return *this->_buckIt; - } - - typename Bucket::value_type* operator -> () - { - return &*this->_buckIt; - } - - const typename Bucket::value_type* operator -> () const - { - return &*this->_buckIt; - } - - Iterator& operator ++ () // prefix - { - ConstIterator::operator ++ (); - return *this; - } - - Iterator operator ++ (int) // postfix - { - Iterator tmp(*this); - ++*this; - return tmp; - } - - friend class LinearHashTable; - }; - - LinearHashTable(std::size_t initialReserve = 64): - _split(0), - _front(1), - _size(0) - /// Creates the LinearHashTable, using the given initialReserve. - { - _buckets.reserve(calcSize(initialReserve)); - _buckets.push_back(Bucket()); - } - - LinearHashTable(const LinearHashTable& table): - _buckets(table._buckets), - _split(table._split), - _front(table._front), - _size(table._size) - /// Creates the LinearHashTable by copying another one. - { - } - - ~LinearHashTable() - /// Destroys the LinearHashTable. - { - } - - LinearHashTable& operator = (const LinearHashTable& table) - /// Assigns another LinearHashTable. - { - LinearHashTable tmp(table); - swap(tmp); - return *this; - } - - void swap(LinearHashTable& table) - /// Swaps the LinearHashTable with another one. - { - using std::swap; - swap(_buckets, table._buckets); - swap(_split, table._split); - swap(_front, table._front); - swap(_size, table._size); - } - - ConstIterator begin() const - /// Returns an iterator pointing to the first entry, if one exists. - { - BucketVecIterator it(_buckets.begin()); - BucketVecIterator end(_buckets.end()); - while (it != end && it->empty()) - { - ++it; - } - if (it == end) - return this->end(); - else - return ConstIterator(it, end, it->begin()); - } - - ConstIterator end() const - /// Returns an iterator pointing to the end of the table. - { - return ConstIterator(_buckets.end(), _buckets.end(), _buckets.front().end()); - } - - Iterator begin() - /// Returns an iterator pointing to the first entry, if one exists. - { - BucketVecIterator it(_buckets.begin()); - BucketVecIterator end(_buckets.end()); - while (it != end && it->empty()) - { - ++it; - } - if (it == end) - return this->end(); - else - return Iterator(it, end, it->begin()); - } - - Iterator end() - /// Returns an iterator pointing to the end of the table. - { - return Iterator(_buckets.end(), _buckets.end(), _buckets.front().end()); - } - - ConstIterator find(const Value& value) const - /// Finds an entry in the table. - { - std::size_t addr = bucketAddress(value); - BucketVecIterator it(_buckets.begin() + addr); - BucketIterator buckIt(std::find(it->begin(), it->end(), value)); - if (buckIt != it->end()) - return ConstIterator(it, _buckets.end(), buckIt); - else - return end(); - } - - Iterator find(const Value& value) - /// Finds an entry in the table. - { - std::size_t addr = bucketAddress(value); - BucketVecIterator it(_buckets.begin() + addr); - BucketIterator buckIt(std::find(it->begin(), it->end(), value)); - if (buckIt != it->end()) - return Iterator(it, _buckets.end(), buckIt); - else - return end(); - } - - std::size_t count(const Value& value) const - /// Returns the number of elements with the given - /// value, with is either 1 or 0. - { - return find(value) != end() ? 1 : 0; - } - - std::pair<Iterator, bool> insert(const Value& value) - /// Inserts an element into the table. - /// - /// If the element already exists in the table, - /// a pair(iterator, false) with iterator pointing to the - /// existing element is returned. - /// Otherwise, the element is inserted an a - /// pair(iterator, true) with iterator - /// pointing to the new element is returned. - { - std::size_t hash = _hash(value); - std::size_t addr = bucketAddressForHash(hash); - BucketVecIterator it(_buckets.begin() + addr); - BucketIterator buckIt(std::find(it->begin(), it->end(), value)); - if (buckIt == it->end()) - { - split(); - addr = bucketAddressForHash(hash); - it = _buckets.begin() + addr; - buckIt = it->insert(it->end(), value); - ++_size; - return std::make_pair(Iterator(it, _buckets.end(), buckIt), true); - } - else - { - return std::make_pair(Iterator(it, _buckets.end(), buckIt), false); - } - } - - void erase(Iterator it) - /// Erases the element pointed to by it. - { - if (it != end()) - { - it._vecIt->erase(it._buckIt); - --_size; - merge(); - } - } - - void erase(const Value& value) - /// Erases the element with the given value, if it exists. - { - Iterator it = find(value); - erase(it); - } - - void clear() - /// Erases all elements. - { - LinearHashTable empty; - swap(empty); - } - - std::size_t size() const - /// Returns the number of elements in the table. - { - return _size; - } - - bool empty() const - /// Returns true iff the table is empty. - { - return _size == 0; - } - - std::size_t buckets() const - /// Returns the number of allocated buckets. - { - return _buckets.size(); - } - -protected: - std::size_t bucketAddress(const Value& value) const - { - std::size_t n = _hash(value); - if (n % _front >= _split) - return n % _front; - else - return n % (2*_front); - } - - std::size_t bucketAddressForHash(std::size_t hash) - { - if (hash % _front >= _split) - return hash % _front; - else - return hash % (2*_front); - } - - void split() - { - if (_split == _front) - { - _split = 0; - _front *= 2; - _buckets.reserve(_front*2); - } - Bucket tmp; - _buckets.push_back(tmp); - _buckets[_split].swap(tmp); - ++_split; - for (BucketIterator it = tmp.begin(); it != tmp.end(); ++it) - { - using std::swap; - std::size_t addr = bucketAddress(*it); - _buckets[addr].push_back(Value()); - swap(*it, _buckets[addr].back()); - } - } - - void merge() - { - if (_split == 0) - { - _front /= 2; - _split = _front; - } - --_split; - Bucket tmp; - tmp.swap(_buckets.back()); - _buckets.pop_back(); - for (BucketIterator it = tmp.begin(); it != tmp.end(); ++it) - { - using std::swap; - std::size_t addr = bucketAddress(*it); - _buckets[addr].push_back(Value()); - swap(*it, _buckets[addr].back()); - } - } - - static std::size_t calcSize(std::size_t initialSize) - { - std::size_t size = 32; - while (size < initialSize) size *= 2; - return size; - } - -private: - // Evil hack: _buckets must be mutable because both ConstIterator and Iterator hold - // ordinary iterator's (not const_iterator's). - mutable BucketVec _buckets; - std::size_t _split; - std::size_t _front; - std::size_t _size; - HashFunc _hash; -}; - - -} // namespace Poco - - -#endif // Foundation_LinearHashTable_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/NObserver.h b/contrib/libs/poco/Foundation/include/Poco/NObserver.h deleted file mode 100644 index 8b5106c8b0..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/NObserver.h +++ /dev/null @@ -1,126 +0,0 @@ -// -// NObserver.h -// -// Library: Foundation -// Package: Notifications -// Module: NotificationCenter -// -// Definition of the NObserver class template. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_NObserver_INCLUDED -#define Foundation_NObserver_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/AbstractObserver.h" -#include "Poco/Mutex.h" - - -namespace Poco { - - -template <class C, class N> -class NObserver: public AbstractObserver - /// This template class implements an adapter that sits between - /// a NotificationCenter and an object receiving notifications - /// from it. It is quite similar in concept to the - /// RunnableAdapter, but provides some NotificationCenter - /// specific additional methods. - /// See the NotificationCenter class for information on how - /// to use this template class. - /// - /// This class template is quite similar to the Observer class - /// template. The only difference is that the NObserver - /// expects the callback function to accept a const AutoPtr& - /// instead of a plain pointer as argument, thus simplifying memory - /// management. -{ -public: - typedef AutoPtr<N> NotificationPtr; - typedef void (C::*Callback)(const NotificationPtr&); - - NObserver(C& object, Callback method): - _pObject(&object), - _method(method) - { - } - - NObserver(const NObserver& observer): - AbstractObserver(observer), - _pObject(observer._pObject), - _method(observer._method) - { - } - - ~NObserver() - { - } - - NObserver& operator = (const NObserver& observer) - { - if (&observer != this) - { - _pObject = observer._pObject; - _method = observer._method; - } - return *this; - } - - void notify(Notification* pNf) const - { - Poco::Mutex::ScopedLock lock(_mutex); - - if (_pObject) - { - N* pCastNf = dynamic_cast<N*>(pNf); - if (pCastNf) - { - NotificationPtr ptr(pCastNf, true); - (_pObject->*_method)(ptr); - } - } - } - - bool equals(const AbstractObserver& abstractObserver) const - { - const NObserver* pObs = dynamic_cast<const NObserver*>(&abstractObserver); - return pObs && pObs->_pObject == _pObject && pObs->_method == _method; - } - - bool accepts(Notification* pNf) const - { - return dynamic_cast<N*>(pNf) != 0; - } - - AbstractObserver* clone() const - { - return new NObserver(*this); - } - - void disable() - { - Poco::Mutex::ScopedLock lock(_mutex); - - _pObject = 0; - } - -private: - NObserver(); - - C* _pObject; - Callback _method; - mutable Poco::Mutex _mutex; -}; - - -} // namespace Poco - - -#endif // Foundation_NObserver_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/NamedTuple.h b/contrib/libs/poco/Foundation/include/Poco/NamedTuple.h deleted file mode 100644 index 9a193575d6..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/NamedTuple.h +++ /dev/null @@ -1,4462 +0,0 @@ -// -// NamedTuple.h -// -// Library: Foundation -// Package: Core -// Module: NamedTuple -// -// Definition of the NamedTuple class. -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_NamedTuple_INCLUDED -#define Foundation_NamedTuple_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Tuple.h" -#include "Poco/TypeList.h" -#include "Poco/DynamicAny.h" -#include "Poco/SharedPtr.h" -#include "Poco/Format.h" - - -namespace Poco { - - -template<class T0, - class T1 = NullTypeList, - class T2 = NullTypeList, - class T3 = NullTypeList, - class T4 = NullTypeList, - class T5 = NullTypeList, - class T6 = NullTypeList, - class T7 = NullTypeList, - class T8 = NullTypeList, - class T9 = NullTypeList, - class T10 = NullTypeList, - class T11 = NullTypeList, - class T12 = NullTypeList, - class T13 = NullTypeList, - class T14 = NullTypeList, - class T15 = NullTypeList, - class T16 = NullTypeList, - class T17 = NullTypeList, - class T18 = NullTypeList, - class T19 = NullTypeList> -struct NamedTuple: public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>::Type Type; - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), - typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), - typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), - typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), - typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - const std::string& n13 = "N", - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - const std::string& n14 = "O", - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - const std::string& n15 = "P", - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - const std::string& n16 = "Q", - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - const std::string& n17 = "R", - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), - const std::string& n18 = "S", - typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18), - const std::string& n19 = "T", - typename TypeWrapper<T19>::CONSTTYPE& t19 = POCO_TYPEWRAPPER_DEFAULTVALUE(T19)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18,n19); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - case 13: return TupleType::template get<13>(); - case 14: return TupleType::template get<14>(); - case 15: return TupleType::template get<15>(); - case 16: return TupleType::template get<16>(); - case 17: return TupleType::template get<17>(); - case 18: return TupleType::template get<18>(); - case 19: return TupleType::template get<19>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M", - const std::string& n13 = "N", - const std::string& n14 = "O", - const std::string& n15 = "P", - const std::string& n16 = "Q", - const std::string& n17 = "R", - const std::string& n18 = "S", - const std::string& n19 = "T") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - _pNames->push_back(n13); - _pNames->push_back(n14); - _pNames->push_back(n15); - _pNames->push_back(n16); - _pNames->push_back(n17); - _pNames->push_back(n18); - _pNames->push_back(n19); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11, - class T12, - class T13, - class T14, - class T15, - class T16, - class T17, - class T18> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>::Type Type; - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), - typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), - typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - const std::string& n13 = "N", - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - const std::string& n14 = "O", - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - const std::string& n15 = "P", - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - const std::string& n16 = "Q", - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - const std::string& n17 = "R", - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17), - const std::string& n18 = "S", - typename TypeWrapper<T18>::CONSTTYPE& t18 = POCO_TYPEWRAPPER_DEFAULTVALUE(T18)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17,n18); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - case 13: return TupleType::template get<13>(); - case 14: return TupleType::template get<14>(); - case 15: return TupleType::template get<15>(); - case 16: return TupleType::template get<16>(); - case 17: return TupleType::template get<17>(); - case 18: return TupleType::template get<18>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M", - const std::string& n13 = "N", - const std::string& n14 = "O", - const std::string& n15 = "P", - const std::string& n16 = "Q", - const std::string& n17 = "R", - const std::string& n18 = "S") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - _pNames->push_back(n13); - _pNames->push_back(n14); - _pNames->push_back(n15); - _pNames->push_back(n16); - _pNames->push_back(n17); - _pNames->push_back(n18); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11, - class T12, - class T13, - class T14, - class T15, - class T16, - class T17> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>::Type Type; - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - const std::string& n13 = "N", - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - const std::string& n14 = "O", - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - const std::string& n15 = "P", - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - const std::string& n16 = "Q", - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16), - const std::string& n17 = "R", - typename TypeWrapper<T17>::CONSTTYPE& t17 = POCO_TYPEWRAPPER_DEFAULTVALUE(T17)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16,n17); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - case 13: return TupleType::template get<13>(); - case 14: return TupleType::template get<14>(); - case 15: return TupleType::template get<15>(); - case 16: return TupleType::template get<16>(); - case 17: return TupleType::template get<17>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M", - const std::string& n13 = "N", - const std::string& n14 = "O", - const std::string& n15 = "P", - const std::string& n16 = "Q", - const std::string& n17 = "R") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - _pNames->push_back(n13); - _pNames->push_back(n14); - _pNames->push_back(n15); - _pNames->push_back(n16); - _pNames->push_back(n17); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11, - class T12, - class T13, - class T14, - class T15, - class T16> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>::Type Type; - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - const std::string& n13 = "N", - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - const std::string& n14 = "O", - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - const std::string& n15 = "P", - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15), - const std::string& n16 = "Q", - typename TypeWrapper<T16>::CONSTTYPE& t16 = POCO_TYPEWRAPPER_DEFAULTVALUE(T16)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,n16); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - case 13: return TupleType::template get<13>(); - case 14: return TupleType::template get<14>(); - case 15: return TupleType::template get<15>(); - case 16: return TupleType::template get<16>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M", - const std::string& n13 = "N", - const std::string& n14 = "O", - const std::string& n15 = "P", - const std::string& n16 = "Q") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - _pNames->push_back(n13); - _pNames->push_back(n14); - _pNames->push_back(n15); - _pNames->push_back(n16); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11, - class T12, - class T13, - class T14, - class T15> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - const std::string& n13 = "N", - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - const std::string& n14 = "O", - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14), - const std::string& n15 = "P", - typename TypeWrapper<T15>::CONSTTYPE& t15 = POCO_TYPEWRAPPER_DEFAULTVALUE(T15)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - case 13: return TupleType::template get<13>(); - case 14: return TupleType::template get<14>(); - case 15: return TupleType::template get<15>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M", - const std::string& n13 = "N", - const std::string& n14 = "O", - const std::string& n15 = "P") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - _pNames->push_back(n13); - _pNames->push_back(n14); - _pNames->push_back(n15); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11, - class T12, - class T13, - class T14> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - const std::string& n13 = "N", - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13), - const std::string& n14 = "O", - typename TypeWrapper<T14>::CONSTTYPE& t14 = POCO_TYPEWRAPPER_DEFAULTVALUE(T14)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - case 13: return TupleType::template get<13>(); - case 14: return TupleType::template get<14>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M", - const std::string& n13 = "N", - const std::string& n14 = "O") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - _pNames->push_back(n13); - _pNames->push_back(n14); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11, - class T12, - class T13> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12), - const std::string& n13 = "N", - typename TypeWrapper<T13>::CONSTTYPE& t13 = POCO_TYPEWRAPPER_DEFAULTVALUE(T13)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - case 13: return TupleType::template get<13>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M", - const std::string& n13 = "N") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - _pNames->push_back(n13); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11, - class T12> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11), - const std::string& n12 = "M", - typename TypeWrapper<T12>::CONSTTYPE& t12 = POCO_TYPEWRAPPER_DEFAULTVALUE(T12)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12), _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - case 12: return TupleType::template get<12>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L", - const std::string& n12 = "M") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - _pNames->push_back(n12); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10, - class T11> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10), - const std::string& n11 = "L", - typename TypeWrapper<T11>::CONSTTYPE& t11 = POCO_TYPEWRAPPER_DEFAULTVALUE(T11)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - case 11: return TupleType::template get<11>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K", - const std::string& n11 = "L") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - _pNames->push_back(n11); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9, - class T10> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9), - const std::string& n10 = "K", - typename TypeWrapper<T10>::CONSTTYPE& t10 = POCO_TYPEWRAPPER_DEFAULTVALUE(T10)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10), _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9,n10); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - case 10: return TupleType::template get<10>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J", - const std::string& n10 = "K") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - _pNames->push_back(n10); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8, - class T9> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8), - const std::string& n9 = "J", - typename TypeWrapper<T9>::CONSTTYPE& t9 = POCO_TYPEWRAPPER_DEFAULTVALUE(T9)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8,n9); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - case 9: return TupleType::template get<9>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I", - const std::string& n9 = "J") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - _pNames->push_back(n9); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7, - class T8> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7), - const std::string& n8 = "I", - typename TypeWrapper<T8>::CONSTTYPE& t8 = POCO_TYPEWRAPPER_DEFAULTVALUE(T8)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7,t8), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7,n8); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - case 8: return TupleType::template get<8>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H", - const std::string& n8 = "I") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - _pNames->push_back(n8); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6, - class T7> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,T7,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6,T7> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6,T7> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6,T7>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6), - const std::string& n7 = "H", - typename TypeWrapper<T7>::CONSTTYPE& t7 = POCO_TYPEWRAPPER_DEFAULTVALUE(T7)): - TupleType(t0,t1,t2,t3,t4,t5,t6,t7), - _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6,n7); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - case 7: return TupleType::template get<7>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G", - const std::string& n7 = "H") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - _pNames->push_back(n7); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5, - class T6> -struct NamedTuple<T0,T1,T2,T3,T4,T5,T6,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5,T6> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5,T6> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5,T6>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)): - TupleType(t0,t1,t2,t3,t4,t5,t6), _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)): - TupleType(t0,t1,t2,t3,t4,t5,t6) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5), - const std::string& n6 = "G", - typename TypeWrapper<T6>::CONSTTYPE& t6 = POCO_TYPEWRAPPER_DEFAULTVALUE(T6)): - TupleType(t0,t1,t2,t3,t4,t5,t6), _pNames(0) - { - init(n0,n1,n2,n3,n4,n5,n6); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - case 6: return TupleType::template get<6>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F", - const std::string& n6 = "G") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - _pNames->push_back(n6); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4, - class T5> -struct NamedTuple<T0,T1,T2,T3,T4,T5,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4,T5> -{ - typedef Tuple<T0,T1,T2,T3,T4,T5> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4,T5>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)): - TupleType(t0,t1,t2,t3,t4,t5), _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)): - TupleType(t0,t1,t2,t3,t4,t5) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4), - const std::string& n5 = "F", - typename TypeWrapper<T5>::CONSTTYPE& t5 = POCO_TYPEWRAPPER_DEFAULTVALUE(T5)): - TupleType(t0,t1,t2,t3,t4,t5), _pNames(0) - { - init(n0,n1,n2,n3,n4,n5); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - case 5: return TupleType::template get<5>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E", - const std::string& n5 = "F") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - _pNames->push_back(n5); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3, - class T4> -struct NamedTuple<T0,T1,T2,T3,T4,NullTypeList>: - public Tuple<T0,T1,T2,T3,T4> -{ - typedef Tuple<T0,T1,T2,T3,T4> TupleType; - typedef typename Tuple<T0,T1,T2,T3,T4>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)): - TupleType(t0,t1,t2,t3,t4), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)): - TupleType(t0,t1,t2,t3,t4) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3), - const std::string& n4 = "E", - typename TypeWrapper<T4>::CONSTTYPE& t4 = POCO_TYPEWRAPPER_DEFAULTVALUE(T4)): - TupleType(t0,t1,t2,t3,t4), - _pNames(0) - { - init(n0,n1,n2,n3,n4); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - case 4: return TupleType::template get<4>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D", - const std::string& n4 = "E") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - _pNames->push_back(n4); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2, - class T3> -struct NamedTuple<T0,T1,T2,T3,NullTypeList>: - public Tuple<T0,T1,T2,T3> -{ - typedef Tuple<T0,T1,T2,T3> TupleType; - typedef typename Tuple<T0,T1,T2,T3>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)): - TupleType(t0,t1,t2,t3), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)): - TupleType(t0,t1,t2,t3) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2), - const std::string& n3 = "D", - typename TypeWrapper<T3>::CONSTTYPE& t3 = POCO_TYPEWRAPPER_DEFAULTVALUE(T3)): - TupleType(t0,t1,t2,t3), _pNames(0) - { - init(n0,n1,n2,n3); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - case 3: return TupleType::template get<3>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C", - const std::string& n3 = "D") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - _pNames->push_back(n3); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1, - class T2> -struct NamedTuple<T0,T1,T2,NullTypeList>: - public Tuple<T0,T1,T2> -{ - typedef Tuple<T0,T1,T2> TupleType; - typedef typename Tuple<T0,T1,T2>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)): - TupleType(t0,t1,t2), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)): - TupleType(t0,t1,t2) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1), - const std::string& n2 = "C", - typename TypeWrapper<T2>::CONSTTYPE& t2 = POCO_TYPEWRAPPER_DEFAULTVALUE(T2)): - TupleType(t0,t1,t2), - _pNames(0) - { - init(n0,n1,n2); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - case 2: return TupleType::template get<2>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B", - const std::string& n2 = "C") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - _pNames->push_back(n2); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0, - class T1> -struct NamedTuple<T0,T1,NullTypeList>: - public Tuple<T0,T1> -{ - typedef Tuple<T0,T1> TupleType; - typedef typename Tuple<T0,T1>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)): - TupleType(t0,t1), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0, - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)): - TupleType(t0,t1) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, - typename TypeWrapper<T0>::CONSTTYPE& t0, - const std::string& n1 = "B", - typename TypeWrapper<T1>::CONSTTYPE& t1 = POCO_TYPEWRAPPER_DEFAULTVALUE(T1)): - TupleType(t0,t1), - _pNames(0) - { - init(n0,n1); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - case 1: return TupleType::template get<1>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A", - const std::string& n1 = "B") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - _pNames->push_back(n1); - } - } - - NameVecPtr _pNames; -}; - - -template<class T0> -struct NamedTuple<T0,NullTypeList>: - public Tuple<T0> -{ - typedef Tuple<T0> TupleType; - typedef typename Tuple<T0>::Type Type; - - typedef std::vector<std::string> NameVec; - typedef SharedPtr<NameVec> NameVecPtr; - - NamedTuple(): _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(typename TypeWrapper<T0>::CONSTTYPE& t0): - TupleType(t0), - _pNames(0) - { - init(); - } - - NamedTuple(const NameVecPtr& rNames, - typename TypeWrapper<T0>::CONSTTYPE& t0): - TupleType(t0) - { - if (rNames->size() != TupleType::length) - throw InvalidArgumentException("Wrong names vector length."); - - _pNames = rNames; - } - - NamedTuple(const std::string& n0, typename TypeWrapper<T0>::CONSTTYPE& t0): - TupleType(t0), - _pNames(0) - { - init(n0); - } - - const DynamicAny get(const std::string& name) const - { - NameVec::const_iterator it = _pNames->begin(); - NameVec::const_iterator itEnd = _pNames->end(); - - for(std::size_t counter = 0; it != itEnd; ++it, ++counter) - { - if (name == *it) - { - switch (counter) - { - case 0: return TupleType::template get<0>(); - default: throw RangeException(); - } - } - } - - throw NotFoundException("Name not found: " + name); - } - - const DynamicAny operator [] (const std::string& name) const - { - return get(name); - } - - template<int N> - typename TypeGetter<N, Type>::ConstHeadType& get() const - { - return TupleType::template get<N>(); - } - - template<int N> - typename TypeGetter<N, Type>::HeadType& get() - { - return TupleType::template get<N>(); - } - - template<int N> - void set(typename TypeGetter<N, Type>::ConstHeadType& val) - { - return TupleType::template set<N>(val); - } - - const NameVecPtr& names() - { - return _pNames; - } - - void setName(std::size_t index, const std::string& name) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - (*_pNames)[index] = name; - } - - const std::string& getName(std::size_t index) - { - if (index >= _pNames->size()) - throw InvalidArgumentException(format("Invalid index: %z", index)); - - return (*_pNames)[index]; - } - - bool operator == (const NamedTuple& other) const - { - return TupleType(*this) == TupleType(other) && _pNames == other._pNames; - } - - bool operator != (const NamedTuple& other) const - { - return !(*this == other); - } - - bool operator < (const NamedTuple& other) const - { - TupleType th(*this); - TupleType oth(other); - - return (th < oth && _pNames == other._pNames) || - (th == oth && _pNames < other._pNames) || - (th < oth && _pNames < other._pNames); - } - -private: - void init(const std::string& n0 = "A") - { - if (!_pNames) - { - _pNames = new NameVec; - _pNames->push_back(n0); - } - } - - NameVecPtr _pNames; -}; - - -} // namespace Poco - - -#endif // Foundation_Tuple_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/ObjectPool.h b/contrib/libs/poco/Foundation/include/Poco/ObjectPool.h deleted file mode 100644 index af3d7bab05..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ObjectPool.h +++ /dev/null @@ -1,332 +0,0 @@ -// -// ObjectPool.h -// -// Library: Foundation -// Package: Core -// Module: ObjectPool -// -// Definition of the ObjectPool template class and friends. -// -// Copyright (c) 2010-2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ObjectPool_INCLUDED -#define Foundation_ObjectPool_INCLUDED - - -#include "Poco/Poco.h" -#include "Poco/Mutex.h" -#include "Poco/Condition.h" -#include "Poco/AutoPtr.h" -#include "Poco/SharedPtr.h" -#include <vector> -#include <cctype> - - -namespace Poco { - - -template <class C, class P = C*> -class PoolableObjectFactory - /// A PoolableObjectFactory is responsible for creating and resetting - /// objects managed by an ObjectPool. - /// - /// Together with an ObjectPool, a PoolableObjectFactory is used as - /// a policy class to change the behavior of the ObjectPool when - /// creating new objects, returning used objects back to the pool - /// and destroying objects, when the pool itself is destroyed or - /// shrunk. -{ -public: - P createObject() - /// Create and return a new object. - { - return new C; - } - - bool validateObject(P pObject) - /// Checks whether the object is still valid - /// and can be reused. - /// - /// Returns true if the object is valid, - /// false otherwise. - /// - /// To maintain the integrity of the pool, this method - /// must not throw an exception. - { - return true; - } - - void activateObject(P pObject) - /// Called before an object is handed out by the pool. - /// Also called for newly created objects, before - /// they are given out for the first time. - { - } - - void deactivateObject(P pObject) - /// Called after an object has been given back to the - /// pool and the object is still valid (a prior call - /// to validateObject() returned true). - /// - /// To maintain the integrity of the pool, this method - /// must not throw an exception. - { - } - - void destroyObject(P pObject) - /// Destroy an object. - /// - /// To maintain the integrity of the pool, this method - /// must not throw an exception. - { - delete pObject; - } -}; - - -template <class C> -class PoolableObjectFactory <C, Poco::AutoPtr<C> > -{ -public: - Poco::AutoPtr<C> createObject() - { - return new C; - } - - bool validateObject(Poco::AutoPtr<C> pObject) - { - return true; - } - - void activateObject(Poco::AutoPtr<C> pObject) - { - } - - void deactivateObject(Poco::AutoPtr<C> pObject) - { - } - - void destroyObject(Poco::AutoPtr<C> pObject) - { - } -}; - - -template <class C> -class PoolableObjectFactory <C, Poco::SharedPtr<C> > -{ -public: - Poco::SharedPtr<C> createObject() - { - return new C; - } - - bool validateObject(Poco::SharedPtr<C> pObject) - { - return true; - } - - void activateObject(Poco::SharedPtr<C> pObject) - { - } - - void deactivateObject(Poco::SharedPtr<C> pObject) - { - } - - void destroyObject(Poco::SharedPtr<C> pObject) - { - } -}; - - -template <class C, class P = C*, class F = PoolableObjectFactory<C, P> > -class ObjectPool - /// An ObjectPool manages a pool of objects of a certain class. - /// - /// The number of objects managed by the pool can be restricted. - /// - /// When an object is requested from the pool: - /// - If an object is available from the pool, an object from the pool is - /// removed from the pool, activated (using the factory) and returned. - /// - Otherwise, if the peak capacity of the pool has not yet been reached, - /// a new object is created and activated, using the object factory, and returned. - /// - If the peak capacity has already been reached, null is returned after timeout. - /// - /// When an object is returned to the pool: - /// - If the object is valid (checked by calling validateObject() - /// from the object factory), the object is deactivated. If the - /// number of objects in the pool is below the capacity, - /// the object is added to the pool. Otherwise it is destroyed. - /// - If the object is not valid, it is destroyed immediately. -{ -public: - ObjectPool(std::size_t capacity, std::size_t peakCapacity): - /// Creates a new ObjectPool with the given capacity - /// and peak capacity. - /// - /// The PoolableObjectFactory must have a public default constructor. - _capacity(capacity), - _peakCapacity(peakCapacity), - _size(0) - { - poco_assert (capacity <= peakCapacity); - } - - ObjectPool(const F& factory, std::size_t capacity, std::size_t peakCapacity): - /// Creates a new ObjectPool with the given PoolableObjectFactory, - /// capacity and peak capacity. The PoolableObjectFactory must have - /// a public copy constructor. - _factory(factory), - _capacity(capacity), - _peakCapacity(peakCapacity), - _size(0) - { - poco_assert (capacity <= peakCapacity); - } - - ~ObjectPool() - /// Destroys the ObjectPool. - { - try - { - for (typename std::vector<P>::iterator it = _pool.begin(); it != _pool.end(); ++it) - { - _factory.destroyObject(*it); - } - } - catch (...) - { - poco_unexpected(); - } - } - - P borrowObject(long timeoutMilliseconds = 0) - /// Obtains an object from the pool, or creates a new object if - /// possible. - /// - /// Returns null if no object is available after timeout. - /// - /// If activating the object fails, the object is destroyed and - /// the exception is passed on to the caller. - { - Poco::FastMutex::ScopedLock lock(_mutex); - - if (!_pool.empty()) - { - P pObject = _pool.back(); - _pool.pop_back(); - return activateObject(pObject); - } - - if (_size >= _peakCapacity) - { - if (timeoutMilliseconds == 0) - { - return 0; - } - while (_size >= _peakCapacity) - { - if ( !_availableCondition.tryWait(_mutex, timeoutMilliseconds)) - { - // timeout - return 0; - } - } - } - - // _size < _peakCapacity - P pObject = _factory.createObject(); - activateObject(pObject); - _size++; - return pObject; - } - - void returnObject(P pObject) - /// Returns an object to the pool. - { - Poco::FastMutex::ScopedLock lock(_mutex); - - if (_factory.validateObject(pObject)) - { - _factory.deactivateObject(pObject); - if (_pool.size() < _capacity) - { - try - { - _pool.push_back(pObject); - return; - } - catch (...) - { - } - } - } - _factory.destroyObject(pObject); - _size--; - _availableCondition.signal(); - } - - std::size_t capacity() const - { - return _capacity; - } - - std::size_t peakCapacity() const - { - return _peakCapacity; - } - - std::size_t size() const - { - Poco::FastMutex::ScopedLock lock(_mutex); - - return _size; - } - - std::size_t available() const - { - Poco::FastMutex::ScopedLock lock(_mutex); - - return _pool.size() + _peakCapacity - _size; - } - -protected: - P activateObject(P pObject) - { - try - { - _factory.activateObject(pObject); - } - catch (...) - { - _factory.destroyObject(pObject); - throw; - } - return pObject; - } - -private: - ObjectPool(); - ObjectPool(const ObjectPool&); - ObjectPool& operator = (const ObjectPool&); - - F _factory; - std::size_t _capacity; - std::size_t _peakCapacity; - std::size_t _size; - std::vector<P> _pool; - mutable Poco::FastMutex _mutex; - Poco::Condition _availableCondition; -}; - - -} // namespace Poco - - -#endif // Foundation_ObjectPool_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/Optional.h b/contrib/libs/poco/Foundation/include/Poco/Optional.h deleted file mode 100644 index 54593b16cc..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/Optional.h +++ /dev/null @@ -1,161 +0,0 @@ -// -// Optional.h -// -// Library: Foundation -// Package: Core -// Module: Optional -// -// Definition of the Optional class template. -// -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_Optional_INCLUDED -#define Foundation_Optional_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Exception.h" -#include <algorithm> - - -namespace Poco { - - -template <typename C> -class Optional - /// Optional is a simple wrapper class for value types - /// that allows to introduce a specified/unspecified state - /// to value objects. - /// - /// An Optional can be default constructed. In this case, - /// the Optional will have a Null value and isSpecified() will - /// return false. Calling value()(without default value) on - /// a Null object will throw a NullValueException. - /// - /// An Optional can also be constructed from a value. - /// It is possible to assign a value to an Optional, and - /// to reset an Optional to contain a Null value by calling - /// clear(). - /// - /// For use with Optional, the value type should support - /// default construction. - /// - /// Note that the Optional class is basically the same as - /// Nullable. However, serializers may treat Nullable - /// and Optional differently. An example is XML serialization based - /// on XML Schema, where Optional would be used for an element with - /// minOccurs == 0, whereas Nullable would be used on an element with - /// nillable == true. -{ -public: - Optional(): - /// Creates an empty Optional. - _value(), - _isSpecified(false) - { - } - - Optional(const C& value): - /// Creates a Optional with the given value. - _value(value), - _isSpecified(true) - { - } - - Optional(const Optional& other): - /// Creates a Optional by copying another one. - _value(other._value), - _isSpecified(other._isSpecified) - { - } - - ~Optional() - /// Destroys the Optional. - { - } - - Optional& assign(const C& value) - /// Assigns a value to the Optional. - { - _value = value; - _isSpecified = true; - return *this; - } - - Optional& assign(const Optional& other) - /// Assigns another Optional. - { - Optional tmp(other); - swap(tmp); - return *this; - } - - Optional& operator = (const C& value) - { - return assign(value); - } - - Optional& operator = (const Optional& other) - { - return assign(other); - } - - void swap(Optional& other) - { - std::swap(_value, other._value); - std::swap(_isSpecified, other._isSpecified); - } - - const C& value() const - /// Returns the Optional's value. - /// - /// Throws a Poco::NullValueException if the value has not been specified. - { - if (_isSpecified) - return _value; - else - throw Poco::NullValueException(); - } - - const C& value(const C& deflt) const - /// Returns the Optional's value, or the - /// given default value if the Optional's - /// value has not been specified. - { - return _isSpecified ? _value : deflt; - } - - bool isSpecified() const - /// Returns true iff the Optional's value has been specified. - { - return _isSpecified; - } - - void clear() - /// Clears the Optional. - { - _isSpecified = false; - } - -private: - C _value; - bool _isSpecified; -}; - - -template <typename C> -inline void swap(Optional<C>& n1, Optional<C>& n2) -{ - n1.swap(n2); -} - - -} // namespace Poco - - -#endif // Foundation_Optional_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/PBKDF2Engine.h b/contrib/libs/poco/Foundation/include/Poco/PBKDF2Engine.h deleted file mode 100644 index 357d482afe..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/PBKDF2Engine.h +++ /dev/null @@ -1,149 +0,0 @@ -// -// PBKDF2Engine.h -// -// Library: Foundation -// Package: Crypt -// Module: PBKDF2Engine -// -// Definition of the PBKDF2Engine class. -// -// Copyright (c) 2014, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_PBKDF2Engine_INCLUDED -#define Foundation_PBKDF2Engine_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/DigestEngine.h" -#include "Poco/ByteOrder.h" -#include <algorithm> - - -namespace Poco { - - -template <class PRF> -class PBKDF2Engine: public DigestEngine - /// This class implementes the Password-Based Key Derivation Function 2, - /// as specified in RFC 2898. The underlying DigestEngine (HMACEngine, etc.), - /// which must accept the passphrase as constructor argument (std::string), - /// must be given as template argument. - /// - /// PBKDF2 (Password-Based Key Derivation Function 2) is a key derivation function - /// that is part of RSA Laboratories' Public-Key Cryptography Standards (PKCS) series, - /// specifically PKCS #5 v2.0, also published as Internet Engineering Task Force's - /// RFC 2898. It replaces an earlier standard, PBKDF1, which could only produce - /// derived keys up to 160 bits long. - /// - /// PBKDF2 applies a pseudorandom function, such as a cryptographic hash, cipher, or - /// HMAC to the input password or passphrase along with a salt value and repeats the - /// process many times to produce a derived key, which can then be used as a - /// cryptographic key in subsequent operations. The added computational work makes - /// password cracking much more difficult, and is known as key stretching. - /// When the standard was written in 2000, the recommended minimum number of - /// iterations was 1000, but the parameter is intended to be increased over time as - /// CPU speeds increase. Having a salt added to the password reduces the ability to - /// use precomputed hashes (rainbow tables) for attacks, and means that multiple - /// passwords have to be tested individually, not all at once. The standard - /// recommends a salt length of at least 64 bits. [Wikipedia] - /// - /// The PBKDF2 algorithm is implemented as a DigestEngine. The passphrase is specified - /// by calling update(). - /// - /// Example (WPA2): - /// PBKDF2Engine<HMACEngine<SHA1Engine> > pbkdf2(ssid, 4096, 256); - /// pbkdf2.update(passphrase); - /// DigestEngine::Digest d = pbkdf2.digest(); -{ -public: - enum - { - PRF_DIGEST_SIZE = PRF::DIGEST_SIZE - }; - - PBKDF2Engine(const std::string& salt, unsigned c = 4096, Poco::UInt32 dkLen = PRF_DIGEST_SIZE): - _s(salt), - _c(c), - _dkLen(dkLen) - { - _result.reserve(_dkLen + PRF_DIGEST_SIZE); - } - - ~PBKDF2Engine() - { - } - - std::size_t digestLength() const - { - return _dkLen; - } - - void reset() - { - _p.clear(); - _result.clear(); - } - - const DigestEngine::Digest& digest() - { - Poco::UInt32 i = 1; - while (_result.size() < _dkLen) - { - f(i++); - } - _result.resize(_dkLen); - return _result; - } - -protected: - void updateImpl(const void* data, std::size_t length) - { - _p.append(reinterpret_cast<const char*>(data), length); - } - - void f(Poco::UInt32 i) - { - PRF prf(_p); - prf.update(_s); - Poco::UInt32 iBE = Poco::ByteOrder::toBigEndian(i); - prf.update(&iBE, sizeof(iBE)); - Poco::DigestEngine::Digest up = prf.digest(); - Poco::DigestEngine::Digest ux = up; - poco_assert_dbg(ux.size() == PRF_DIGEST_SIZE); - for (unsigned k = 1; k < _c; k++) - { - prf.reset(); - prf.update(&up[0], up.size()); - Poco::DigestEngine::Digest u = prf.digest(); - poco_assert_dbg(u.size() == PRF_DIGEST_SIZE); - for (int ui = 0; ui < PRF_DIGEST_SIZE; ui++) - { - ux[ui] ^= u[ui]; - } - std::swap(up, u); - } - _result.insert(_result.end(), ux.begin(), ux.end()); - } - -private: - PBKDF2Engine(); - PBKDF2Engine(const PBKDF2Engine&); - PBKDF2Engine& operator = (const PBKDF2Engine&); - - std::string _p; - std::string _s; - unsigned _c; - Poco::UInt32 _dkLen; - DigestEngine::Digest _result; -}; - - -} // namespace Poco - - -#endif // Foundation_PBKDF2Engine_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/PriorityDelegate.h b/contrib/libs/poco/Foundation/include/Poco/PriorityDelegate.h deleted file mode 100644 index 7c776b9406..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/PriorityDelegate.h +++ /dev/null @@ -1,464 +0,0 @@ -// -// PriorityDelegate.h -// -// Library: Foundation -// Package: Events -// Module: PriorityDelegate -// -// Implementation of the PriorityDelegate template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_PriorityDelegate_INCLUDED -#define Foundation_PriorityDelegate_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/AbstractPriorityDelegate.h" -#include "Poco/PriorityExpire.h" -#include "Poco/FunctionPriorityDelegate.h" -#include "Poco/Mutex.h" - - -namespace Poco { - - -template <class TObj, class TArgs, bool useSender = true> -class PriorityDelegate: public AbstractPriorityDelegate<TArgs> -{ -public: - typedef void (TObj::*NotifyMethod)(const void*, TArgs&); - - PriorityDelegate(TObj* obj, NotifyMethod method, int prio): - AbstractPriorityDelegate<TArgs>(prio), - _receiverObject(obj), - _receiverMethod(method) - { - } - - PriorityDelegate(const PriorityDelegate& delegate): - AbstractPriorityDelegate<TArgs>(delegate), - _receiverObject(delegate._receiverObject), - _receiverMethod(delegate._receiverMethod) - { - } - - PriorityDelegate& operator = (const PriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_pTarget = delegate._pTarget; - this->_receiverObject = delegate._receiverObject; - this->_receiverMethod = delegate._receiverMethod; - this->_priority = delegate._priority; - } - return *this; - } - - ~PriorityDelegate() - { - } - - bool notify(const void* sender, TArgs& arguments) - { - Mutex::ScopedLock lock(_mutex); - if (_receiverObject) - { - (_receiverObject->*_receiverMethod)(sender, arguments); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<TArgs>& other) const - { - const PriorityDelegate* pOtherDelegate = dynamic_cast<const PriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _receiverObject == pOtherDelegate->_receiverObject && _receiverMethod == pOtherDelegate->_receiverMethod; - } - - AbstractDelegate<TArgs>* clone() const - { - return new PriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _receiverObject = 0; - } - -protected: - TObj* _receiverObject; - NotifyMethod _receiverMethod; - Mutex _mutex; - -private: - PriorityDelegate(); -}; - - -template <class TObj, class TArgs> -class PriorityDelegate<TObj, TArgs, false>: public AbstractPriorityDelegate<TArgs> -{ -public: - typedef void (TObj::*NotifyMethod)(TArgs&); - - PriorityDelegate(TObj* obj, NotifyMethod method, int prio): - AbstractPriorityDelegate<TArgs>(prio), - _receiverObject(obj), - _receiverMethod(method) - { - } - - PriorityDelegate(const PriorityDelegate& delegate): - AbstractPriorityDelegate<TArgs>(delegate), - _receiverObject(delegate._receiverObject), - _receiverMethod(delegate._receiverMethod) - { - } - - PriorityDelegate& operator = (const PriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_pTarget = delegate._pTarget; - this->_receiverObject = delegate._receiverObject; - this->_receiverMethod = delegate._receiverMethod; - this->_priority = delegate._priority; - } - return *this; - } - - ~PriorityDelegate() - { - } - - bool notify(const void* sender, TArgs& arguments) - { - Mutex::ScopedLock lock(_mutex); - if (_receiverObject) - { - (_receiverObject->*_receiverMethod)(arguments); - return true; - } - return false; - } - - bool equals(const AbstractDelegate<TArgs>& other) const - { - const PriorityDelegate* pOtherDelegate = dynamic_cast<const PriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _receiverObject == pOtherDelegate->_receiverObject && _receiverMethod == pOtherDelegate->_receiverMethod; - } - - AbstractDelegate<TArgs>* clone() const - { - return new PriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _receiverObject = 0; - } - -protected: - TObj* _receiverObject; - NotifyMethod _receiverMethod; - Mutex _mutex; - -private: - PriorityDelegate(); -}; - - -template <class TObj> -class PriorityDelegate<TObj, void, true>: public AbstractPriorityDelegate<void> -{ -public: - typedef void (TObj::*NotifyMethod)(const void*); - - PriorityDelegate(TObj* obj, NotifyMethod method, int prio): - AbstractPriorityDelegate<void>(prio), - _receiverObject(obj), - _receiverMethod(method) - { - } - - PriorityDelegate(const PriorityDelegate& delegate): - AbstractPriorityDelegate<void>(delegate), - _receiverObject(delegate._receiverObject), - _receiverMethod(delegate._receiverMethod) - { - } - - PriorityDelegate& operator = (const PriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_pTarget = delegate._pTarget; - this->_receiverObject = delegate._receiverObject; - this->_receiverMethod = delegate._receiverMethod; - this->_priority = delegate._priority; - } - return *this; - } - - ~PriorityDelegate() - { - } - - bool notify(const void* sender) - { - Mutex::ScopedLock lock(_mutex); - if (_receiverObject) - { - (_receiverObject->*_receiverMethod)(sender); - return true; - } - else return false; - } - - bool equals(const AbstractDelegate<void>& other) const - { - const PriorityDelegate* pOtherDelegate = dynamic_cast<const PriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _receiverObject == pOtherDelegate->_receiverObject && _receiverMethod == pOtherDelegate->_receiverMethod; - } - - AbstractDelegate<void>* clone() const - { - return new PriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _receiverObject = 0; - } - -protected: - TObj* _receiverObject; - NotifyMethod _receiverMethod; - Mutex _mutex; - -private: - PriorityDelegate(); -}; - - -template <class TObj> -class PriorityDelegate<TObj, void, false>: public AbstractPriorityDelegate<void> -{ -public: - typedef void (TObj::*NotifyMethod)(); - - PriorityDelegate(TObj* obj, NotifyMethod method, int prio): - AbstractPriorityDelegate<void>(prio), - _receiverObject(obj), - _receiverMethod(method) - { - } - - PriorityDelegate(const PriorityDelegate& delegate): - AbstractPriorityDelegate<void>(delegate), - _receiverObject(delegate._receiverObject), - _receiverMethod(delegate._receiverMethod) - { - } - - PriorityDelegate& operator = (const PriorityDelegate& delegate) - { - if (&delegate != this) - { - this->_pTarget = delegate._pTarget; - this->_receiverObject = delegate._receiverObject; - this->_receiverMethod = delegate._receiverMethod; - this->_priority = delegate._priority; - } - return *this; - } - - ~PriorityDelegate() - { - } - - bool notify(const void* sender) - { - Mutex::ScopedLock lock(_mutex); - if (_receiverObject) - { - (_receiverObject->*_receiverMethod)(); - return true; - } - return false; - } - - bool equals(const AbstractDelegate<void>& other) const - { - const PriorityDelegate* pOtherDelegate = dynamic_cast<const PriorityDelegate*>(other.unwrap()); - return pOtherDelegate && this->priority() == pOtherDelegate->priority() && _receiverObject == pOtherDelegate->_receiverObject && _receiverMethod == pOtherDelegate->_receiverMethod; - } - - AbstractDelegate<void>* clone() const - { - return new PriorityDelegate(*this); - } - - void disable() - { - Mutex::ScopedLock lock(_mutex); - _receiverObject = 0; - } - -protected: - TObj* _receiverObject; - NotifyMethod _receiverMethod; - Mutex _mutex; - -private: - PriorityDelegate(); -}; - - -template <class TObj, class TArgs> -static PriorityDelegate<TObj, TArgs, true> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*, TArgs&), int prio) -{ - return PriorityDelegate<TObj, TArgs, true>(pObj, NotifyMethod, prio); -} - - -template <class TObj, class TArgs> -static PriorityDelegate<TObj, TArgs, false> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(TArgs&), int prio) -{ - return PriorityDelegate<TObj, TArgs, false>(pObj, NotifyMethod, prio); -} - - -template <class TObj, class TArgs> -static PriorityExpire<TArgs> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*, TArgs&), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<TArgs>(PriorityDelegate<TObj, TArgs, true>(pObj, NotifyMethod, prio), expireMilliSec); -} - - -template <class TObj, class TArgs> -static PriorityExpire<TArgs> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(TArgs&), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<TArgs>(PriorityDelegate<TObj, TArgs, false>(pObj, NotifyMethod, prio), expireMilliSec); -} - - -template <class TArgs> -static PriorityExpire<TArgs> priorityDelegate(void (*NotifyMethod)(const void*, TArgs&), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<TArgs>(FunctionPriorityDelegate<TArgs, true, true>(NotifyMethod, prio), expireMilliSec); -} - - -template <class TArgs> -static PriorityExpire<TArgs> priorityDelegate(void (*NotifyMethod)(void*, TArgs&), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<TArgs>(FunctionPriorityDelegate<TArgs, true, false>(NotifyMethod, prio), expireMilliSec); -} - - -template <class TArgs> -static PriorityExpire<TArgs> priorityDelegate(void (*NotifyMethod)(TArgs&), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<TArgs>(FunctionPriorityDelegate<TArgs, false>(NotifyMethod, prio), expireMilliSec); -} - - -template <class TArgs> -static FunctionPriorityDelegate<TArgs, true, true> priorityDelegate(void (*NotifyMethod)(const void*, TArgs&), int prio) -{ - return FunctionPriorityDelegate<TArgs, true, true>(NotifyMethod, prio); -} - - -template <class TArgs> -static FunctionPriorityDelegate<TArgs, true, false> priorityDelegate(void (*NotifyMethod)(void*, TArgs&), int prio) -{ - return FunctionPriorityDelegate<TArgs, true, false>(NotifyMethod, prio); -} - - -template <class TArgs> -static FunctionPriorityDelegate<TArgs, false> priorityDelegate(void (*NotifyMethod)(TArgs&), int prio) -{ - return FunctionPriorityDelegate<TArgs, false>(NotifyMethod, prio); -} - - -template <class TObj> -static PriorityDelegate<TObj, void, true> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*), int prio) -{ - return PriorityDelegate<TObj, void, true>(pObj, NotifyMethod, prio); -} - - -template <class TObj> -static PriorityDelegate<TObj, void, false> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(), int prio) -{ - return PriorityDelegate<TObj, void, false>(pObj, NotifyMethod, prio); -} - - -template <class TObj> -static PriorityExpire<void> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(const void*), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<void>(PriorityDelegate<TObj, void, true>(pObj, NotifyMethod, prio), expireMilliSec); -} - - -template <class TObj> -static PriorityExpire<void> priorityDelegate(TObj* pObj, void (TObj::*NotifyMethod)(), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<void>(PriorityDelegate<TObj, void, false>(pObj, NotifyMethod, prio), expireMilliSec); -} - - -inline PriorityExpire<void> priorityDelegate(void (*NotifyMethod)(const void*), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<void>(FunctionPriorityDelegate<void, true, true>(NotifyMethod, prio), expireMilliSec); -} - - -inline PriorityExpire<void> priorityDelegate(void (*NotifyMethod)(void*), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<void>(FunctionPriorityDelegate<void, true, false>(NotifyMethod, prio), expireMilliSec); -} - - -inline PriorityExpire<void> priorityDelegate(void (*NotifyMethod)(), int prio, Timestamp::TimeDiff expireMilliSec) -{ - return PriorityExpire<void>(FunctionPriorityDelegate<void, false>(NotifyMethod, prio), expireMilliSec); -} - - -inline FunctionPriorityDelegate<void, true, true> priorityDelegate(void (*NotifyMethod)(const void*), int prio) -{ - return FunctionPriorityDelegate<void, true, true>(NotifyMethod, prio); -} - - -inline FunctionPriorityDelegate<void, true, false> priorityDelegate(void (*NotifyMethod)(void*), int prio) -{ - return FunctionPriorityDelegate<void, true, false>(NotifyMethod, prio); -} - - -inline FunctionPriorityDelegate<void, false> priorityDelegate(void (*NotifyMethod)(), int prio) -{ - return FunctionPriorityDelegate<void, false>(NotifyMethod, prio); -} - - -} // namespace Poco - - -#endif // Foundation_PriorityDelegate_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/PriorityEvent.h b/contrib/libs/poco/Foundation/include/Poco/PriorityEvent.h deleted file mode 100644 index 48b9f604f6..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/PriorityEvent.h +++ /dev/null @@ -1,61 +0,0 @@ -// -// PriorityEvent.h -// -// Library: Foundation -// Package: Events -// Module: PriorityEvent -// -// Implementation of the PriorityEvent template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_PriorityEvent_INCLUDED -#define Foundation_PriorityEvent_INCLUDED - - -#include "Poco/AbstractEvent.h" -#include "Poco/PriorityStrategy.h" -#include "Poco/AbstractPriorityDelegate.h" - - -namespace Poco { - - -template <class TArgs, class TMutex = FastMutex> -class PriorityEvent: public AbstractEvent < - TArgs, - PriorityStrategy<TArgs, AbstractPriorityDelegate<TArgs> >, - AbstractPriorityDelegate<TArgs>, - TMutex -> - /// A PriorityEvent uses internally a PriorityStrategy which - /// invokes delegates in order of priority (lower priorities first). - /// PriorityEvent's can only be used together with PriorityDelegate's. - /// PriorityDelegate's are sorted according to the priority value, when - /// two delegates have the same priority, they are invoked in - /// an arbitrary manner. -{ -public: - PriorityEvent() - { - } - - ~PriorityEvent() - { - } - -private: - PriorityEvent(const PriorityEvent&); - PriorityEvent& operator = (const PriorityEvent&); -}; - - -} // namespace Poco - - -#endif // Foundation_PriorityEvent_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/PriorityExpire.h b/contrib/libs/poco/Foundation/include/Poco/PriorityExpire.h deleted file mode 100644 index 9491445f07..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/PriorityExpire.h +++ /dev/null @@ -1,195 +0,0 @@ -// -// PriorityExpire.h -// -// Library: Foundation -// Package: Events -// Module: PriorityExpire -// -// Implementation of the PriorityExpire template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_PriorityExpire_INCLUDED -#define Foundation_PriorityExpire_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Timestamp.h" -#include "Poco/AbstractPriorityDelegate.h" - - -namespace Poco { - - -template <class TArgs> -class PriorityExpire: public AbstractPriorityDelegate<TArgs> - /// Decorator for AbstractPriorityDelegate adding automatic - /// expiring of registrations to AbstractPriorityDelegate. -{ -public: - PriorityExpire(const AbstractPriorityDelegate<TArgs>& p, Timestamp::TimeDiff expireMilliSec): - AbstractPriorityDelegate<TArgs>(p), - _pDelegate(static_cast<AbstractPriorityDelegate<TArgs>*>(p.clone())), - _expire(expireMilliSec*1000) - { - } - - PriorityExpire(const PriorityExpire& expire): - AbstractPriorityDelegate<TArgs>(expire), - _pDelegate(static_cast<AbstractPriorityDelegate<TArgs>*>(expire._pDelegate->clone())), - _expire(expire._expire), - _creationTime(expire._creationTime) - { - } - - ~PriorityExpire() - { - delete _pDelegate; - } - - PriorityExpire& operator = (const PriorityExpire& expire) - { - if (&expire != this) - { - delete this->_pDelegate; - this->_pTarget = expire._pTarget; - this->_pDelegate = expire._pDelegate->clone(); - this->_expire = expire._expire; - this->_creationTime = expire._creationTime; - } - return *this; - } - - bool notify(const void* sender, TArgs& arguments) - { - if (!expired()) - return this->_pDelegate->notify(sender, arguments); - else - return false; - } - - bool equals(const AbstractDelegate<TArgs>& other) const - { - return other.equals(*_pDelegate); - } - - AbstractPriorityDelegate<TArgs>* clone() const - { - return new PriorityExpire(*this); - } - - void disable() - { - _pDelegate->disable(); - } - - const AbstractPriorityDelegate<TArgs>* unwrap() const - { - return this->_pDelegate; - } - -protected: - bool expired() const - { - return _creationTime.isElapsed(_expire); - } - - AbstractPriorityDelegate<TArgs>* _pDelegate; - Timestamp::TimeDiff _expire; - Timestamp _creationTime; - -private: - PriorityExpire(); -}; - - -template <> -class PriorityExpire<void>: public AbstractPriorityDelegate<void> - /// Decorator for AbstractPriorityDelegate adding automatic - /// expiring of registrations to AbstractPriorityDelegate. -{ -public: - PriorityExpire(const AbstractPriorityDelegate<void>& p, Timestamp::TimeDiff expireMilliSec): - AbstractPriorityDelegate<void>(p), - _pDelegate(static_cast<AbstractPriorityDelegate<void>*>(p.clone())), - _expire(expireMilliSec*1000) - { - } - - PriorityExpire(const PriorityExpire& expire): - AbstractPriorityDelegate<void>(expire), - _pDelegate(static_cast<AbstractPriorityDelegate<void>*>(expire._pDelegate->clone())), - _expire(expire._expire), - _creationTime(expire._creationTime) - { - } - - ~PriorityExpire() - { - delete _pDelegate; - } - - PriorityExpire& operator = (const PriorityExpire& expire) - { - if (&expire != this) - { - delete this->_pDelegate; - this->_pDelegate = static_cast<AbstractPriorityDelegate<void>*>(expire._pDelegate->clone()); - this->_expire = expire._expire; - this->_creationTime = expire._creationTime; - } - return *this; - } - - bool notify(const void* sender) - { - if (!expired()) - return this->_pDelegate->notify(sender); - else - return false; - } - - bool equals(const AbstractDelegate<void>& other) const - { - return other.equals(*_pDelegate); - } - - AbstractPriorityDelegate<void>* clone() const - { - return new PriorityExpire(*this); - } - - void disable() - { - _pDelegate->disable(); - } - - const AbstractPriorityDelegate<void>* unwrap() const - { - return this->_pDelegate; - } - -protected: - bool expired() const - { - return _creationTime.isElapsed(_expire); - } - - AbstractPriorityDelegate<void>* _pDelegate; - Timestamp::TimeDiff _expire; - Timestamp _creationTime; - -private: - PriorityExpire(); -}; - - -} // namespace Poco - - -#endif // Foundation_PriorityExpire_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/PriorityStrategy.h b/contrib/libs/poco/Foundation/include/Poco/PriorityStrategy.h deleted file mode 100644 index 65d67a4491..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/PriorityStrategy.h +++ /dev/null @@ -1,230 +0,0 @@ -// -// PriorityStrategy.h -// -// Library: Foundation -// Package: Events -// Module: PrioritytStrategy -// -// Implementation of the DefaultStrategy template. -// -// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_PriorityStrategy_INCLUDED -#define Foundation_PriorityStrategy_INCLUDED - - -#include "Poco/NotificationStrategy.h" -#include "Poco/SharedPtr.h" -#include <vector> - - -namespace Poco { - - -template <class TArgs, class TDelegate> -class PriorityStrategy: public NotificationStrategy<TArgs, TDelegate> - /// NotificationStrategy for PriorityEvent. - /// - /// Delegates are kept in a std::vector<>, ordered - /// by their priority. -{ -public: - typedef TDelegate* DelegateHandle; - typedef SharedPtr<TDelegate> DelegatePtr; - typedef std::vector<DelegatePtr> Delegates; - typedef typename Delegates::iterator Iterator; - -public: - PriorityStrategy() - { - } - - PriorityStrategy(const PriorityStrategy& s): - _delegates(s._delegates) - { - } - - ~PriorityStrategy() - { - } - - void notify(const void* sender, TArgs& arguments) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - (*it)->notify(sender, arguments); - } - } - - DelegateHandle add(const TDelegate& delegate) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - if ((*it)->priority() > delegate.priority()) - { - DelegatePtr pDelegate(static_cast<TDelegate*>(delegate.clone())); - _delegates.insert(it, pDelegate); - return pDelegate.get(); - } - } - DelegatePtr pDelegate(static_cast<TDelegate*>(delegate.clone())); - _delegates.push_back(pDelegate); - return pDelegate.get(); - } - - void remove(const TDelegate& delegate) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - if (delegate.equals(**it)) - { - (*it)->disable(); - _delegates.erase(it); - return; - } - } - } - - void remove(DelegateHandle delegateHandle) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - if (*it == delegateHandle) - { - (*it)->disable(); - _delegates.erase(it); - return; - } - } - } - - PriorityStrategy& operator = (const PriorityStrategy& s) - { - if (this != &s) - { - _delegates = s._delegates; - } - return *this; - } - - void clear() - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - (*it)->disable(); - } - _delegates.clear(); - } - - bool empty() const - { - return _delegates.empty(); - } - -protected: - Delegates _delegates; -}; - - -template <class TDelegate> -class PriorityStrategy<void, TDelegate> - /// NotificationStrategy for PriorityEvent. - /// - /// Delegates are kept in a std::vector<>, ordered - /// by their priority. -{ -public: - typedef TDelegate* DelegateHandle; - typedef SharedPtr<TDelegate> DelegatePtr; - typedef std::vector<DelegatePtr> Delegates; - typedef typename Delegates::iterator Iterator; - -public: - - void notify(const void* sender) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - (*it)->notify(sender); - } - } - - DelegateHandle add(const TDelegate& delegate) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - if ((*it)->priority() > delegate.priority()) - { - DelegatePtr pDelegate(static_cast<TDelegate*>(delegate.clone())); - _delegates.insert(it, pDelegate); - return pDelegate.get(); - } - } - DelegatePtr pDelegate(static_cast<TDelegate*>(delegate.clone())); - _delegates.push_back(pDelegate); - return pDelegate.get(); - } - - void remove(const TDelegate& delegate) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - if (delegate.equals(**it)) - { - (*it)->disable(); - _delegates.erase(it); - return; - } - } - } - - void remove(DelegateHandle delegateHandle) - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - if (*it == delegateHandle) - { - (*it)->disable(); - _delegates.erase(it); - return; - } - } - } - - PriorityStrategy& operator = (const PriorityStrategy& s) - { - if (this != &s) - { - _delegates = s._delegates; - } - return *this; - } - - void clear() - { - for (Iterator it = _delegates.begin(); it != _delegates.end(); ++it) - { - (*it)->disable(); - } - _delegates.clear(); - } - - bool empty() const - { - return _delegates.empty(); - } - -protected: - Delegates _delegates; -}; - - -} // namespace Poco - - -#endif // Foundation_PriorityStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/RecursiveDirectoryIterator.h b/contrib/libs/poco/Foundation/include/Poco/RecursiveDirectoryIterator.h deleted file mode 100644 index c0ce2285ee..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/RecursiveDirectoryIterator.h +++ /dev/null @@ -1,254 +0,0 @@ -// -// RecursiveDirectoryIterator.h -// -// Library: Foundation -// Package: Filesystem -// Module: RecursiveDirectoryIterator -// -// Definition of the RecursiveDirectoryIterator class. -// -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_RecursiveDirectoryIterator_INCLUDED -#define Foundation_RecursiveDirectoryIterator_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/File.h" -#include "Poco/Path.h" -#include "Poco/RecursiveDirectoryIteratorImpl.h" -#include "Poco/DirectoryIteratorStrategy.h" - - -namespace Poco { - - -class DirectoryIterator; - - -template<class TTravStr> -class RecursiveDirectoryIteratorImpl; - - -template<class TTravStr = ChildrenFirstTraverse> -class RecursiveDirectoryIterator - /// The RecursiveDirectoryIterator class is used to enumerate - /// all files in a directory and its subdirectories. - /// - /// RecursiveDirectoryIterator has some limitations: - /// * only forward iteration (++) is supported - /// * an iterator copied from another one will always - /// point to the same file as the original iterator, - /// even is the original iterator has been advanced - /// (all copies of an iterator share their state with - /// the original iterator) - /// - /// The class can follow different traversal strategies: - /// * depth-first strategy; - /// * siblings-first strategy. - /// The stategies are set by template parameter. - /// There are two corresponding typedefs: - /// * SimpleRecursiveDirectoryIterator; - /// * SiblingsFirstRecursiveDirectoryIterator. - /// - /// The depth of traversal can be limited by constructor - /// parameter maxDepth (which sets the infinite depth by default). -{ -public: - typedef RecursiveDirectoryIterator<TTravStr> MyType; - - enum - { - D_INFINITE = 0 /// Constant for infinite traverse depth. - }; - - RecursiveDirectoryIterator() - /// Creates the end iterator. - : _pImpl(0) - { - } - - RecursiveDirectoryIterator(const std::string& path, UInt16 maxDepth = D_INFINITE) - /// Creates a recursive directory iterator for the given path. - : _pImpl(new ImplType(path, maxDepth)), _path(Path(_pImpl->get())), _file(_path) - { - } - - RecursiveDirectoryIterator(const MyType& iterator): - /// Creates a copy of another recursive directory iterator. - _pImpl(iterator._pImpl), _path(iterator._path), _file(iterator._file) - { - } - - RecursiveDirectoryIterator(const DirectoryIterator& iterator, UInt16 maxDepth = D_INFINITE): - /// Creates a recursive directory iterator for the path of - /// non-recursive directory iterator. - _pImpl(new ImplType(iterator->path(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) - { - } - - RecursiveDirectoryIterator(const File& file, UInt16 maxDepth = D_INFINITE): - /// Creates a recursive directory iterator for the given path. - _pImpl(new ImplType(file.path(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) - { - } - - RecursiveDirectoryIterator(const Path& path, UInt16 maxDepth = D_INFINITE): - /// Creates a recursive directory iterator for the given path. - _pImpl(new ImplType(path.toString(), maxDepth)), _path(Path(_pImpl->get())), _file(_path) - { - } - - ~RecursiveDirectoryIterator() - /// Destroys the DirectoryIterator. - { - if (_pImpl) - _pImpl->release(); - } - - const std::string& name() const - /// Returns the current filename. - { - return _path.getFileName(); - } - - const Poco::Path& path() const - /// Returns the current path. - { - return _path; - } - - UInt16 depth() const - /// Depth of recursion (counting from 1). - { - return _pImpl->depth(); - } - - UInt16 maxDepth() const - /// Max depth of recursion (counting from 1). - { - return _pImpl->maxDepth(); - } - - - MyType& operator = (const MyType& it) - { - if (_pImpl) - _pImpl->release(); - _pImpl = it._pImpl; - if (_pImpl) - { - _pImpl->duplicate(); - _path = it._path; - _file = _path; - } - return *this; - } - - MyType& operator = (const File& file) - { - if (_pImpl) - _pImpl->release(); - _pImpl = new ImplType(file.path()); - _path = Path(_pImpl->get()); - _file = _path; - return *this; - } - - - MyType& operator = (const Path& path) - { - if (_pImpl) - _pImpl->release(); - _pImpl = new ImplType(path.toString()); - _path = Path(_pImpl->get()); - _file = _path; - return *this; - } - - MyType& operator = (const std::string& path) - { - if (_pImpl) - _pImpl->release(); - _pImpl = new ImplType(path); - _path = Path(_pImpl->get()); - _file = _path; - return *this; - } - - MyType& operator ++ () - { - if (_pImpl) - { - _path = Path(_pImpl->next()); - _file = _path; - } - return *this; - } - - const File& operator * () const - { - return _file; - } - - File& operator *() - { - return _file; - } - - const File* operator -> () const - { - return &_file; - } - - File* operator -> () - { - return &_file; - } - - template<class T1, class T2> - friend inline bool operator ==(const RecursiveDirectoryIterator<T1>& a, const RecursiveDirectoryIterator<T2>& b); - template<class T1, class T2> - friend inline bool operator !=(const RecursiveDirectoryIterator<T1>& a, const RecursiveDirectoryIterator<T2>& b); - -private: - typedef RecursiveDirectoryIteratorImpl<TTravStr> ImplType; - - ImplType* _pImpl; - Path _path; - File _file; -}; - - -// -// friend comparsion operators -// -template<class T1, class T2> -inline bool operator ==(const RecursiveDirectoryIterator<T1>& a, const RecursiveDirectoryIterator<T2>& b) -{ - return a.path().toString() == b.path().toString();; -} - -template<class T1, class T2> -inline bool operator !=(const RecursiveDirectoryIterator<T1>& a, const RecursiveDirectoryIterator<T2>& b) -{ - return a.path().toString() != b.path().toString();; -} - - -// -// typedefs -// -typedef RecursiveDirectoryIterator<ChildrenFirstTraverse> SimpleRecursiveDirectoryIterator; -typedef RecursiveDirectoryIterator<SiblingsFirstTraverse> SiblingsFirstRecursiveDirectoryIterator; - - -} // namespace Poco - - -#endif // Foundation_RecursiveDirectoryIterator_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/RecursiveDirectoryIteratorImpl.h b/contrib/libs/poco/Foundation/include/Poco/RecursiveDirectoryIteratorImpl.h deleted file mode 100644 index fb2d467049..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/RecursiveDirectoryIteratorImpl.h +++ /dev/null @@ -1,111 +0,0 @@ -// -// RecursiveDirectoryIteratorImpl.h -// -// Library: Foundation -// Package: Filesystem -// Module: RecursiveDirectoryIterator -// -// Definition of the RecursiveDirectoryIteratorImpl class. -// -// Copyright (c) 2012, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_RecursiveDirectoryIteratorImpl_INCLUDED -#define Foundation_RecursiveDirectoryIteratorImpl_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/DirectoryIteratorStrategy.h" -#include <stack> -#include <functional> - - -namespace Poco { - - -class ChildrenFirstTraverse; -class SiblingsFirstTraverse; - - -template<class TTraverseStrategy = ChildrenFirstTraverse> -class RecursiveDirectoryIteratorImpl -{ -public: - enum - { - D_INFINITE = 0 /// Special value for infinite traverse depth. - }; - - RecursiveDirectoryIteratorImpl(const std::string& path, UInt16 maxDepth = D_INFINITE) - : _maxDepth(maxDepth), _traverseStrategy(std::ptr_fun(depthFun), _maxDepth), _isFinished(false), _rc(1) - { - _itStack.push(DirectoryIterator(path)); - _current = _itStack.top()->path(); - } - - ~RecursiveDirectoryIteratorImpl() - { - } - - inline void duplicate() - { - ++_rc; - } - - inline void release() - { - if (--_rc == 0) - delete this; - } - - inline UInt16 depth() const - { - return depthFun(_itStack); - } - - inline UInt16 maxDepth() const - { - return _maxDepth; - } - - inline const std::string& get() const - { - return _current; - } - const std::string& next() - { - if (_isFinished) - return _current; - - _current = _traverseStrategy.next(&_itStack, &_isFinished); - - return _current; - } - -private: - typedef std::stack<DirectoryIterator> Stack; - - static UInt16 depthFun(const Stack& stack) - /// Function which implements the logic of determining - /// recursion depth. - { - return static_cast<Poco::UInt16>(stack.size()); - } - - UInt16 _maxDepth; - TTraverseStrategy _traverseStrategy; - bool _isFinished; - Stack _itStack; - std::string _current; - int _rc; -}; - - -} // namespace Poco - - -#endif // Foundation_RecursiveDirectoryIteratorImpl_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/RunnableAdapter.h b/contrib/libs/poco/Foundation/include/Poco/RunnableAdapter.h deleted file mode 100644 index 571871be98..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/RunnableAdapter.h +++ /dev/null @@ -1,78 +0,0 @@ -// -// RunnableAdapter.h -// -// Library: Foundation -// Package: Threading -// Module: Thread -// -// Definition of the RunnableAdapter template class. -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_RunnableAdapter_INCLUDED -#define Foundation_RunnableAdapter_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Runnable.h" - - -namespace Poco { - - -template <class C> -class RunnableAdapter: public Runnable - /// This adapter simplifies using ordinary methods as - /// targets for threads. - /// Usage: - /// RunnableAdapter<MyClass> ra(myObject, &MyObject::doSomething)); - /// Thread thr; - /// thr.Start(ra); - /// - /// For using a freestanding or static member function as a thread - /// target, please see the ThreadTarget class. -{ -public: - typedef void (C::*Callback)(); - - RunnableAdapter(C& object, Callback method): _pObject(&object), _method(method) - { - } - - RunnableAdapter(const RunnableAdapter& ra): _pObject(ra._pObject), _method(ra._method) - { - } - - ~RunnableAdapter() - { - } - - RunnableAdapter& operator = (const RunnableAdapter& ra) - { - _pObject = ra._pObject; - _method = ra._method; - return *this; - } - - void run() - { - (_pObject->*_method)(); - } - -private: - RunnableAdapter(); - - C* _pObject; - Callback _method; -}; - - -} // namespace Poco - - -#endif // Foundation_RunnableAdapter_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/SimpleHashTable.h b/contrib/libs/poco/Foundation/include/Poco/SimpleHashTable.h deleted file mode 100644 index c149cd6b7e..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/SimpleHashTable.h +++ /dev/null @@ -1,398 +0,0 @@ -// -// SimpleHashTable.h -// -// Library: Foundation -// Package: Hashing -// Module: SimpleHashTable -// -// Definition of the SimpleHashTable class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_SimpleHashTable_INCLUDED -#define Foundation_SimpleHashTable_INCLUDED - - -#include "Poco/Foundation.h" -#include "Poco/Exception.h" -#include "Poco/HashFunction.h" -#include "Poco/HashStatistic.h" -#include <vector> -#include <map> -#include <cstddef> -#include <algorithm> - - -namespace Poco { - - -//@ deprecated -template <class Key, class Value, class KeyHashFunction = HashFunction<Key> > -class SimpleHashTable - /// A SimpleHashTable stores a key value pair that can be looked up via a hashed key. - /// - /// In comparision to a HashTable, this class handles collisions by sequentially searching the next - /// free location. This also means that the maximum size of this table is limited, i.e. if the hash table - /// is full, it will throw an exception and that this class does not support remove operations. - /// On the plus side it is faster than the HashTable. - /// - /// This class is NOT thread safe. -{ -public: - class HashEntry - { - public: - Key key; - Value value; - HashEntry(const Key k, const Value v): key(k), value(v) - { - } - }; - - typedef std::vector<HashEntry*> HashTableVector; - - SimpleHashTable(UInt32 capacity = 251): _entries(capacity, 0), _size(0), _capacity(capacity) - /// Creates the SimpleHashTable. - { - } - - SimpleHashTable(const SimpleHashTable& ht): - _size(ht._size), - _capacity(ht._capacity) - { - _entries.reserve(ht._capacity); - for (typename HashTableVector::iterator it = ht._entries.begin(); it != ht._entries.end(); ++it) - { - if (*it) - _entries.push_back(new HashEntry(*it)); - else - _entries.push_back(0); - } - } - - ~SimpleHashTable() - /// Destroys the SimpleHashTable. - { - clear(); - } - - SimpleHashTable& operator = (const SimpleHashTable& ht) - { - if (this != &ht) - { - SimpleHashTable tmp(ht); - swap(tmp); - } - return *this; - } - - void swap(SimpleHashTable& ht) - { - using std::swap; - swap(_entries, ht._entries); - swap(_size, ht._size); - swap(_capacity, ht._capacity); - } - - void clear() - { - for (typename HashTableVector::iterator it = _entries.begin(); it != _entries.end(); ++it) - { - delete *it; - *it = 0; - } - _size = 0; - } - - UInt32 insert(const Key& key, const Value& value) - /// Returns the hash value of the inserted item. - /// Throws an exception if the entry was already inserted - { - UInt32 hsh = hash(key); - insertRaw(key, hsh, value); - return hsh; - } - - Value& insertRaw(const Key& key, UInt32 hsh, const Value& value) - /// Returns the hash value of the inserted item. - /// Throws an exception if the entry was already inserted - { - UInt32 pos = hsh; - if (!_entries[pos]) - _entries[pos] = new HashEntry(key, value); - else - { - UInt32 origHash = hsh; - while (_entries[hsh % _capacity]) - { - if (_entries[hsh % _capacity]->key == key) - throw ExistsException(); - if (hsh - origHash > _capacity) - throw PoolOverflowException("SimpleHashTable full"); - hsh++; - } - pos = hsh % _capacity; - _entries[pos] = new HashEntry(key, value); - } - _size++; - return _entries[pos]->value; - } - - UInt32 update(const Key& key, const Value& value) - /// Returns the hash value of the inserted item. - /// Replaces an existing entry if it finds one - { - UInt32 hsh = hash(key); - updateRaw(key, hsh, value); - return hsh; - } - - void updateRaw(const Key& key, UInt32 hsh, const Value& value) - /// Returns the hash value of the inserted item. - /// Replaces an existing entry if it finds one - { - if (!_entries[hsh]) - _entries[hsh] = new HashEntry(key, value); - else - { - UInt32 origHash = hsh; - while (_entries[hsh % _capacity]) - { - if (_entries[hsh % _capacity]->key == key) - { - _entries[hsh % _capacity]->value = value; - return; - } - if (hsh - origHash > _capacity) - throw PoolOverflowException("SimpleHashTable full"); - hsh++; - } - _entries[hsh % _capacity] = new HashEntry(key, value); - } - _size++; - } - - UInt32 hash(const Key& key) const - { - return _hash(key, _capacity); - } - - const Value& get(const Key& key) const - /// Throws an exception if the value does not exist - { - UInt32 hsh = hash(key); - return getRaw(key, hsh); - } - - const Value& getRaw(const Key& key, UInt32 hsh) const - /// Throws an exception if the value does not exist - { - UInt32 origHash = hsh; - while (true) - { - if (_entries[hsh % _capacity]) - { - if (_entries[hsh % _capacity]->key == key) - { - return _entries[hsh % _capacity]->value; - } - } - else - throw InvalidArgumentException("value not found"); - if (hsh - origHash > _capacity) - throw InvalidArgumentException("value not found"); - hsh++; - } - } - - Value& get(const Key& key) - /// Throws an exception if the value does not exist - { - UInt32 hsh = hash(key); - return const_cast<Value&>(getRaw(key, hsh)); - } - - const Value& operator [] (const Key& key) const - { - return get(key); - } - - Value& operator [] (const Key& key) - { - UInt32 hsh = hash(key); - UInt32 origHash = hsh; - while (true) - { - if (_entries[hsh % _capacity]) - { - if (_entries[hsh % _capacity]->key == key) - { - return _entries[hsh % _capacity]->value; - } - } - else return insertRaw(key, hsh, Value()); - if (hsh - origHash > _capacity) - return insertRaw(key, hsh, Value()); - hsh++; - } - } - - const Key& getKeyRaw(const Key& key, UInt32 hsh) - /// Throws an exception if the key does not exist. returns a reference to the internally - /// stored key. Useful when someone does an insert and wants for performance reason only to store - /// a pointer to the key in another collection - { - UInt32 origHash = hsh; - while (true) - { - if (_entries[hsh % _capacity]) - { - if (_entries[hsh % _capacity]->key == key) - { - return _entries[hsh % _capacity]->key; - } - } - else - throw InvalidArgumentException("key not found"); - - if (hsh - origHash > _capacity) - throw InvalidArgumentException("key not found"); - hsh++; - } - } - - bool get(const Key& key, Value& v) const - /// Sets v to the found value, returns false if no value was found - { - UInt32 hsh = hash(key); - return getRaw(key, hsh, v); - } - - bool getRaw(const Key& key, UInt32 hsh, Value& v) const - /// Sets v to the found value, returns false if no value was found - { - UInt32 origHash = hsh; - while (true) - { - if (_entries[hsh % _capacity]) - { - if (_entries[hsh % _capacity]->key == key) - { - v = _entries[hsh % _capacity]->value; - return true; - } - } - else - return false; - if (hsh - origHash > _capacity) - return false; - hsh++; - } - } - - bool exists(const Key& key) const - { - UInt32 hsh = hash(key); - return existsRaw(key, hsh); - } - - bool existsRaw(const Key& key, UInt32 hsh) const - { - UInt32 origHash = hsh; - while (true) - { - if (_entries[hsh % _capacity]) - { - if (_entries[hsh % _capacity]->key == key) - { - return true; - } - } - else - return false; - if (hsh - origHash > _capacity) - return false; - hsh++; - } - } - - std::size_t size() const - /// Returns the number of elements already inserted into the SimpleHashTable - { - return _size; - } - - UInt32 capacity() const - { - return _capacity; - } - - void resize(UInt32 newSize) - /// Resizes the hashtable, rehashes all existing entries. Expensive! - { - if (_capacity != newSize) - { - SimpleHashTable tmp(newSize); - swap(tmp); - for (typename HashTableVector::const_iterator it = tmp._entries.begin(); it != tmp._entries.end(); ++it) - { - if (*it) - { - insertRaw((*it)->key, hash((*it)->key), (*it)->value); - } - } - } - } - - HashStatistic currentState(bool details = false) const - /// Returns the current internal state - { - UInt32 numberOfEntries = (UInt32)_size; - UInt32 numZeroEntries = 0; - UInt32 maxEntriesPerHash = 0; - std::vector<UInt32> detailedEntriesPerHash; - #ifdef _DEBUG - UInt32 totalSize = 0; - #endif - for (int i=0; i < _capacity; ++i) - { - if (_entries[i]) - { - maxEntriesPerHash = 1; - UInt32 size = 1; - if (details) - detailedEntriesPerHash.push_back(size); - #ifdef _DEBUG - totalSize += size; - #endif - } - else - { - numZeroEntries++; - if (details) - detailedEntriesPerHash.push_back(0); - } - } - #ifdef _DEBUG - poco_assert_dbg(totalSize == numberOfEntries); - #endif - return HashStatistic(_capacity, numberOfEntries, numZeroEntries, maxEntriesPerHash, detailedEntriesPerHash); - } - -private: - HashTableVector _entries; - std::size_t _size; - UInt32 _capacity; - KeyHashFunction _hash; -}; - - -} // namespace Poco - - -#endif // Foundation_HashTable_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/StrategyCollection.h b/contrib/libs/poco/Foundation/include/Poco/StrategyCollection.h deleted file mode 100644 index 6372d46620..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/StrategyCollection.h +++ /dev/null @@ -1,133 +0,0 @@ -// -// StrategyCollection.h -// -// Library: Foundation -// Package: Cache -// Module: StrategyCollection -// -// Definition of the StrategyCollection class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_StrategyCollection_INCLUDED -#define Foundation_StrategyCollection_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/AbstractStrategy.h" -#include "Poco/SharedPtr.h" -#include <vector> - - -namespace Poco { - - -template <class TKey, class TValue> -class StrategyCollection: public AbstractStrategy<TKey, TValue> - /// An StrategyCollection is a decorator masking n collections as a single one. -{ -public: - typedef std::vector<SharedPtr<AbstractStrategy<TKey, TValue> > > Strategies; - typedef typename Strategies::iterator Iterator; - typedef typename Strategies::const_iterator ConstIterator; - -public: - StrategyCollection() - { - } - - ~StrategyCollection() - { - } - - void pushBack(AbstractStrategy<TKey, TValue>* pStrat) - /// Adds an AbstractStrategy to the collection. Class takes ownership of pointer - { - _strategies.push_back(SharedPtr<AbstractStrategy<TKey, TValue> >(pStrat)); - } - - void popBack() - /// Removes the last added AbstractStrategy from the collection. - { - _strategies.pop_back(); - } - - void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key) - /// Adds the key to the strategy. - /// If for the key already an entry exists, it will be overwritten. - { - Iterator it = _strategies.begin(); - Iterator endIt = _strategies.end(); - for (; it != endIt; ++it) - { - (*it)->onAdd(pSender, key); - } - } - - void onRemove(const void* pSender, const TKey& key) - /// Removes an entry from the strategy. If the entry is not found - /// the remove is ignored. - { - Iterator it = _strategies.begin(); - Iterator endIt = _strategies.end(); - for (; it != endIt; ++it) - { - (*it)->onRemove(pSender, key); - } - } - - void onGet(const void* pSender, const TKey& key) - { - Iterator it = _strategies.begin(); - Iterator endIt = _strategies.end(); - for (; it != endIt; ++it) - { - (*it)->onGet(pSender, key); - } - } - - void onClear(const void* pSender, const EventArgs& args) - { - Iterator it = _strategies.begin(); - Iterator endIt = _strategies.end(); - for (; it != endIt; ++it) - { - (*it)->onClear(pSender, args); - } - } - - void onIsValid(const void* pSender, ValidArgs<TKey>& key) - { - Iterator it = _strategies.begin(); - Iterator endIt = _strategies.end(); - for (; it != endIt && key.isValid(); ++it) - { - (*it)->onIsValid(pSender, key); - } - } - - void onReplace(const void* pSender, std::set<TKey>& elemsToRemove) - { - Iterator it = _strategies.begin(); - Iterator endIt = _strategies.end(); - for (; it != endIt; ++it) - { - (*it)->onReplace(pSender, elemsToRemove); - } - } - -protected: - Strategies _strategies; -}; - - -} // namespace Poco - - -#endif // Foundation_StrategyCollection_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireCache.h b/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireCache.h deleted file mode 100644 index a2d58f6433..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireCache.h +++ /dev/null @@ -1,73 +0,0 @@ -// -// UniqueAccessExpireCache.h -// -// Library: Foundation -// Package: Cache -// Module: UniqueAccessExpireCache -// -// Definition of the UniqueAccessExpireCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_UniqueAccessExpireCache_INCLUDED -#define Foundation_UniqueAccessExpireCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/UniqueAccessExpireStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class UniqueAccessExpireCache: public AbstractCache<TKey, TValue, UniqueAccessExpireStrategy<TKey, TValue>, TMutex, TEventMutex> - /// An UniqueAccessExpireCache caches entries for a given time span. In contrast - /// to ExpireCache which only allows to set a per cache expiration value, it allows to define - /// expiration per CacheEntry. - /// Each TValue object must thus offer the following method: - /// - /// const Poco::Timespan& getTimeout() const; - /// - /// which returns the relative timespan for how long the entry should be valid without being accessed! - /// The absolute expire timepoint is calculated as now() + getTimeout(). - /// Accessing an object will update this absolute expire timepoint. - /// You can use the Poco::AccessExpirationDecorator to add the getExpiration - /// method to values that do not have a getExpiration function. - /// - /// Be careful when using an UniqueAccessExpireCache. A cache is often used - /// like cache.has(x) followed by cache.get x). Note that it could happen - /// that the "has" call works, then the current execution thread gets descheduled, time passes, - /// the entry gets invalid, thus leading to an empty SharedPtr being returned - /// when "get" is invoked. -{ -public: - UniqueAccessExpireCache(): - AbstractCache<TKey, TValue, UniqueAccessExpireStrategy<TKey, TValue>, TMutex, TEventMutex>(UniqueAccessExpireStrategy<TKey, TValue>()) - { - } - - ~UniqueAccessExpireCache() - { - } - -private: - UniqueAccessExpireCache(const UniqueAccessExpireCache& aCache); - UniqueAccessExpireCache& operator = (const UniqueAccessExpireCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_UniqueAccessExpireCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireLRUCache.h b/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireLRUCache.h deleted file mode 100644 index 6e7a366670..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireLRUCache.h +++ /dev/null @@ -1,71 +0,0 @@ -// -// UniqueAccessExpireLRUCache.h -// -// Library: Foundation -// Package: Cache -// Module: UniqueAccessExpireLRUCache -// -// Definition of the UniqueAccessExpireLRUCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_UniqueAccessExpireLRUCache_INCLUDED -#define Foundation_UniqueAccessExpireLRUCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/StrategyCollection.h" -#include "Poco/UniqueAccessExpireStrategy.h" -#include "Poco/LRUStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class UniqueAccessExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex> - /// A UniqueAccessExpireLRUCache combines LRU caching and time based per entry expire caching. - /// One can define for each cache entry a seperate timepoint - /// but also limit the size of the cache (per default: 1024). - /// Each TValue object must thus offer the following method: - /// - /// const Poco::Timespan& getTimeout() const; - /// - /// which returns the relative timespan for how long the entry should be valid without being accessed! - /// The absolute expire timepoint is calculated as now() + getTimeout(). - /// Accessing an object will update this absolute expire timepoint. - /// You can use the Poco::AccessExpirationDecorator to add the getExpiration - /// method to values that do not have a getExpiration function. -{ -public: - UniqueAccessExpireLRUCache(long cacheSize = 1024): - AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>(StrategyCollection<TKey, TValue>()) - { - this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); - this->_strategy.pushBack(new UniqueAccessExpireStrategy<TKey, TValue>()); - } - - ~UniqueAccessExpireLRUCache() - { - } - -private: - UniqueAccessExpireLRUCache(const UniqueAccessExpireLRUCache& aCache); - UniqueAccessExpireLRUCache& operator = (const UniqueAccessExpireLRUCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_UniqueAccessExpireLRUCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireStrategy.h b/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireStrategy.h deleted file mode 100644 index d20f2185e0..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/UniqueAccessExpireStrategy.h +++ /dev/null @@ -1,156 +0,0 @@ -// -// UniqueAccessExpireStrategy.h -// -// Library: Foundation -// Package: Cache -// Module: UniqueAccessExpireStrategy -// -// Definition of the UniqueAccessExpireStrategy class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_UniqueAccessExpireStrategy_INCLUDED -#define Foundation_UniqueAccessExpireStrategy_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/AbstractStrategy.h" -#include "Poco/Bugcheck.h" -#include "Poco/Timestamp.h" -#include "Poco/Timespan.h" -#include "Poco/EventArgs.h" -#include "Poco/UniqueExpireStrategy.h" -#include <set> -#include <map> - - -namespace Poco { - - -template < - class TKey, - class TValue -> -class UniqueAccessExpireStrategy: public AbstractStrategy<TKey, TValue> - /// An UniqueExpireStrategy implements time based expiration of cache entries. In contrast - /// to ExpireStrategy which only allows to set a per cache expiration value, it allows to define - /// expiration per CacheEntry. - /// Each TValue object must thus offer the following method: - /// - /// const Poco::Timestamp& getTimeout() const; - /// - /// which returns the timespan for how long an object will be valid without being accessed. -{ -public: - typedef std::pair<TKey, Timespan> KeyExpire; - typedef std::multimap<Timestamp, KeyExpire> TimeIndex; - typedef typename TimeIndex::iterator IndexIterator; - typedef typename TimeIndex::const_iterator ConstIndexIterator; - typedef std::map<TKey, IndexIterator> Keys; - typedef typename Keys::iterator Iterator; - -public: - UniqueAccessExpireStrategy() - /// Create an unique expire strategy. - { - } - - ~UniqueAccessExpireStrategy() - { - } - - void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args) - { - // the expire value defines how many millisecs in the future the - // value will expire, even insert negative values! - Timestamp expire; - expire += args.value().getTimeout().totalMicroseconds(); - - IndexIterator it = _keyIndex.insert(std::make_pair(expire, std::make_pair(args.key(), args.value().getTimeout()))); - std::pair<Iterator, bool> stat = _keys.insert(std::make_pair(args.key(), it)); - if (!stat.second) - { - _keyIndex.erase(stat.first->second); - stat.first->second = it; - } - } - - void onRemove(const void*, const TKey& key) - { - Iterator it = _keys.find(key); - if (it != _keys.end()) - { - _keyIndex.erase(it->second); - _keys.erase(it); - } - } - - void onGet(const void*, const TKey& key) - { - // get updates the expiration time stamp - Iterator it = _keys.find(key); - if (it != _keys.end()) - { - KeyExpire ke = it->second->second; - // gen new absolute expire value - Timestamp expire; - expire += ke.second.totalMicroseconds(); - // delete old index - _keyIndex.erase(it->second); - IndexIterator itt = _keyIndex.insert(std::make_pair(expire, ke)); - // update iterator - it->second = itt; - } - } - - void onClear(const void*, const EventArgs& args) - { - _keys.clear(); - _keyIndex.clear(); - } - - void onIsValid(const void*, ValidArgs<TKey>& args) - { - Iterator it = _keys.find(args.key()); - if (it != _keys.end()) - { - Timestamp now; - if (it->second->first <= now) - { - args.invalidate(); - } - } - else //not found: probably removed by onReplace - args.invalidate(); - } - - void onReplace(const void*, std::set<TKey>& elemsToRemove) - { - // Note: replace only informs the cache which elements - // it would like to remove! - // it does not remove them on its own! - IndexIterator it = _keyIndex.begin(); - Timestamp now; - while (it != _keyIndex.end() && it->first < now) - { - elemsToRemove.insert(it->second.first); - ++it; - } - } - -protected: - Keys _keys; /// For faster replacement of keys, the iterator points to the _keyIndex map - TimeIndex _keyIndex; /// Maps time to key value -}; - - -} // namespace Poco - - -#endif // Foundation_UniqueAccessExpireStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/UniqueExpireCache.h b/contrib/libs/poco/Foundation/include/Poco/UniqueExpireCache.h deleted file mode 100644 index 613f9e215c..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/UniqueExpireCache.h +++ /dev/null @@ -1,72 +0,0 @@ -// -// UniqueExpireCache.h -// -// Library: Foundation -// Package: Cache -// Module: UniqueExpireCache -// -// Definition of the UniqueExpireCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_UniqueExpireCache_INCLUDED -#define Foundation_UniqueExpireCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/UniqueExpireStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class UniqueExpireCache: public AbstractCache<TKey, TValue, UniqueExpireStrategy<TKey, TValue>, TMutex, TEventMutex> - /// An UniqueExpireCache caches entries for a given time amount. In contrast - /// to ExpireCache which only allows to set a per cache expiration value, it allows to define - /// expiration per CacheEntry. - /// Each TValue object must thus offer the following method: - /// - /// const Poco::Timestamp& getExpiration() const; - /// - /// which returns the absolute timepoint when the entry will be invalidated. - /// Accessing an object will NOT update this absolute expire timepoint. - /// You can use the Poco::ExpirationDecorator to add the getExpiration - /// method to values that do not have a getExpiration function. - /// - /// Be careful when using an UniqueExpireCache. A cache is often used - /// like cache.has(x) followed by cache.get x). Note that it could happen - /// that the "has" call works, then the current execution thread gets descheduled, time passes, - /// the entry gets invalid, thus leading to an empty SharedPtr being returned - /// when "get" is invoked. -{ -public: - UniqueExpireCache(): - AbstractCache<TKey, TValue, UniqueExpireStrategy<TKey, TValue>, TMutex, TEventMutex>(UniqueExpireStrategy<TKey, TValue>()) - { - } - - ~UniqueExpireCache() - { - } - -private: - UniqueExpireCache(const UniqueExpireCache& aCache); - UniqueExpireCache& operator = (const UniqueExpireCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_UniqueExpireCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/UniqueExpireLRUCache.h b/contrib/libs/poco/Foundation/include/Poco/UniqueExpireLRUCache.h deleted file mode 100644 index c59bf0f7a4..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/UniqueExpireLRUCache.h +++ /dev/null @@ -1,70 +0,0 @@ -// -// UniqueExpireLRUCache.h -// -// Library: Foundation -// Package: Cache -// Module: UniqueExpireLRUCache -// -// Definition of the UniqueExpireLRUCache class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_UniqueExpireLRUCache_INCLUDED -#define Foundation_UniqueExpireLRUCache_INCLUDED - - -#include "Poco/AbstractCache.h" -#include "Poco/StrategyCollection.h" -#include "Poco/UniqueExpireStrategy.h" -#include "Poco/LRUStrategy.h" - - -namespace Poco { - - -template < - class TKey, - class TValue, - class TMutex = FastMutex, - class TEventMutex = FastMutex -> -class UniqueExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex> - /// A UniqueExpireLRUCache combines LRU caching and time based per entry expire caching. - /// One can define for each cache entry a seperate timepoint - /// but also limit the size of the cache (per default: 1024). - /// Each TValue object must thus offer the following method: - /// - /// const Poco::Timestamp& getExpiration() const; - /// - /// which returns the absolute timepoint when the entry will be invalidated. - /// Accessing an object will NOT update this absolute expire timepoint. - /// You can use the Poco::ExpirationDecorator to add the getExpiration - /// method to values that do not have a getExpiration function. -{ -public: - UniqueExpireLRUCache(long cacheSize = 1024): - AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue>, TMutex, TEventMutex>(StrategyCollection<TKey, TValue>()) - { - this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize)); - this->_strategy.pushBack(new UniqueExpireStrategy<TKey, TValue>()); - } - - ~UniqueExpireLRUCache() - { - } - -private: - UniqueExpireLRUCache(const UniqueExpireLRUCache& aCache); - UniqueExpireLRUCache& operator = (const UniqueExpireLRUCache& aCache); -}; - - -} // namespace Poco - - -#endif // Foundation_UniqueExpireLRUCache_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/UniqueExpireStrategy.h b/contrib/libs/poco/Foundation/include/Poco/UniqueExpireStrategy.h deleted file mode 100644 index 6ae79945b1..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/UniqueExpireStrategy.h +++ /dev/null @@ -1,138 +0,0 @@ -// -// UniqueExpireStrategy.h -// -// Library: Foundation -// Package: Cache -// Module: UniqueExpireStrategy -// -// Definition of the UniqueExpireStrategy class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_UniqueExpireStrategy_INCLUDED -#define Foundation_UniqueExpireStrategy_INCLUDED - - -#include "Poco/KeyValueArgs.h" -#include "Poco/ValidArgs.h" -#include "Poco/AbstractStrategy.h" -#include "Poco/Bugcheck.h" -#include "Poco/Timestamp.h" -#include "Poco/EventArgs.h" -#include <set> -#include <map> - - -namespace Poco { - - -template < - class TKey, - class TValue -> -class UniqueExpireStrategy: public AbstractStrategy<TKey, TValue> - /// An UniqueExpireStrategy implements time based expiration of cache entries. In contrast - /// to ExpireStrategy which only allows to set a per cache expiration value, it allows to define - /// expiration per CacheEntry. - /// Each TValue object must thus offer the following method: - /// - /// const Poco::Timestamp& getExpiration() const; - /// - /// which returns the absolute timepoint when the entry will be invalidated. -{ -public: - typedef std::multimap<Timestamp, TKey> TimeIndex; - typedef typename TimeIndex::iterator IndexIterator; - typedef typename TimeIndex::const_iterator ConstIndexIterator; - typedef std::map<TKey, IndexIterator> Keys; - typedef typename Keys::iterator Iterator; - -public: - UniqueExpireStrategy() - /// Create an unique expire strategy. - { - } - - ~UniqueExpireStrategy() - { - } - - void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args) - { - // note: we have to insert even if the expire timepoint is in the past (for StrategyCollection classes to avoid inconsistency with LRU) - // no problem: will be removed with next get - const Timestamp& expire = args.value().getExpiration(); - IndexIterator it = _keyIndex.insert(std::make_pair(expire, args.key())); - std::pair<Iterator, bool> stat = _keys.insert(std::make_pair(args.key(), it)); - if (!stat.second) - { - _keyIndex.erase(stat.first->second); - stat.first->second = it; - } - } - - void onRemove(const void*, const TKey& key) - { - Iterator it = _keys.find(key); - if (it != _keys.end()) - { - _keyIndex.erase(it->second); - _keys.erase(it); - } - } - - void onGet(const void*, const TKey& key) - { - // get triggers no changes in an expire - } - - void onClear(const void*, const EventArgs& args) - { - _keys.clear(); - _keyIndex.clear(); - } - - void onIsValid(const void*, ValidArgs<TKey>& args) - { - Iterator it = _keys.find(args.key()); - if (it != _keys.end()) - { - Timestamp now; - if (it->second->first <= now) - { - args.invalidate(); - } - } - else //not found: probably removed by onReplace - args.invalidate(); - } - - void onReplace(const void*, std::set<TKey>& elemsToRemove) - { - // Note: replace only informs the cache which elements - // it would like to remove! - // it does not remove them on its own! - IndexIterator it = _keyIndex.begin(); - Timestamp now; - while (it != _keyIndex.end() && it->first < now) - { - elemsToRemove.insert(it->second); - ++it; - } - } - -protected: - Keys _keys; /// For faster replacement of keys, the iterator points to the _keyIndex map - TimeIndex _keyIndex; /// Maps time to key value -}; - - -} // namespace Poco - - -#endif // Foundation_UniqueExpireStrategy_INCLUDED diff --git a/contrib/libs/poco/Foundation/include/Poco/ValidArgs.h b/contrib/libs/poco/Foundation/include/Poco/ValidArgs.h deleted file mode 100644 index 7928a0fe8b..0000000000 --- a/contrib/libs/poco/Foundation/include/Poco/ValidArgs.h +++ /dev/null @@ -1,74 +0,0 @@ -// -// ValidArgs.h -// -// Library: Foundation -// Package: Cache -// Module: ValidArgs -// -// Definition of the ValidArgs class. -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#ifndef Foundation_ValidArgs_INCLUDED -#define Foundation_ValidArgs_INCLUDED - - -#include "Poco/Foundation.h" - - -namespace Poco { - - -template <class TKey> -class ValidArgs -{ -public: - ValidArgs(const TKey& key): - _key(key), - _isValid(true) - { - } - - ValidArgs(const ValidArgs& args): - _key(args._key), - _isValid(args._isValid) - { - } - - ~ValidArgs() - { - } - - const TKey& key() const - { - return _key; - } - - bool isValid() const - { - return _isValid; - } - - void invalidate() - { - _isValid = false; - } - -protected: - const TKey& _key; - bool _isValid; - -private: - ValidArgs& operator = (const ValidArgs& args); -}; - - -} // namespace Poco - - -#endif // Foundation_ValidArgs_INCLUDED diff --git a/contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp b/contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp deleted file mode 100644 index 624ff83c8c..0000000000 --- a/contrib/libs/poco/Foundation/src/Environment_WIN32U.cpp +++ /dev/null @@ -1,235 +0,0 @@ -// -// Environment_WIN32U.cpp -// -// Library: Foundation -// Package: Core -// Module: Environment -// -// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/Environment_WIN32U.h" -#include "Poco/Exception.h" -#include "Poco/UnicodeConverter.h" -#include "Poco/Buffer.h" -#include <sstream> -#include <cstring> -#include "Poco/UnWindows.h" -#include <winsock2.h> -#include <wincrypt.h> -#include <ws2ipdef.h> -#include <iphlpapi.h> - - -namespace Poco { - - -std::string EnvironmentImpl::getImpl(const std::string& name) -{ - std::wstring uname; - UnicodeConverter::toUTF16(name, uname); - DWORD len = GetEnvironmentVariableW(uname.c_str(), 0, 0); - if (len == 0) throw NotFoundException(name); - Buffer<wchar_t> buffer(len); - GetEnvironmentVariableW(uname.c_str(), buffer.begin(), len); - std::string result; - UnicodeConverter::toUTF8(buffer.begin(), len - 1, result); - return result; -} - - -bool EnvironmentImpl::hasImpl(const std::string& name) -{ - std::wstring uname; - UnicodeConverter::toUTF16(name, uname); - DWORD len = GetEnvironmentVariableW(uname.c_str(), 0, 0); - return len > 0; -} - - -void EnvironmentImpl::setImpl(const std::string& name, const std::string& value) -{ - std::wstring uname; - std::wstring uvalue; - UnicodeConverter::toUTF16(name, uname); - UnicodeConverter::toUTF16(value, uvalue); - if (SetEnvironmentVariableW(uname.c_str(), uvalue.c_str()) == 0) - { - std::string msg = "cannot set environment variable: "; - msg.append(name); - throw SystemException(msg); - } -} - - -std::string EnvironmentImpl::osNameImpl() -{ - OSVERSIONINFO vi; - vi.dwOSVersionInfoSize = sizeof(vi); - if (GetVersionEx(&vi) == 0) throw SystemException("Cannot get OS version information"); - switch (vi.dwPlatformId) - { - case VER_PLATFORM_WIN32s: - return "Windows 3.x"; - case VER_PLATFORM_WIN32_WINDOWS: - return vi.dwMinorVersion == 0 ? "Windows 95" : "Windows 98"; - case VER_PLATFORM_WIN32_NT: - return "Windows NT"; - default: - return "Unknown"; - } -} - - -std::string EnvironmentImpl::osDisplayNameImpl() -{ - OSVERSIONINFOEX vi; // OSVERSIONINFOEX is supported starting at Windows 2000 - vi.dwOSVersionInfoSize = sizeof(vi); - if (GetVersionEx((OSVERSIONINFO*) &vi) == 0) throw SystemException("Cannot get OS version information"); - switch (vi.dwMajorVersion) - { - case 10: - switch (vi.dwMinorVersion) - { - case 0: - return vi.wProductType == VER_NT_WORKSTATION ? "Windows 10" : "Windows Server 2016"; - } - case 6: - switch (vi.dwMinorVersion) - { - case 0: - return vi.wProductType == VER_NT_WORKSTATION ? "Windows Vista" : "Windows Server 2008"; - case 1: - return vi.wProductType == VER_NT_WORKSTATION ? "Windows 7" : "Windows Server 2008 R2"; - case 2: - return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8" : "Windows Server 2012"; - case 3: - return vi.wProductType == VER_NT_WORKSTATION ? "Windows 8.1" : "Windows Server 2012 R2"; - default: - return "Unknown"; - } - case 5: - switch (vi.dwMinorVersion) - { - case 0: - return "Windows 2000"; - case 1: - return "Windows XP"; - case 2: - return "Windows Server 2003/Windows Server 2003 R2"; - default: - return "Unknown"; - } - default: - return "Unknown"; - } -} - - -std::string EnvironmentImpl::osVersionImpl() -{ - OSVERSIONINFOW vi; - vi.dwOSVersionInfoSize = sizeof(vi); - if (GetVersionExW(&vi) == 0) throw SystemException("Cannot get OS version information"); - std::ostringstream str; - str << vi.dwMajorVersion << "." << vi.dwMinorVersion << " (Build " << (vi.dwBuildNumber & 0xFFFF); - std::string version; - UnicodeConverter::toUTF8(vi.szCSDVersion, version); - if (!version.empty()) str << ": " << version; - str << ")"; - return str.str(); -} - - -std::string EnvironmentImpl::osArchitectureImpl() -{ - SYSTEM_INFO si; - GetSystemInfo(&si); - switch (si.wProcessorArchitecture) - { - case PROCESSOR_ARCHITECTURE_INTEL: - return "IA32"; - case PROCESSOR_ARCHITECTURE_MIPS: - return "MIPS"; - case PROCESSOR_ARCHITECTURE_ALPHA: - return "ALPHA"; - case PROCESSOR_ARCHITECTURE_PPC: - return "PPC"; - case PROCESSOR_ARCHITECTURE_IA64: - return "IA64"; -#ifdef PROCESSOR_ARCHITECTURE_IA32_ON_WIN64 - case PROCESSOR_ARCHITECTURE_IA32_ON_WIN64: - return "IA64/32"; -#endif -#ifdef PROCESSOR_ARCHITECTURE_AMD64 - case PROCESSOR_ARCHITECTURE_AMD64: - return "AMD64"; -#endif - default: - return "Unknown"; - } -} - - -std::string EnvironmentImpl::nodeNameImpl() -{ - wchar_t name[MAX_COMPUTERNAME_LENGTH + 1]; - DWORD size = MAX_COMPUTERNAME_LENGTH + 1; - if (GetComputerNameW(name, &size) == 0) throw SystemException("Cannot get computer name"); - std::string result; - UnicodeConverter::toUTF8(name, result); - return result; -} - - -void EnvironmentImpl::nodeIdImpl(NodeId& id) -{ - std::memset(&id, 0, sizeof(id)); - - PIP_ADAPTER_INFO pAdapterInfo; - PIP_ADAPTER_INFO pAdapter = 0; - ULONG len = sizeof(IP_ADAPTER_INFO); - pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]); - // Make an initial call to GetAdaptersInfo to get - // the necessary size into len - DWORD rc = GetAdaptersInfo(pAdapterInfo, &len); - if (rc == ERROR_BUFFER_OVERFLOW) - { - delete [] reinterpret_cast<char*>(pAdapterInfo); - pAdapterInfo = reinterpret_cast<IP_ADAPTER_INFO*>(new char[len]); - } - else if (rc != ERROR_SUCCESS) - { - return; - } - if (GetAdaptersInfo(pAdapterInfo, &len) == NO_ERROR) - { - pAdapter = pAdapterInfo; - bool found = false; - while (pAdapter && !found) - { - if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(id)) - { - found = true; - std::memcpy(&id, pAdapter->Address, pAdapter->AddressLength); - } - pAdapter = pAdapter->Next; - } - } - delete [] reinterpret_cast<char*>(pAdapterInfo); -} - - -unsigned EnvironmentImpl::processorCountImpl() -{ - SYSTEM_INFO si; - GetSystemInfo(&si); - return si.dwNumberOfProcessors; -} - - -} // namespace Poco diff --git a/contrib/libs/poco/Foundation/src/EventLogChannel.cpp b/contrib/libs/poco/Foundation/src/EventLogChannel.cpp deleted file mode 100644 index 5e95f6d1b6..0000000000 --- a/contrib/libs/poco/Foundation/src/EventLogChannel.cpp +++ /dev/null @@ -1,327 +0,0 @@ -// -// EventLogChannel.cpp -// -// Library: Foundation -// Package: Logging -// Module: EventLogChannel -// -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/EventLogChannel.h" -#include "Poco/Message.h" -#include "Poco/String.h" -#include "pocomsg.h" -#if defined(POCO_WIN32_UTF8) -#include "Poco/UnicodeConverter.h" -#endif - - -namespace Poco { - - -const std::string EventLogChannel::PROP_NAME = "name"; -const std::string EventLogChannel::PROP_HOST = "host"; -const std::string EventLogChannel::PROP_LOGHOST = "loghost"; -const std::string EventLogChannel::PROP_LOGFILE = "logfile"; - - -EventLogChannel::EventLogChannel(): - _logFile("Application"), - _h(0) -{ - const DWORD maxPathLen = MAX_PATH + 1; -#if defined(POCO_WIN32_UTF8) - wchar_t name[maxPathLen]; - int n = GetModuleFileNameW(NULL, name, maxPathLen); - if (n > 0) - { - wchar_t* end = name + n - 1; - while (end > name && *end != '\\') --end; - if (*end == '\\') ++end; - std::wstring uname(end); - UnicodeConverter::toUTF8(uname, _name); - } -#else - char name[maxPathLen]; - int n = GetModuleFileNameA(NULL, name, maxPathLen); - if (n > 0) - { - char* end = name + n - 1; - while (end > name && *end != '\\') --end; - if (*end == '\\') ++end; - _name = end; - } -#endif -} - - -EventLogChannel::EventLogChannel(const std::string& name): - _name(name), - _logFile("Application"), - _h(0) -{ -} - - -EventLogChannel::EventLogChannel(const std::string& name, const std::string& host): - _name(name), - _host(host), - _logFile("Application"), - _h(0) -{ -} - - -EventLogChannel::~EventLogChannel() -{ - try - { - close(); - } - catch (...) - { - poco_unexpected(); - } -} - - -void EventLogChannel::open() -{ - setUpRegistry(); -#if defined(POCO_WIN32_UTF8) - std::wstring uhost; - UnicodeConverter::toUTF16(_host, uhost); - std::wstring uname; - UnicodeConverter::toUTF16(_name, uname); - _h = RegisterEventSourceW(uhost.empty() ? NULL : uhost.c_str(), uname.c_str()); -#else - _h = RegisterEventSource(_host.empty() ? NULL : _host.c_str(), _name.c_str()); -#endif - if (!_h) throw SystemException("cannot register event source"); -} - - -void EventLogChannel::close() -{ - if (_h) DeregisterEventSource(_h); - _h = 0; -} - - -void EventLogChannel::log(const Message& msg) -{ - if (!_h) open(); -#if defined(POCO_WIN32_UTF8) - std::wstring utext; - UnicodeConverter::toUTF16(msg.getText(), utext); - const wchar_t* pMsg = utext.c_str(); - ReportEventW(_h, - static_cast<WORD>(getType(msg)), - static_cast<WORD>(getCategory(msg)), - POCO_MSG_LOG, - NULL, - 1, - 0, - &pMsg, - NULL); -#else - const char* pMsg = msg.getText().c_str(); - ReportEvent(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL); -#endif -} - - -void EventLogChannel::setProperty(const std::string& name, const std::string& value) -{ - if (icompare(name, PROP_NAME) == 0) - _name = value; - else if (icompare(name, PROP_HOST) == 0) - _host = value; - else if (icompare(name, PROP_LOGHOST) == 0) - _host = value; - else if (icompare(name, PROP_LOGFILE) == 0) - _logFile = value; - else - Channel::setProperty(name, value); -} - - -std::string EventLogChannel::getProperty(const std::string& name) const -{ - if (icompare(name, PROP_NAME) == 0) - return _name; - else if (icompare(name, PROP_HOST) == 0) - return _host; - else if (icompare(name, PROP_LOGHOST) == 0) - return _host; - else if (icompare(name, PROP_LOGFILE) == 0) - return _logFile; - else - return Channel::getProperty(name); -} - - -int EventLogChannel::getType(const Message& msg) -{ - switch (msg.getPriority()) - { - case Message::PRIO_TRACE: - case Message::PRIO_DEBUG: - case Message::PRIO_INFORMATION: - return EVENTLOG_INFORMATION_TYPE; - case Message::PRIO_NOTICE: - case Message::PRIO_WARNING: - return EVENTLOG_WARNING_TYPE; - default: - return EVENTLOG_ERROR_TYPE; - } -} - - -int EventLogChannel::getCategory(const Message& msg) -{ - switch (msg.getPriority()) - { - case Message::PRIO_TRACE: - return POCO_CTG_TRACE; - case Message::PRIO_DEBUG: - return POCO_CTG_DEBUG; - case Message::PRIO_INFORMATION: - return POCO_CTG_INFORMATION; - case Message::PRIO_NOTICE: - return POCO_CTG_NOTICE; - case Message::PRIO_WARNING: - return POCO_CTG_WARNING; - case Message::PRIO_ERROR: - return POCO_CTG_ERROR; - case Message::PRIO_CRITICAL: - return POCO_CTG_CRITICAL; - case Message::PRIO_FATAL: - return POCO_CTG_FATAL; - default: - return 0; - } -} - - -void EventLogChannel::setUpRegistry() const -{ - std::string key = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\"; - key.append(_logFile); - key.append("\\"); - key.append(_name); - HKEY hKey; - DWORD disp; -#if defined(POCO_WIN32_UTF8) - std::wstring ukey; - UnicodeConverter::toUTF16(key, ukey); - DWORD rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ukey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp); -#else - DWORD rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, key.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp); -#endif - if (rc != ERROR_SUCCESS) return; - - if (disp == REG_CREATED_NEW_KEY) - { -#if defined(POCO_WIN32_UTF8) - std::wstring path; - #if defined(POCO_DLL) - #if defined(_DEBUG) - #if defined(_WIN64) - path = findLibrary(L"PocoFoundation64d.dll"); - #else - path = findLibrary(L"PocoFoundationd.dll"); - #endif - #else - #if defined(_WIN64) - path = findLibrary(L"PocoFoundation64.dll"); - #else - path = findLibrary(L"PocoFoundation.dll"); - #endif - #endif - #endif - - if (path.empty()) - path = findLibrary(L"PocoMsg.dll"); -#else - std::string path; - #if defined(POCO_DLL) - #if defined(_DEBUG) - #if defined(_WIN64) - path = findLibrary("PocoFoundation64d.dll"); - #else - path = findLibrary("PocoFoundationd.dll"); - #endif - #else - #if defined(_WIN64) - path = findLibrary("PocoFoundation64.dll"); - #else - path = findLibrary("PocoFoundation.dll"); - #endif - #endif - #endif - - if (path.empty()) - path = findLibrary("PocoMsg.dll"); -#endif - - if (!path.empty()) - { - DWORD count = 8; - DWORD types = 7; -#if defined(POCO_WIN32_UTF8) - RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(sizeof(wchar_t)*(path.size() + 1))); - RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(sizeof(wchar_t)*(path.size() + 1))); - RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast<DWORD>(sizeof(count))); - RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast<DWORD>(sizeof(types))); -#else - RegSetValueEx(hKey, "CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(path.size() + 1)); - RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast<DWORD>(path.size() + 1)); - RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast<DWORD>(sizeof(count))); - RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast<DWORD>(sizeof(types))); -#endif - } - } - RegCloseKey(hKey); -} - - -#if defined(POCO_WIN32_UTF8) -std::wstring EventLogChannel::findLibrary(const wchar_t* name) -{ - std::wstring path; - HMODULE dll = LoadLibraryW(name); - if (dll) - { - const DWORD maxPathLen = MAX_PATH + 1; - wchar_t moduleName[maxPathLen]; - int n = GetModuleFileNameW(dll, moduleName, maxPathLen); - if (n > 0) path = moduleName; - FreeLibrary(dll); - } - return path; -} -#else -std::string EventLogChannel::findLibrary(const char* name) -{ - std::string path; - HMODULE dll = LoadLibraryA(name); - if (dll) - { - const DWORD maxPathLen = MAX_PATH + 1; - char name[maxPathLen]; - int n = GetModuleFileNameA(dll, name, maxPathLen); - if (n > 0) path = name; - FreeLibrary(dll); - } - return path; -} -#endif - - -} // namespace Poco diff --git a/contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp b/contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp deleted file mode 100644 index 07e352935f..0000000000 --- a/contrib/libs/poco/Foundation/src/WindowsConsoleChannel.cpp +++ /dev/null @@ -1,302 +0,0 @@ -// -// WindowsConsoleChannel.cpp -// -// Library: Foundation -// Package: Logging -// Module: WindowsConsoleChannel -// -// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. -// and Contributors. -// -// SPDX-License-Identifier: BSL-1.0 -// - - -#include "Poco/WindowsConsoleChannel.h" -#include "Poco/Message.h" -#if defined(POCO_WIN32_UTF8) -#include "Poco/UnicodeConverter.h" -#endif -#include "Poco/String.h" -#include "Poco/Exception.h" - - -namespace Poco { - - -WindowsConsoleChannel::WindowsConsoleChannel(): - _isFile(false), - _hConsole(INVALID_HANDLE_VALUE) -{ - _hConsole = GetStdHandle(STD_OUTPUT_HANDLE); - // check whether the console has been redirected - DWORD mode; - _isFile = (GetConsoleMode(_hConsole, &mode) == 0); -} - - -WindowsConsoleChannel::~WindowsConsoleChannel() -{ -} - - -void WindowsConsoleChannel::log(const Message& msg) -{ - std::string text = msg.getText(); - text += "\r\n"; - -#if defined(POCO_WIN32_UTF8) - if (_isFile) - { - DWORD written; - WriteFile(_hConsole, text.data(), static_cast<DWORD>(text.size()), &written, NULL); - } - else - { - std::wstring utext; - UnicodeConverter::toUTF16(text, utext); - DWORD written; - WriteConsoleW(_hConsole, utext.data(), static_cast<DWORD>(utext.size()), &written, NULL); - } -#else - DWORD written; - WriteFile(_hConsole, text.data(), text.size(), &written, NULL); -#endif -} - - -WindowsColorConsoleChannel::WindowsColorConsoleChannel(): - _enableColors(true), - _isFile(false), - _hConsole(INVALID_HANDLE_VALUE) -{ - _hConsole = GetStdHandle(STD_OUTPUT_HANDLE); - // check whether the console has been redirected - DWORD mode; - _isFile = (GetConsoleMode(_hConsole, &mode) == 0); - initColors(); -} - - -WindowsColorConsoleChannel::~WindowsColorConsoleChannel() -{ -} - - -void WindowsColorConsoleChannel::log(const Message& msg) -{ - std::string text = msg.getText(); - text += "\r\n"; - - if (_enableColors && !_isFile) - { - WORD attr = _colors[0]; - attr &= 0xFFF0; - attr |= _colors[msg.getPriority()]; - SetConsoleTextAttribute(_hConsole, attr); - } - -#if defined(POCO_WIN32_UTF8) - if (_isFile) - { - DWORD written; - WriteFile(_hConsole, text.data(), static_cast<DWORD>(text.size()), &written, NULL); - } - else - { - std::wstring utext; - UnicodeConverter::toUTF16(text, utext); - DWORD written; - WriteConsoleW(_hConsole, utext.data(), static_cast<DWORD>(utext.size()), &written, NULL); - } -#else - DWORD written; - WriteFile(_hConsole, text.data(), text.size(), &written, NULL); -#endif - - if (_enableColors && !_isFile) - { - SetConsoleTextAttribute(_hConsole, _colors[0]); - } -} - - -void WindowsColorConsoleChannel::setProperty(const std::string& name, const std::string& value) -{ - if (name == "enableColors") - { - _enableColors = icompare(value, "true") == 0; - } - else if (name == "traceColor") - { - _colors[Message::PRIO_TRACE] = parseColor(value); - } - else if (name == "debugColor") - { - _colors[Message::PRIO_DEBUG] = parseColor(value); - } - else if (name == "informationColor") - { - _colors[Message::PRIO_INFORMATION] = parseColor(value); - } - else if (name == "noticeColor") - { - _colors[Message::PRIO_NOTICE] = parseColor(value); - } - else if (name == "warningColor") - { - _colors[Message::PRIO_WARNING] = parseColor(value); - } - else if (name == "errorColor") - { - _colors[Message::PRIO_ERROR] = parseColor(value); - } - else if (name == "criticalColor") - { - _colors[Message::PRIO_CRITICAL] = parseColor(value); - } - else if (name == "fatalColor") - { - _colors[Message::PRIO_FATAL] = parseColor(value); - } - else - { - Channel::setProperty(name, value); - } -} - - -std::string WindowsColorConsoleChannel::getProperty(const std::string& name) const -{ - if (name == "enableColors") - { - return _enableColors ? "true" : "false"; - } - else if (name == "traceColor") - { - return formatColor(_colors[Message::PRIO_TRACE]); - } - else if (name == "debugColor") - { - return formatColor(_colors[Message::PRIO_DEBUG]); - } - else if (name == "informationColor") - { - return formatColor(_colors[Message::PRIO_INFORMATION]); - } - else if (name == "noticeColor") - { - return formatColor(_colors[Message::PRIO_NOTICE]); - } - else if (name == "warningColor") - { - return formatColor(_colors[Message::PRIO_WARNING]); - } - else if (name == "errorColor") - { - return formatColor(_colors[Message::PRIO_ERROR]); - } - else if (name == "criticalColor") - { - return formatColor(_colors[Message::PRIO_CRITICAL]); - } - else if (name == "fatalColor") - { - return formatColor(_colors[Message::PRIO_FATAL]); - } - else - { - return Channel::getProperty(name); - } -} - - -WORD WindowsColorConsoleChannel::parseColor(const std::string& color) const -{ - if (icompare(color, "default") == 0) - return _colors[0]; - else if (icompare(color, "black") == 0) - return CC_BLACK; - else if (icompare(color, "red") == 0) - return CC_RED; - else if (icompare(color, "green") == 0) - return CC_GREEN; - else if (icompare(color, "brown") == 0) - return CC_BROWN; - else if (icompare(color, "blue") == 0) - return CC_BLUE; - else if (icompare(color, "magenta") == 0) - return CC_MAGENTA; - else if (icompare(color, "cyan") == 0) - return CC_CYAN; - else if (icompare(color, "gray") == 0) - return CC_GRAY; - else if (icompare(color, "darkGray") == 0) - return CC_DARKGRAY; - else if (icompare(color, "lightRed") == 0) - return CC_LIGHTRED; - else if (icompare(color, "lightGreen") == 0) - return CC_LIGHTGREEN; - else if (icompare(color, "yellow") == 0) - return CC_YELLOW; - else if (icompare(color, "lightBlue") == 0) - return CC_LIGHTBLUE; - else if (icompare(color, "lightMagenta") == 0) - return CC_LIGHTMAGENTA; - else if (icompare(color, "lightCyan") == 0) - return CC_LIGHTCYAN; - else if (icompare(color, "white") == 0) - return CC_WHITE; - else throw InvalidArgumentException("Invalid color value", color); -} - - -std::string WindowsColorConsoleChannel::formatColor(WORD color) const -{ - switch (color) - { - case CC_BLACK: return "black"; - case CC_RED: return "red"; - case CC_GREEN: return "green"; - case CC_BROWN: return "brown"; - case CC_BLUE: return "blue"; - case CC_MAGENTA: return "magenta"; - case CC_CYAN: return "cyan"; - case CC_GRAY: return "gray"; - case CC_DARKGRAY: return "darkGray"; - case CC_LIGHTRED: return "lightRed"; - case CC_LIGHTGREEN: return "lightGreen"; - case CC_YELLOW: return "yellow"; - case CC_LIGHTBLUE: return "lightBlue"; - case CC_LIGHTMAGENTA: return "lightMagenta"; - case CC_LIGHTCYAN: return "lightCyan"; - case CC_WHITE: return "white"; - default: return "invalid"; - } -} - - -void WindowsColorConsoleChannel::initColors() -{ - if (!_isFile) - { - CONSOLE_SCREEN_BUFFER_INFO csbi; - GetConsoleScreenBufferInfo(_hConsole, &csbi); - _colors[0] = csbi.wAttributes; - } - else - { - _colors[0] = CC_WHITE; - } - _colors[Message::PRIO_FATAL] = CC_LIGHTRED; - _colors[Message::PRIO_CRITICAL] = CC_LIGHTRED; - _colors[Message::PRIO_ERROR] = CC_LIGHTRED; - _colors[Message::PRIO_WARNING] = CC_YELLOW; - _colors[Message::PRIO_NOTICE] = _colors[0]; - _colors[Message::PRIO_INFORMATION] = _colors[0]; - _colors[Message::PRIO_DEBUG] = CC_GRAY; - _colors[Message::PRIO_TRACE] = CC_GRAY; -} - - -} // namespace Poco diff --git a/contrib/libs/poco/Foundation/src/pocomsg.h b/contrib/libs/poco/Foundation/src/pocomsg.h deleted file mode 100644 index fe68ae436f..0000000000 --- a/contrib/libs/poco/Foundation/src/pocomsg.h +++ /dev/null @@ -1,158 +0,0 @@ -// -// pocomsg.mc[.h] -// -// $Id: //poco/1.4/Foundation/src/pocomsg.mc#1 $ -// -// The Poco message source/header file. -// -// NOTE: pocomsg.h is automatically generated from pocomsg.mc. -// Never edit pocomsg.h directly! -// -// 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. -// -// -// Categories -// -// -// Values are 32 bit values laid out as follows: -// -// 3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 -// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 -// +---+-+-+-----------------------+-------------------------------+ -// |Sev|C|R| Facility | Code | -// +---+-+-+-----------------------+-------------------------------+ -// -// where -// -// Sev - is the severity code -// -// 00 - Success -// 01 - Informational -// 10 - Warning -// 11 - Error -// -// C - is the Customer code flag -// -// R - is a reserved bit -// -// Facility - is the facility code -// -// Code - is the facility's status code -// -// -// Define the facility codes -// - - -// -// Define the severity codes -// - - -// -// MessageId: POCO_CTG_FATAL -// -// MessageText: -// -// Fatal -// -#define POCO_CTG_FATAL 0x00000001L - -// -// MessageId: POCO_CTG_CRITICAL -// -// MessageText: -// -// Critical -// -#define POCO_CTG_CRITICAL 0x00000002L - -// -// MessageId: POCO_CTG_ERROR -// -// MessageText: -// -// Error -// -#define POCO_CTG_ERROR 0x00000003L - -// -// MessageId: POCO_CTG_WARNING -// -// MessageText: -// -// Warning -// -#define POCO_CTG_WARNING 0x00000004L - -// -// MessageId: POCO_CTG_NOTICE -// -// MessageText: -// -// Notice -// -#define POCO_CTG_NOTICE 0x00000005L - -// -// MessageId: POCO_CTG_INFORMATION -// -// MessageText: -// -// Information -// -#define POCO_CTG_INFORMATION 0x00000006L - -// -// MessageId: POCO_CTG_DEBUG -// -// MessageText: -// -// Debug -// -#define POCO_CTG_DEBUG 0x00000007L - -// -// MessageId: POCO_CTG_TRACE -// -// MessageText: -// -// Trace -// -#define POCO_CTG_TRACE 0x00000008L - -// -// Event Identifiers -// -// -// MessageId: POCO_MSG_LOG -// -// MessageText: -// -// %1 -// -#define POCO_MSG_LOG 0x00001000L - |