lib/base/eptrlist.h: fix tabs
[vuplus_dvbapp] / lib / base / eptrlist.h
index ae61d78..0da46da 100644 (file)
@@ -3,7 +3,9 @@
 
 #include <list>
 #include <vector>
 
 #include <list>
 #include <vector>
+#include <algorithm>
 #include <lib/base/smartptr.h>
 #include <lib/base/smartptr.h>
+#include <lib/base/eerror.h>
 
 template <class T>
 class ePtrList : public std::list<T*>
 
 template <class T>
 class ePtrList : public std::list<T*>
@@ -56,63 +58,63 @@ public:
        inline const T* last() const;
 
 // added operator methods
        inline const T* last() const;
 
 // added operator methods
-       inline operator bool();
-       inline bool operator!();
+       inline operator bool() const;
+       inline bool operator!() const;
 
 // added compare struct ... to sort
        struct less;
 private:
        iterator cur;
 public:
 
 // added compare struct ... to sort
        struct less;
 private:
        iterator cur;
 public:
-       iterator ePtrList<T>::begin()
+       iterator begin()
        {                               
        //      makes implicit type conversion form std::list::iterator to ePtrList::iterator
                return std::list<T*>::begin();          
        }
 
        {                               
        //      makes implicit type conversion form std::list::iterator to ePtrList::iterator
                return std::list<T*>::begin();          
        }
 
-       iterator ePtrList<T>::end()
+       iterator end()
        {                               
        //      makes implicit type conversion form std::list::iterator to ePtrList::iterator
                return std::list<T*>::end();            
        }
 
        {                               
        //      makes implicit type conversion form std::list::iterator to ePtrList::iterator
                return std::list<T*>::end();            
        }
 
-       const_iterator ePtrList<T>::begin() const
+       const_iterator begin() const
        {                               
        //      makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
                return std::list<T*>::begin();          
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
                return std::list<T*>::begin();          
        }
 
-       const_iterator ePtrList<T>::end() const
+       const_iterator end() const
        {                               
        //      makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
                return std::list<T*>::end();            
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_iterator to ePtrList::const_iterator
                return std::list<T*>::end();            
        }
 
-       reverse_iterator ePtrList<T>::rbegin()
+       reverse_iterator rbegin()
        {                               
        //      makes implicit type conversion form std::list::reverse:_iterator to ePtrList::reverse_iterator
                return std::list<T*>::rbegin();         
        }
 
        {                               
        //      makes implicit type conversion form std::list::reverse:_iterator to ePtrList::reverse_iterator
                return std::list<T*>::rbegin();         
        }
 
-       reverse_iterator ePtrList<T>::rend()
+       reverse_iterator rend()
        {                               
        //      makes implicit type conversion form std::list::reverse_iterator to ePtrList::reverse_iterator
                return std::list<T*>::rend();           
        }
 
        {                               
        //      makes implicit type conversion form std::list::reverse_iterator to ePtrList::reverse_iterator
                return std::list<T*>::rend();           
        }
 
-       const_reverse_iterator ePtrList<T>::rbegin() const
+       const_reverse_iterator rbegin() const
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
                return std::list<T*>::rbegin();         
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
                return std::list<T*>::rbegin();         
        }
 
-       const_reverse_iterator ePtrList<T>::rend() const
+       const_reverse_iterator rend() const
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
                return std::list<T*>::rend();           
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to ePtrList::const_reverse_iterator
                return std::list<T*>::rend();           
        }
 
-       iterator ePtrList<T>::erase(iterator it)
+       iterator erase(iterator it)
        {
        //      Remove the item it, if auto-deletion is enabled, than the list call delete for this item
        //  If current is equal to the item that was removed, current is set to the next item in the list
        {
        //      Remove the item it, if auto-deletion is enabled, than the list call delete for this item
        //  If current is equal to the item that was removed, current is set to the next item in the list
@@ -122,7 +124,7 @@ public:
                        return std::list<T*>::erase(it);
        }
 
                        return std::list<T*>::erase(it);
        }
 
-       iterator ePtrList<T>::erase(iterator from, iterator to)
+       iterator erase(iterator from, iterator to)
        {
        //      Remove all items between the to iterators from and to
        //      If auto-deletion is enabled, than the list call delete for all removed items
        {
        //      Remove all items between the to iterators from and to
        //      If auto-deletion is enabled, than the list call delete for all removed items
@@ -161,8 +163,8 @@ public:
                // Creates an vector and copys all elements to this vector
                // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
                std::vector<T>* v=new std::vector<T>();
                // Creates an vector and copys all elements to this vector
                // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
                std::vector<T>* v=new std::vector<T>();
-               v->reserve( size() );
-    for ( std_list_T_iterator it( std::list<T*>::begin() ); it != std::list<T*>::end(); it++)
+               v->reserve( std::list<T>::size() );
+               for ( std_list_T_iterator it( std::list<T*>::begin() ); it != std::list<T*>::end(); it++)
                        v->push_back( **it );
 
                return v;
                        v->push_back( **it );
 
                return v;
@@ -172,7 +174,7 @@ public:
        {
                // added a new item to the list... in order
                // returns a iterator to the new item
        {
                // added a new item to the list... in order
                // returns a iterator to the new item
-               return insert( std::lower_bound( std::list<T*>::begin(), std::list<T*>::end(), e ), e );
+               return insert( std::lower_bound( std::list<T*>::begin(), std::list<T*>::end(), e, less()), e );
        }
 
 };
        }
 
 };
