OSDN Git Service

any_iterator.hpp: 5
authorMyun2 <myun2@nwhite.info>
Sat, 18 Dec 2010 17:10:06 +0000 (02:10 +0900)
committerMyun2 <myun2@nwhite.info>
Sat, 18 Dec 2010 17:10:06 +0000 (02:10 +0900)
roast/include/roast/container/any_iterator.hpp

index e511120..49b2658 100644 (file)
@@ -32,6 +32,45 @@ namespace roast{
 
        /////////////////////////////////////////////////////////////////////
 
+       template <typename _ValueTypeRef, typename _Iterator>
+       class _attach_iterator_base : public virtual _iterator_base<_ValueTypeRef>//, public virtual _Iterator
+       {
+       protected:
+               _Iterator *m_pimpl;
+       public:
+               _attach_iterator_base(_Iterator* pimpl) : m_pimpl(pimpl){}
+
+               //      Next (Like iterator ++)
+               void next(){ m_pimpl->next(); }
+               
+               //      Iterator pointer iValid?
+               bool is_valid(){ return m_pimpl->is_valid(); }
+               
+               //      Value
+               _ValueTypeRef get_value_ref(){ return m_pimpl->get_value_ref(); }
+       };
+
+       template <typename _ValueTypeRef, typename _Iterator>
+       class _attach_iterator_base_release : public virtual _iterator_base<_ValueTypeRef>//, public virtual _Iterator
+       {
+       protected:
+               _Iterator *m_pimpl;
+       public:
+               _attach_iterator_base_release(_Iterator* pimpl) : m_pimpl(pimpl){}
+               virtual ~_attach_iterator_base_release() { delete pimpl; }
+
+               //      Next (Like iterator ++)
+               void next(){ m_pimpl->next(); }
+               
+               //      Iterator pointer iValid?
+               bool is_valid(){ return m_pimpl->is_valid(); }
+               
+               //      Value
+               _ValueTypeRef get_value_ref(){ return m_pimpl->get_value_ref(); }
+       };
+
+       /////////////////////////////////////////////////////////////////////
+
        template <typename _ValueTypeRef>
        class _any_iterator_impl
        {
@@ -76,6 +115,7 @@ namespace roast{
                        : _Base(_Impl(pimpl)) {}
        };
 
+       //      Alias
        template <typename _ValueTypeRef>
        class _iterator :
                public _iterator_adapter< _any_iterator_impl<_ValueTypeRef> >
@@ -92,17 +132,11 @@ namespace roast{
        ////////////////////////////////////////////////////////////////////////
 
        template <typename T>
-       _iterator<void> get_iterator(void*)
-       {
-               return _iterator<void>(NULL);
-       }
-
-       /////////////////
-
-       template <typename T>
-       _iterator<T> get_iterator< ::std::vector<T> >( ::std::vector<T>& ary )
+       _iterator<T> get_iterator( ::std::vector<T>& ary )
        {
-               m_ary = ary;
+               return _attach_iterator_base_release<T,
+                       _stllike_uni_iterator_to_roast_impl< ::std::vector<T> >
+                       >( new _stllike_uni_iterator_to_roast_impl< ::std::vector<T> >(ary) );
        }
 
        ////////////////////////////////////////////////////////////////////////