8#include "Arp/Base/Core/Exception.hpp"
9#include "Arp/Base/Core/Detail/Enumerator.hxx"
10#include "Arp/Base/Core/Detail/Enumerator.IteratorAdapters.hxx"
13namespace Arp {
namespace Base {
namespace Core
21template<
class Iterator,
class IteratorAdapter>
25 StlAdapter(Iterator begin, Iterator end);
26 StlAdapter(
const StlAdapter& arg) =
delete;
39 bool wasMoved =
false;
40 IteratorAdapter iteratorAdapter;
49template<
class Iterator,
class IteratorAdapter>
56template<
class Iterator,
class IteratorAdapter>
61template<
class Iterator,
class IteratorAdapter>
68template<
class Iterator,
class IteratorAdapter>
77template<
class Iterator,
class IteratorAdapter>
80 if (this->begin == this->end)
86 this->wasMoved =
true;
92 return this->begin != this->end;
97template<
class Iterator,
class IteratorAdapter>
100 if ((!this->wasMoved) || (this->begin == this->end))
102 throw Exception(
"Enumerator<T>::StlAdapter::GetCurrent(): StlAdapter enumerator is empty or enumerating has ended yet");
104 return this->iteratorAdapter(this->begin);
115template<
class TIterator>
118 return std::make_shared<StlAdapter<TIterator, typename IteratorAdapters<TIterator>::Value>>(begin, end);
126template<
class TContainer>
129 return CreateStlAdapter(c.begin(), c.end());
137template<
class TContainer>
140 return CreateStlAdapter(c.begin(), c.end());
148template<
class TContainer>
151 return std::make_shared<StlAdapter<typename TContainer::iterator, typename IteratorAdapters<typename TContainer::iterator>::ConstKey>>(c.begin(), c.end());
159template<
class TContainer>
162 return std::make_shared<StlAdapter<typename TContainer::const_iterator, typename IteratorAdapters<typename TContainer::const_iterator>::ConstKey>>(c.begin(), c.end());
170template<
class TContainer>
173 return std::make_shared<StlAdapter<typename TContainer::iterator, typename IteratorAdapters<typename TContainer::iterator>::Mapped>>(c.begin(), c.end());
181template<
class TContainer>
184 return std::make_shared<StlAdapter<typename TContainer::const_iterator, typename IteratorAdapters<typename TContainer::const_iterator>::ConstMapped>>(c.begin(), c.end());
This class implements an enumerator adapter for STL container based on iterators.
Definition: Enumerator.StlAdapter.hxx:23
StlAdapter(StlAdapter &&arg) noexcept
Move constructor.
~StlAdapter(void) override
Destructs this instance and frees all resources.
StlAdapter & operator=(StlAdapter &&arg) noexcept
Move assignment operator.
This class defines a base class for all enumerator implementations and some predefined enumerators as...
Definition: Enumerator.hxx:24
static IEnumerator< T >::Ptr CreateMappedAdapter(TContainer &c)
Creates an enumerator adapter from the given STL map enumerating the mapped items.
Definition: Enumerator.StlAdapter.hxx:171
static IEnumerator< T >::Ptr CreateKeysAdapter(TContainer &c)
Creates an enumerator adapter from the given STL map enumerating the keys.
Definition: Enumerator.StlAdapter.hxx:149
static IEnumerator< T >::Ptr CreateStlAdapter(TIterator begin, TIterator end)
Creates an enumerator adapter from the given STL iterators.
Definition: Enumerator.StlAdapter.hxx:116
T GetCurrent(void) override
Gets the element at the current position.
Definition: Enumerator.hxx:113
This is the base class of all Arp exception classes.
Definition: Exception.hpp:21
Declares the interface of the enumerator pattern, which is leaned on .NET enumerator idiom.
Definition: IEnumerator.hxx:49
virtual bool MoveNext(void)=0
Moves this enumerator to the next position.
std::shared_ptr< IEnumerator > Ptr
The smart pointer type of this interface.
Definition: IEnumerator.hxx:52
Root namespace for the PLCnext API