@@ -392,7 +394,7 @@ inline void ePtrList<T>::sort()
 {              
 //     Sorts all items in the list.
 //     The type T must have a operator <.
 {              
 //     Sorts all items in the list.
 //     The type T must have a operator <.
-       std::list<T*>::sort(ePtrList<T>::less());
+       std::list<T*>::sort(typename ePtrList<T>::less());
 }      
 
 /////////////////// ePtrList remove(T*) /////////////////////////
 }      
 
 /////////////////// ePtrList remove(T*) /////////////////////////
@@ -621,17 +623,17 @@ struct ePtrList<T>::less
 
 /////////////////// ePtrList operator bool ////////////////////
 template <class T>
 
 /////////////////// ePtrList operator bool ////////////////////
 template <class T>
-ePtrList<T>::operator bool()   
+ePtrList<T>::operator bool() const
 {
 //     Returns a bool that contains true, when the list is NOT empty otherwise false
 {
 //     Returns a bool that contains true, when the list is NOT empty otherwise false
-       return !empty();        
+       return !std::list<T*>::empty(); 
 }
 
 template <class T>
 }
 
 template <class T>
-bool ePtrList<T>::operator!()  
+bool ePtrList<T>::operator!() const
 {
 //     Returns a bool that contains true, when the list is empty otherwise false
 {
 //     Returns a bool that contains true, when the list is empty otherwise false
-       return empty(); 
+       return std::list<T*>::empty();  
 }
 
 template <class T>
 }
 
 template <class T>
@@ -685,63 +687,63 @@ public:
        inline const T* last() const;
 
 // added operator methods
        inline const T* last() const;
 
 // added operator methods
-       inline operator bool();
-       inline bool operator!();
+       inline operator bool() const;
+       inline bool operator!() const;
 
 // added compare struct ... to sort
        struct less;
 private:
        iterator cur;
 public:
 
 // added compare struct ... to sort
        struct less;
 private:
        iterator cur;
 public:
-       iterator eSmartPtrList<T>::begin()
+       iterator begin()
        {                               
        //      makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
                return std::list<ePtr<T> >::begin();            
        }
 
        {                               
        //      makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
                return std::list<ePtr<T> >::begin();            
        }
 
-       iterator eSmartPtrList<T>::end()
+       iterator end()
        {                               
        //      makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
                return std::list<ePtr<T> >::end();              
        }
 
        {                               
        //      makes implicit type conversion form std::list::iterator to eSmartPtrList::iterator
                return std::list<ePtr<T> >::end();              
        }
 
-       const_iterator eSmartPtrList<T>::begin() const
+       const_iterator begin() const
        {                               
        //      makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
                return std::list<ePtr<T> >::begin();            
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
                return std::list<ePtr<T> >::begin();            
        }
 
-       const_iterator eSmartPtrList<T>::end() const
+       const_iterator end() const
        {                               
        //      makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
                return std::list<ePtr<T> >::end();              
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_iterator to eSmartPtrList::const_iterator
                return std::list<ePtr<T> >::end();              
        }
 
-       reverse_iterator eSmartPtrList<T>::rbegin()
+       reverse_iterator rbegin()
        {                               
        //      makes implicit type conversion form std::list::reverse:_iterator to eSmartPtrList::reverse_iterator
                return std::list<ePtr<T> >::rbegin();           
        }
 
        {                               
        //      makes implicit type conversion form std::list::reverse:_iterator to eSmartPtrList::reverse_iterator
                return std::list<ePtr<T> >::rbegin();           
        }
 
-       reverse_iterator eSmartPtrList<T>::rend()
+       reverse_iterator rend()
        {                               
        //      makes implicit type conversion form std::list::reverse_iterator to eSmartPtrList::reverse_iterator
                return std::list<ePtr<T> >::rend();             
        }
 
        {                               
        //      makes implicit type conversion form std::list::reverse_iterator to eSmartPtrList::reverse_iterator
                return std::list<ePtr<T> >::rend();             
        }
 
-       const_reverse_iterator eSmartPtrList<T>::rbegin() const
+       const_reverse_iterator rbegin() const
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
                return std::list<ePtr<T> >::rbegin();           
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
                return std::list<ePtr<T> >::rbegin();           
        }
 
