|
|
|
|
| #ifndef _CLI_ADAPTER_
|
| #define _CLI_ADAPTER_
|
| #include <cliext/iterator>
|
| #include <cliext/utility>
|
|
|
| namespace cliext {
|
|
|
|
|
|
|
| template<typename _Cont_t>
|
| ref class collection_adapter;
|
|
|
|
|
|
|
|
|
| template<typename _Cont_t,
|
| typename _Enum_t,
|
| typename _Value_t>
|
| ref class Enum_iterator
|
| {
|
| public:
|
|
|
| typedef Enum_iterator<_Cont_t, _Enum_t, _Value_t> _Mytype_t;
|
|
|
| typedef input_iterator_tag iterator_category;
|
| typedef _Value_t value_type;
|
| typedef int difference_type;
|
| typedef value_type% pointer;
|
| typedef value_type% reference;
|
| typedef value_type% const_reference;
|
|
|
|
|
| Enum_iterator()
|
| : _Mycont(nullptr), _Myenum(nullptr)
|
| {
|
| }
|
|
|
| Enum_iterator(Enum_iterator% _Right)
|
| : _Mycont(_Right._Mycont), _Myenum(_Right._Myenum)
|
| {
|
| }
|
|
|
| Enum_iterator% operator=(Enum_iterator% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| _Myenum = _Right._Myenum;
|
| return (*this);
|
| }
|
|
|
|
|
| Enum_iterator(_Cont_t^ _Cont)
|
| : _Mycont(_Cont), _Myenum(nullptr)
|
| {
|
| }
|
|
|
| Enum_iterator(_Cont_t^ _Cont, _Enum_t^ _Enum)
|
| : _Mycont(_Cont), _Myenum(_Enum)
|
| {
|
| if (!_Myenum->MoveNext())
|
| _Myenum = nullptr;
|
| }
|
|
|
|
|
| static value_type operator->(Enum_iterator% _Left)
|
| {
|
| return (_Left._Myenum->Current);
|
| }
|
|
|
| static value_type operator*(Enum_iterator% _Left)
|
| {
|
| return (_Left._Myenum->Current);
|
| }
|
|
|
| Enum_iterator operator++()
|
| {
|
| if (!_Myenum->MoveNext())
|
| _Myenum = nullptr;
|
| return (*this);
|
| }
|
|
|
| Enum_iterator operator++(int)
|
| {
|
| Enum_iterator _Iter = *this;
|
|
|
| ++*this;
|
| return (_Iter);
|
| }
|
|
|
| bool operator==(_Mytype_t% _Right)
|
| {
|
| if (_Mycont != _Right._Mycont)
|
| throw gcnew System::InvalidOperationException();
|
| return ((System::Object^)_Myenum == _Right._Myenum);
|
| }
|
|
|
| bool operator!=(_Mytype_t% _Right)
|
| {
|
| return (!(*this == _Right));
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Cont_t^ _Mycont;
|
| _Enum_t^ _Myenum;
|
| };
|
|
|
|
|
|
|
|
|
| template<>
|
| ref class collection_adapter<
|
| System::Collections::IEnumerable>
|
| {
|
| public:
|
|
|
| typedef System::Collections::IEnumerable _Mycont_t;
|
| typedef System::Collections::IEnumerator _Myenum_t;
|
| typedef System::Object^ _Value_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef Enum_iterator<_Mycont_t, _Myenum_t, _Value_t> iterator;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef _Value_t% reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator begin()
|
| {
|
| return (iterator(_Mycont, _Mycont->GetEnumerator()));
|
| }
|
|
|
| iterator end()
|
| {
|
| return (iterator(_Mycont));
|
| }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Value_t>
|
| ref class collection_adapter<
|
| System::Collections::Generic::IEnumerable<_Value_t> >
|
| {
|
| public:
|
|
|
| typedef System::Collections::Generic::IEnumerable<_Value_t> _Mycont_t;
|
| typedef System::Collections::Generic::IEnumerator<_Value_t> _Myenum_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef Enum_iterator<_Mycont_t, _Myenum_t, _Value_t> iterator;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef _Value_t% reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator begin()
|
| {
|
| return (iterator(_Mycont, _Mycont->GetEnumerator()));
|
| }
|
|
|
| iterator end()
|
| {
|
| return (iterator(_Mycont));
|
| }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
|
|
|
|
|
|
| template<>
|
| ref class collection_adapter<
|
| System::Collections::ICollection>
|
| {
|
| public:
|
|
|
| typedef System::Collections::ICollection _Mycont_t;
|
| typedef System::Collections::IEnumerator _Myenum_t;
|
| typedef System::Object^ _Value_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef Enum_iterator<_Mycont_t, _Myenum_t, _Value_t> iterator;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef _Value_t% reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator begin()
|
| {
|
| return (iterator(_Mycont, _Mycont->GetEnumerator()));
|
| }
|
|
|
| iterator end()
|
| {
|
| return (iterator(_Mycont));
|
| }
|
|
|
|
|
| size_type size()
|
| {
|
| return (_Mycont->Count);
|
| }
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Value_t>
|
| ref class collection_adapter<
|
| System::Collections::Generic::ICollection<_Value_t> >
|
| {
|
| public:
|
|
|
| typedef System::Collections::Generic::ICollection<_Value_t> _Mycont_t;
|
| typedef System::Collections::Generic::IEnumerator<_Value_t> _Myenum_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef Enum_iterator<_Mycont_t, _Myenum_t, _Value_t> iterator;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef _Value_t% reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator begin()
|
| {
|
| return (iterator(_Mycont, _Mycont->GetEnumerator()));
|
| }
|
|
|
| iterator end()
|
| {
|
| return (iterator(_Mycont));
|
| }
|
|
|
|
|
| size_type size()
|
| {
|
| return (_Mycont->Count);
|
| }
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
|
|
|
|
|
|
| template<>
|
| ref class collection_adapter<
|
| System::Collections::IDictionary>
|
| {
|
| public:
|
|
|
| typedef System::Collections::IDictionary _Mycont_t;
|
| typedef System::Collections::IEnumerator _Myenum_t;
|
| typedef System::Object^ _Value_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef Enum_iterator<_Mycont_t, _Myenum_t, _Value_t> iterator;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef _Value_t% reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator begin()
|
| {
|
| return (iterator(_Mycont, _Mycont->GetEnumerator()));
|
| }
|
|
|
| iterator end()
|
| {
|
| return (iterator(_Mycont));
|
| }
|
|
|
|
|
| size_type size()
|
| {
|
| return (_Mycont->Count);
|
| }
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Key_t,
|
| typename _Mapped_t>
|
| ref class collection_adapter<
|
| System::Collections::Generic::IDictionary<_Key_t, _Mapped_t> >
|
| {
|
| public:
|
|
|
| typedef System::Collections::Generic::IDictionary<
|
| _Key_t, _Mapped_t> _Mycont_t;
|
| typedef System::Collections::Generic::KeyValuePair<
|
| _Key_t, _Mapped_t> _Value_t;
|
| typedef System::Collections::Generic::IEnumerator<
|
| _Value_t> _Myenum_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef Enum_iterator<_Mycont_t, _Myenum_t, _Value_t> iterator;
|
|
|
| typedef _Key_t key_type;
|
| typedef _Mapped_t mapped_type;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef _Value_t% reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator begin()
|
| {
|
| return (iterator(_Mycont, _Mycont->GetEnumerator()));
|
| }
|
|
|
| iterator end()
|
| {
|
| return (iterator(_Mycont));
|
| }
|
|
|
|
|
| size_type size()
|
| {
|
| return (_Mycont->Count);
|
| }
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
|
|
|
|
|
|
| template<>
|
| ref class collection_adapter<
|
| System::Collections::IList>
|
| {
|
| public:
|
|
|
| typedef System::Collections::IList _Mycont_t;
|
| typedef System::Object^ _Value_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef BCL_iterator<_Mytype_t, false> iterator;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef BCL_reference<_Mytype_t, false> reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| bool valid_bias(size_type _Bias)
|
| {
|
| return (0 <= _Bias && _Bias <= size());
|
| }
|
|
|
| reference at(size_type _Bias)
|
| {
|
| return (reference(this, _Bias));
|
| }
|
|
|
| value_type at_val(size_type _Pos)
|
| {
|
| return (_Mycont[_Pos]);
|
| }
|
|
|
| void at_set(size_type _Pos, value_type _Val)
|
| {
|
| _Mycont[_Pos] = _Val;
|
| }
|
|
|
| property value_type default[difference_type]
|
| {
|
| value_type get(difference_type _Pos)
|
| {
|
| return (_Mycont[_Pos]);
|
| }
|
|
|
| void set(difference_type _Pos, value_type _Val)
|
| {
|
| _Mycont[_Pos] = _Val;
|
| }
|
| };
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator make_iterator(size_type _Bias)
|
| {
|
| return (iterator(this, _Bias));
|
| }
|
|
|
| iterator begin()
|
| {
|
| return (make_iterator(0));
|
| }
|
| iterator end()
|
| {
|
| return (make_iterator(size()));
|
| }
|
|
|
|
|
| size_type size()
|
| {
|
| return (_Mycont->Count);
|
| }
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Value_t>
|
| ref class collection_adapter<
|
| System::Collections::Generic::IList<_Value_t> >
|
| {
|
| public:
|
|
|
| typedef System::Collections::Generic::IList<_Value_t> _Mycont_t;
|
| typedef collection_adapter<_Mycont_t> _Mytype_t;
|
|
|
| typedef BCL_iterator<_Mytype_t, false> iterator;
|
|
|
| typedef int size_type;
|
| typedef int difference_type;
|
| typedef _Value_t value_type;
|
| typedef BCL_reference<_Mytype_t, false> reference;
|
|
|
|
|
| collection_adapter()
|
| : _Mycont(nullptr)
|
| {
|
| }
|
|
|
| collection_adapter(collection_adapter% _Right)
|
| : _Mycont(_Right._Mycont)
|
| {
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter% _Right)
|
| {
|
| _Mycont = _Right._Mycont;
|
| return (*this);
|
| }
|
|
|
| collection_adapter% operator=(collection_adapter^ _Right)
|
| {
|
| _Mycont = _Right->_Mycont;
|
| return (*this);
|
| }
|
|
|
|
|
| collection_adapter(_Mycont_t^ _Right)
|
| : _Mycont(_Right)
|
| {
|
| }
|
|
|
|
|
| ~collection_adapter()
|
| {
|
| }
|
|
|
|
|
| bool valid_bias(size_type _Bias)
|
| {
|
| return (0 <= _Bias && _Bias <= size());
|
| }
|
|
|
| reference at(size_type _Bias)
|
| {
|
| return (reference(this, _Bias));
|
| }
|
|
|
| value_type at_val(size_type _Pos)
|
| {
|
| return (_Mycont[_Pos]);
|
| }
|
|
|
| void at_set(size_type _Pos, value_type _Val)
|
| {
|
| _Mycont[_Pos] = _Val;
|
| }
|
|
|
| property value_type default[difference_type]
|
| {
|
| value_type get(difference_type _Pos)
|
| {
|
| return (_Mycont[_Pos]);
|
| }
|
|
|
| void set(difference_type _Pos, value_type _Val)
|
| {
|
| _Mycont[_Pos] = _Val;
|
| }
|
| };
|
|
|
|
|
| operator _Mycont_t^()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
| _Mycont_t^ base()
|
| {
|
| return (_Mycont);
|
| }
|
|
|
|
|
| iterator make_iterator(size_type _Bias)
|
| {
|
| return (iterator(this, _Bias));
|
| }
|
|
|
| iterator begin()
|
| {
|
| return (make_iterator(0));
|
| }
|
|
|
| iterator end()
|
| {
|
| return (make_iterator(size()));
|
| }
|
|
|
|
|
| size_type size()
|
| {
|
| return (_Mycont->Count);
|
| }
|
|
|
|
|
| void swap(collection_adapter% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Mycont_t^ _Tcont = _Mycont;
|
|
|
| _Mycont = _Right._Mycont;
|
| _Right._Mycont = _Tcont;
|
| }
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Mycont_t^ _Mycont;
|
| };
|
|
|
| namespace impl {
|
|
|
|
|
|
|
| template<typename _Iter_t,
|
| typename _Value_t>
|
| ref class range_enumerator_base
|
| : public System::Collections::IEnumerator
|
| {
|
| public:
|
| typedef range_enumerator_base<_Iter_t, _Value_t> _Mytype_t;
|
|
|
| typedef _Value_t value_type;
|
|
|
| range_enumerator_base(_Iter_t _First, _Iter_t _Last)
|
| : _Myfirst(_First), _Mylast(_Last), _Is_reset(true)
|
| {
|
| }
|
|
|
| virtual bool MoveNext()
|
| {
|
| if (_Is_reset)
|
| {
|
| _Is_reset = false;
|
| _Mynext = _Myfirst;
|
| }
|
| else if (_Mynext != _Mylast)
|
| ++_Mynext;
|
| return (_Mynext != _Mylast);
|
| }
|
|
|
| property System::Object^ Current
|
| {
|
| virtual System::Object^ get()
|
| {
|
| return (_Getval());
|
| }
|
|
|
| virtual void set(System::Object^ _Val)
|
| {
|
| _Setval((value_type)_Val);
|
| }
|
| };
|
|
|
| virtual void Reset()
|
| {
|
| _Is_reset = true;
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| value_type _Getval()
|
| {
|
| if (_Is_reset || _Mynext == _Mylast)
|
| throw gcnew System::InvalidOperationException();
|
| return (*_Mynext);
|
| }
|
|
|
| void _Setval(value_type _Val)
|
| {
|
| if (_Is_reset || _Mynext == _Mylast)
|
| throw gcnew System::InvalidOperationException();
|
| *_Mynext = _Val;
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
| bool _Is_reset;
|
| _Iter_t _Myfirst;
|
| _Iter_t _Mynext;
|
| _Iter_t _Mylast;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Iter_t,
|
| typename _Value_t>
|
| ref class range_enumerator
|
| : public range_enumerator_base<_Iter_t, _Value_t>,
|
| System::Collections::Generic::IEnumerator<_Value_t>
|
| {
|
| public:
|
| typedef range_enumerator<_Iter_t, _Value_t> _Mytype_t;
|
| typedef range_enumerator_base<_Iter_t, _Value_t> _Mybase_t;
|
|
|
| typedef _Value_t value_type;
|
|
|
| range_enumerator(_Iter_t _First, _Iter_t _Last)
|
| : _Mybase_t(_First, _Last)
|
| {
|
| }
|
|
|
| ~range_enumerator()
|
| {
|
| }
|
|
|
| virtual bool MoveNext() override
|
| {
|
| return (_Mybase_t::MoveNext());
|
| }
|
|
|
| property value_type Current
|
| {
|
| virtual value_type get() new
|
| {
|
| return (_Mybase_t::_Getval());
|
| }
|
|
|
| virtual void set(value_type _Val)
|
| {
|
| _Mybase_t::_Setval(_Val);
|
| }
|
| };
|
|
|
| virtual void Reset() override
|
| {
|
| _Mybase_t::Reset();
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Iter_t,
|
| typename _Value_t,
|
| bool _Is_ref>
|
| ref class range_impl
|
| : public System::Collections::ICollection,
|
| System::Collections::IEnumerable
|
| {
|
| public:
|
|
|
| typedef range_impl<_Iter_t, _Value_t, _Is_ref> _Mytype_t;
|
| typedef cli::array<_Value_t> _Myarray_t;
|
| typedef System::Collections::Generic::IEnumerable<_Value_t> _Myenum_it;
|
| typedef _Cont_make_value<_Value_t, _Is_ref> _Mymake_t;
|
|
|
| typedef typename iterator_traits<_Iter_t>::distance_type size_type;
|
| typedef _Value_t value_type;
|
|
|
|
|
| range_impl()
|
| : _Myfirst(), _Mylast()
|
| {
|
| }
|
|
|
| range_impl(range_impl% _Right)
|
| : _Myfirst(_Right._Myfirst), _Mylast(_Right._Mylast)
|
| {
|
| }
|
|
|
| range_impl% operator=(range_impl% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Myfirst = _Right._Myfirst;
|
| _Mylast = _Right._Mylast;
|
| }
|
| return (*this);
|
| }
|
|
|
|
|
| range_impl(_Iter_t _First, _Iter_t _Last)
|
| : _Myfirst(_First), _Mylast(_Last)
|
| {
|
| }
|
|
|
|
|
| ~range_impl()
|
| {
|
| }
|
|
|
| _STLCLR_FIELD_ACCESS:
|
|
|
| _Iter_t _Myfirst;
|
| _Iter_t _Mylast;
|
|
|
|
|
| public:
|
| System::Object^ Clone()
|
| {
|
| return (gcnew range_impl(this));
|
| }
|
|
|
| private:
|
| property size_type Count
|
| {
|
| virtual size_type get() sealed
|
| = System::Collections::ICollection::Count::get
|
| {
|
| return (distance(_Myfirst, _Mylast));
|
| }
|
| };
|
|
|
| property bool IsSynchronized
|
| {
|
| virtual bool get() sealed
|
| = System::Collections::ICollection::IsSynchronized::get
|
| {
|
| return (false);
|
| }
|
| };
|
|
|
| property System::Object^ SyncRoot
|
| {
|
| virtual System::Object^ get() sealed
|
| = System::Collections::ICollection::SyncRoot::get
|
| {
|
| return (this);
|
| }
|
| };
|
|
|
| virtual void CopyTo(System::Array^ _Dest_arg, int _First) sealed
|
| = System::Collections::ICollection::CopyTo
|
| {
|
| cli::array<System::Object^>^ _Dest =
|
| (cli::array<System::Object ^>^)_Dest_arg;
|
| int _Idx = 0;
|
|
|
| for (_Iter_t _Next = _Myfirst; _Next != _Mylast; ++_Next, ++_Idx)
|
| {
|
| _Dest[_First + _Idx] = *_Next;
|
| }
|
| }
|
|
|
| virtual System::Collections::IEnumerator^ GetEnumerator() sealed
|
| = System::Collections::IEnumerable::GetEnumerator
|
| {
|
| return (gcnew range_enumerator<_Iter_t, _Value_t>(_Myfirst, _Mylast));
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Iter_t,
|
| typename _Value_t,
|
| bool _Is_ref>
|
| ref class range_base
|
| : public range_impl<_Iter_t, _Value_t, _Is_ref>,
|
| System::Collections::Generic::ICollection<_Value_t>,
|
| System::Collections::Generic::IEnumerable<_Value_t>
|
| {
|
| public:
|
|
|
| typedef range_base<_Iter_t, _Value_t, _Is_ref> _Mytype_t;
|
| typedef range_impl<_Iter_t, _Value_t, _Is_ref> _Mybase_t;
|
|
|
| typedef typename _Mybase_t::_Myarray_t _Myarray_t;
|
| typedef typename _Mybase_t::size_type size_type;
|
| typedef typename _Mybase_t::value_type value_type;
|
|
|
|
|
| range_base()
|
| : _Mybase_t()
|
| {
|
| }
|
|
|
| range_base(range_base% _Right)
|
| : _Mybase_t(_Right)
|
| {
|
| }
|
|
|
| range_base% operator=(range_base% _Right)
|
| {
|
| _Mybase_t::operator=(_Right);
|
| return (*this);
|
| }
|
|
|
|
|
| range_base(_Iter_t _First, _Iter_t _Last)
|
| : _Mybase_t(_First, _Last)
|
| {
|
| }
|
|
|
|
|
| private:
|
| property size_type Count_generic
|
| {
|
| virtual size_type get() sealed
|
| = System::Collections::Generic::ICollection<_Value_t>::Count::get
|
| {
|
| return (distance(this->_Myfirst, this->_Mylast));
|
| }
|
| };
|
|
|
| property bool IsReadOnly
|
| {
|
| virtual bool get() sealed
|
| = System::Collections::Generic::ICollection<_Value_t>
|
| ::IsReadOnly::get
|
| {
|
| return (true);
|
| }
|
| };
|
|
|
| virtual void CopyTo(_Myarray_t^ _Dest, int _First) sealed
|
| = System::Collections::Generic::ICollection<_Value_t>::CopyTo
|
| {
|
| int _Idx = 0;
|
|
|
| for (_Iter_t _Next = this->_Myfirst; _Next != this->_Mylast; ++_Next, ++_Idx)
|
| {
|
| _Dest[_First + _Idx] = *_Next;
|
| }
|
| }
|
|
|
| virtual System::Collections::Generic::IEnumerator<_Value_t>^
|
| GetEnumerator() sealed
|
| = System::Collections::Generic::IEnumerable<_Value_t>::GetEnumerator
|
| {
|
| return (gcnew range_enumerator<_Iter_t, _Value_t>(this->_Myfirst, this->_Mylast));
|
| }
|
|
|
|
|
| virtual void Add(value_type) sealed
|
| = System::Collections::Generic::ICollection<_Value_t>::Add
|
| {
|
| throw gcnew System::InvalidOperationException();
|
| }
|
|
|
| virtual void Clear() sealed
|
| = System::Collections::Generic::ICollection<_Value_t>::Clear
|
| {
|
| throw gcnew System::InvalidOperationException();
|
| }
|
|
|
| virtual bool Contains(value_type _Val) sealed
|
| = System::Collections::Generic::ICollection<_Value_t>::Contains
|
| {
|
| for (_Iter_t _Next = this->_Myfirst; _Next != this->_Mylast; ++_Next)
|
| {
|
| value_type _Elem = *_Next;
|
|
|
| if (((System::Object^)_Val)->Equals(
|
| (System::Object^)_Elem))
|
| return (true);
|
| }
|
| return (false);
|
| }
|
|
|
| virtual bool Remove(value_type) sealed
|
| = System::Collections::Generic::ICollection<_Value_t>::Remove
|
| {
|
| #pragma warning(push)
|
| #pragma warning(disable: 4715)
|
| throw gcnew System::InvalidOperationException();
|
| #pragma warning(pop)
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Iter_t,
|
| typename _Value_t,
|
| bool _Is_ref>
|
| ref class range_select
|
| : public range_base<_Iter_t, _Value_t, _Is_ref>
|
| {
|
| public:
|
|
|
| typedef _Value_t _Gvalue_t;
|
|
|
| typedef range_select<_Iter_t, _Value_t, _Is_ref> _Mytype_t;
|
| typedef range_base<_Iter_t, _Gvalue_t, _Is_ref> _Mybase_t;
|
|
|
|
|
| range_select()
|
| : _Mybase_t()
|
| {
|
| }
|
|
|
| range_select(range_select% _Right)
|
| : _Mybase_t(_Right)
|
| {
|
| }
|
|
|
| range_select% operator=(range_select% _Right)
|
| {
|
| _Mybase_t::operator=(_Right);
|
| return (*this);
|
| }
|
|
|
|
|
| range_select(_Iter_t _First, _Iter_t _Last)
|
| : _Mybase_t(_First, _Last)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Iter_t,
|
| typename _Value_t>
|
| ref class range_select<_Iter_t, _Value_t, true>
|
| : public range_base<_Iter_t, _Value_t^, true>
|
| {
|
| public:
|
|
|
| typedef _Value_t^ _Gvalue_t;
|
|
|
| typedef range_select<_Iter_t, _Value_t, true> _Mytype_t;
|
| typedef range_base<_Iter_t, _Gvalue_t, true> _Mybase_t;
|
|
|
| typedef _Value_t value_type;
|
|
|
|
|
| range_select()
|
| : _Mybase_t()
|
| {
|
| }
|
|
|
| range_select(range_select% _Right)
|
| : _Mybase_t(_Right)
|
| {
|
| }
|
|
|
| range_select% operator=(range_select% _Right)
|
| {
|
| _Mybase_t::operator=(_Right);
|
| return (*this);
|
| }
|
|
|
|
|
| range_select(_Iter_t _First, _Iter_t _Last)
|
| : _Mybase_t(_First, _Last)
|
| {
|
| }
|
| };
|
| }
|
|
|
|
|
|
|
|
|
| template<typename _Iter_t>
|
| ref class range_adapter
|
| : public impl::range_select<
|
| _Iter_t,
|
| typename iterator_traits<_Iter_t>::value_type,
|
| __is_ref_class(typename _Dehandle<
|
| typename iterator_traits<_Iter_t>::value_type>::type)
|
| && !is_handle<
|
| typename iterator_traits<_Iter_t>::value_type>::value>
|
| {
|
| public:
|
|
|
| typedef range_adapter<_Iter_t> _Mytype_t;
|
| typedef typename iterator_traits<_Iter_t>::value_type _Value_t;
|
| typedef impl::range_select<
|
| _Iter_t,
|
| _Value_t,
|
| __is_ref_class(typename _Dehandle<_Value_t>::type)
|
| && !is_handle<_Value_t>::value> _Mybase_t;
|
|
|
|
|
| range_adapter()
|
| : _Mybase_t()
|
| {
|
| }
|
|
|
| range_adapter(range_adapter% _Right)
|
| : _Mybase_t(_Right)
|
| {
|
| }
|
|
|
| range_adapter(range_adapter^ _Right)
|
| : _Mybase_t(*_Right)
|
| {
|
| }
|
|
|
| range_adapter% operator=(range_adapter% _Right)
|
| {
|
| _Mybase_t::operator=(_Right);
|
| return (*this);
|
| }
|
|
|
| range_adapter% operator=(range_adapter^ _Right)
|
| {
|
| _Mybase_t::operator=(*_Right);
|
| return (*this);
|
| }
|
|
|
|
|
| range_adapter(_Iter_t _First, _Iter_t _Last)
|
| : _Mybase_t(_First, _Last)
|
| {
|
| }
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Iter_t> inline
|
| range_adapter<_Iter_t>^ make_collection(_Iter_t _First, _Iter_t _Last)
|
| {
|
| return (gcnew range_adapter<_Iter_t>(_First, _Last));
|
| }
|
| }
|
| #endif
|
|
|