diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-05 03:54:55 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2014-12-05 16:10:34 +0100 |
commit | d150ace12b6d8fbb30664d1de1001622720bd53b (patch) | |
tree | f999bf8d1766cf787e1fd64876dd7179e8d228d6 /sw | |
parent | d011686765eb13740e8fd821b579836d0c117e02 (diff) |
stick to code conventions for new code
Change-Id: I596733f76a16c01f85d1cae5f130e6ef59fe137a
Diffstat (limited to 'sw')
-rw-r--r-- | sw/inc/ring.hxx | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/sw/inc/ring.hxx b/sw/inc/ring.hxx index c1a51799dee5..b2c341e305ce 100644 --- a/sw/inc/ring.hxx +++ b/sw/inc/ring.hxx @@ -29,22 +29,21 @@ namespace sw { - template <class T> class RingContainer; - template <class T> class RingIterator; + template <typename value_type> class RingContainer; + template <typename value_type> class RingIterator; /** * An intrusive container class double linking the contained nodes * @example sw/qa/core/uwriter.cxx */ - template <class T> + template <typename value_type> class Ring { public: - typedef T value_type; - typedef typename std::add_const<T>::type const_value_type; - typedef RingContainer<T> ring_container; + typedef typename std::add_const<value_type>::type const_value_type; + typedef RingContainer<value_type> ring_container; typedef RingContainer< const_value_type > const_ring_container; virtual ~Ring() - { algo::unlink(static_cast< T* >(this)); }; + { algo::unlink(static_cast< value_type* >(this)); }; /** * Removes this item from its current ring container and adds it to * another ring container. If the item was not alone in the original @@ -53,24 +52,24 @@ namespace sw * Note: the newly created item will be inserted just before item pDestRing. * @param pDestRing the container to add this item to */ - void MoveTo( T* pDestRing ); + void MoveTo( value_type* pDestRing ); /** * Merges two ring containers. All item from both ring containers will * be in the same ring container in the end. - * Note: The items of this ring container will be inserted just before + * Note: value_typehe items of this ring container will be inserted just before * item pDestRing * @param pDestRing the container to merge this container with */ - void MoveRingTo( T* pDestRing ) + void MoveRingTo( value_type* pDestRing ) { std::swap(*(&pPrev->pNext), *(&pDestRing->pPrev->pNext)); std::swap(*(&pPrev), *(&pDestRing->pPrev)); } /** @return the next item in the ring container */ - T* GetNext() const + value_type* GetNext() const { return pNext; } /** @return the previous item in the ring container */ - T* GetPrev() const + value_type* GetPrev() const { return pPrev; } /** @return a stl-like container with begin()/end() for iteration */ ring_container GetRingContainer(); @@ -84,22 +83,22 @@ namespace sw * are alone in one. */ Ring() - : pPrev(static_cast< T* >(this)) - { algo::init_header(static_cast< T* >(this)); } + : pPrev(static_cast< value_type* >(this)) + { algo::init_header(static_cast< value_type* >(this)); } /** * Creates a new item and add it to an existing ring container. * Note: the newly created item will be inserted just before item pRing. * @param pRing ring container to add the created item to */ - Ring( T* pRing ); + Ring( value_type* pRing ); private: /** internal implementation class -- not for external use */ struct Ring_node_traits { - typedef T node; - typedef T* node_ptr; - typedef const T* const_node_ptr; + typedef value_type node; + typedef value_type* node_ptr; + typedef const value_type* const_node_ptr; static node_ptr get_next(const_node_ptr n) { return n->GetNext(); }; static void set_next(node_ptr n, node_ptr next) { n->pNext = next; }; static node_ptr get_previous(const_node_ptr n) { return n->GetPrev(); }; @@ -111,25 +110,25 @@ namespace sw friend typename const_ring_container::const_iterator; friend class boost::iterator_core_access; typedef boost::intrusive::circular_list_algorithms<Ring_node_traits> algo; - T* pNext; - T* pPrev; + value_type* pNext; + value_type* pPrev; }; - template <class T> - inline Ring<T>::Ring( T* pObj ) - : pPrev(static_cast< T* >(this)) + template <typename value_type> + inline Ring<value_type>::Ring( value_type* pObj ) + : pPrev(static_cast< value_type* >(this)) { - T* pThis = static_cast< T* >(this); + value_type* pThis = static_cast< value_type* >(this); if( !pObj ) algo::init_header(pThis); else algo::link_before(pObj, pThis); } - template <class T> - inline void Ring<T>::MoveTo(T* pDestRing) + template <typename value_type> + inline void Ring<value_type>::MoveTo(value_type* pDestRing) { - T* pThis = static_cast< T* >(this); + value_type* pThis = static_cast< value_type* >(this); // insert into "new" if( pDestRing ) { @@ -143,19 +142,19 @@ namespace sw } /** - * helper class that provides STL-style container iteration to the ring + * helper class that provides Svalue_typeL-style container iteration to the ring */ - template <class T> + template <typename value_type> class RingContainer SAL_FINAL { private: /** the item in the ring where iteration starts */ - T* m_pStart; + value_type* m_pStart; public: - RingContainer( T* pRing ) : m_pStart(pRing) {}; - typedef RingIterator<T> iterator; - typedef RingIterator<const T> const_iterator; + RingContainer( value_type* pRing ) : m_pStart(pRing) {}; + typedef RingIterator<value_type> iterator; + typedef RingIterator<const value_type> const_iterator; /** * iterator access * @code @@ -172,22 +171,23 @@ namespace sw { return std::distance(begin(), end()); } }; - template <class T> + template <typename value_type> class RingIterator SAL_FINAL : public boost::iterator_facade< - RingIterator<T> - , T + RingIterator<value_type> + , value_type , boost::forward_traversal_tag > { - typedef typename std::remove_const<T>::type Tnonconst; + private: + typedef typename std::remove_const<value_type>::type nonconst_value_type; public: RingIterator() : m_pCurrent(nullptr) , m_pStart(nullptr) {} - explicit RingIterator(T* pRing, bool bStart = true) + explicit RingIterator(value_type* pRing, bool bStart = true) : m_pCurrent(nullptr) - , m_pStart(const_cast<Tnonconst*>(pRing)) + , m_pStart(const_cast<nonconst_value_type*>(pRing)) { if(!bStart) m_pCurrent = m_pStart; @@ -204,42 +204,42 @@ namespace sw assert(m_pStart == other.m_pStart); return m_pCurrent == other.m_pCurrent; } - T& dereference() const + value_type& dereference() const { return m_pCurrent ? *m_pCurrent : * m_pStart; } /** - * This is: + * value_typehis is: * - pointing to the current item in the iteration in general * - nullptr if on the first item (begin()) * - m_pStart when beyond the last item (end()) */ - Tnonconst* m_pCurrent; + nonconst_value_type* m_pCurrent; /** the first item of the iteration */ - Tnonconst* m_pStart; + nonconst_value_type* m_pStart; }; - template <class T> - inline typename Ring<T>::ring_container Ring<T>::GetRingContainer() - { return Ring<T>::ring_container(static_cast< T* >(this)); }; + template <typename value_type> + inline typename Ring<value_type>::ring_container Ring<value_type>::GetRingContainer() + { return Ring<value_type>::ring_container(static_cast< value_type* >(this)); }; - template <class T> - inline typename Ring<T>::const_ring_container Ring<T>::GetRingContainer() const - { return Ring<T>::const_ring_container(static_cast< const T* >(this)); }; + template <typename value_type> + inline typename Ring<value_type>::const_ring_container Ring<value_type>::GetRingContainer() const + { return Ring<value_type>::const_ring_container(static_cast< const value_type* >(this)); }; - template <class T> - inline typename RingContainer<T>::iterator RingContainer<T>::begin() - { return RingContainer<T>::iterator(m_pStart); }; + template <typename value_type> + inline typename RingContainer<value_type>::iterator RingContainer<value_type>::begin() + { return RingContainer<value_type>::iterator(m_pStart); }; - template <class T> - inline typename RingContainer<T>::iterator RingContainer<T>::end() - { return RingContainer<T>::iterator(m_pStart, false); }; + template <typename value_type> + inline typename RingContainer<value_type>::iterator RingContainer<value_type>::end() + { return RingContainer<value_type>::iterator(m_pStart, false); }; - template <class T> - inline typename RingContainer<T>::const_iterator RingContainer<T>::begin() const - { return RingContainer<T>::const_iterator(m_pStart); }; + template <typename value_type> + inline typename RingContainer<value_type>::const_iterator RingContainer<value_type>::begin() const + { return RingContainer<value_type>::const_iterator(m_pStart); }; - template <class T> - inline typename RingContainer<T>::const_iterator RingContainer<T>::end() const - { return RingContainer<T>::const_iterator(m_pStart, false); }; + template <typename value_type> + inline typename RingContainer<value_type>::const_iterator RingContainer<value_type>::end() const + { return RingContainer<value_type>::const_iterator(m_pStart, false); }; } #endif |