-       const_reverse_iterator eSmartPtrList<T>::rend() const
+       const_reverse_iterator rend() const
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
                return std::list<ePtr<T> >::rend();             
        }
 
        {                               
        //      makes implicit type conversion form std::list::const_reverse_iterator to eSmartPtrList::const_reverse_iterator
                return std::list<ePtr<T> >::rend();             
        }
 
-       iterator eSmartPtrList<T>::erase(iterator it)
+       iterator erase(iterator it)
        {
        //      Remove the item it, if auto-deletion is enabled, than the list call delete for this item
        //  If current is equal to the item that was removed, current is set to the next item in the list
        {
        //      Remove the item it, if auto-deletion is enabled, than the list call delete for this item
        //  If current is equal to the item that was removed, current is set to the next item in the list
@@ -752,7 +754,7 @@ public:
                        return std::list<ePtr<T> >::erase(it);
        }
 
                        return std::list<ePtr<T> >::erase(it);
        }
 
-       iterator eSmartPtrList<T>::erase(iterator from, iterator to)
+       iterator erase(iterator from, iterator to)
        {
        //      Remove all items between the to iterators from and to
        //      If auto-deletion is enabled, than the list call delete for all removed items
        {
        //      Remove all items between the to iterators from and to
        //      If auto-deletion is enabled, than the list call delete for all removed items
@@ -791,7 +793,7 @@ public:
                // Creates an vector and copys all elements to this vector
                // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
                std::vector<T>* v=new std::vector<T>();
                // Creates an vector and copys all elements to this vector
                // returns a pointer to this new vector ( the reserved memory must deletet from the receiver !! )
                std::vector<T>* v=new std::vector<T>();
-               v->reserve( size() );
+               v->reserve( std::list<T>::size() );
     for ( std_list_T_iterator it( std::list<ePtr<T> >::begin() ); it != std::list<ePtr<T> >::end(); it++)
                        v->push_back( **it );
 
     for ( std_list_T_iterator it( std::list<ePtr<T> >::begin() ); it != std::list<ePtr<T> >::end(); it++)
                        v->push_back( **it );
 
@@ -802,7 +804,7 @@ public:
        {
                // added a new item to the list... in order
                // returns a iterator to the new item
        {
                // added a new item to the list... in order
                // returns a iterator to the new item
-               return insert( std::lower_bound( std::list<ePtr<T> >::begin(), std::list<ePtr<T> >::end(), e ), e );
+               return insert( std::lower_bound( std::list<ePtr<T> >::begin(), e, std::list<ePtr<T> >::end()), e );
        }
 
 };
        }
 
 };
@@ -1100,27 +1102,6 @@ inline void eSmartPtrList<T>::push_front(T* x)
        first();        
 }
 
        first();        
 }
 
-/////////////////// eSmartPtrList take() ////////////////////
-//template <class T>
-//inline T* eSmartPtrList<T>::take()
-//{
-//// Takes the current item out of the list without deleting it (even if auto-deletion is enabled).
-//// Returns a pointer to the item taken out of the list, or null if the index is out of range.
-//// The item after the taken item becomes the new current list item if the taken item is not the last item in the list. If the last item is taken, the new last item becomes the current item.
-//// The current item is set to null if the list becomes empty.
-//     T* tmp = *cur;
-//     cur = std::list<T*>::erase(cur);
-//     return tmp;
-//}
-
-/////////////////// eSmartPtrList take(T*) ////////////////////
-//template <class T>
-//inline void eSmartPtrList<T>::take(T* t)
-//{
-//// Takes all item with T* out of the list without deleting it (even if auto-deletion is enabled).
-//     std::list<T*>::remove(t);
-//}
-
 /////////////////// eSmartPtrList setCurrent(T*) ////////////////////
 template <class T>
 inline T* eSmartPtrList<T>::setCurrent(const T* t)
 /////////////////// eSmartPtrList setCurrent(T*) ////////////////////
 template <class T>
 inline T* eSmartPtrList<T>::setCurrent(const T* t)
@@ -1252,17 +1233,17 @@ struct eSmartPtrList<T>::less
 
 /////////////////// eSmartPtrList operator bool ////////////////////
 template <class T>
 
 /////////////////// eSmartPtrList operator bool ////////////////////
 template <class T>
-eSmartPtrList<T>::operator bool()      
+eSmartPtrList<T>::operator bool() const
 {
 //     Returns a bool that contains true, when the list is NOT empty otherwise false
 {
 //     Returns a bool that contains true, when the list is NOT empty otherwise false
-       return !empty();        
+       return !std::list<T>::empty();  
 }
 
 template <class T>
 }
 
 template <class T>
-bool eSmartPtrList<T>::operator!()     
+bool eSmartPtrList<T>::operator!() const
 {
 //     Returns a bool that contains true, when the list is empty otherwise false
 {
 //     Returns a bool that contains true, when the list is empty otherwise false
-       return empty(); 
+       return std::list<T>::empty();   
 }
 
 #endif // _E_PTRLIST
 }
 
 #endif // _E_PTRLIST