LCOV - code coverage report
Current view: top level - include/tools - unqidx.hxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 11 0.0 %
Date: 2014-04-14 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : #ifndef INCLUDED_TOOLS_UNQIDX_HXX
      20             : #define INCLUDED_TOOLS_UNQIDX_HXX
      21             : 
      22             : #include <tools/toolsdllapi.h>
      23             : #include <tools/contnr.hxx>
      24             : #include <map>
      25             : 
      26             : #define UNIQUEINDEX_ENTRY_NOTFOUND   CONTAINER_ENTRY_NOTFOUND
      27             : 
      28           0 : class TOOLS_DLLPUBLIC SAL_WARN_UNUSED UniqueIndexImpl : public std::map<sal_uInt32, void*>
      29             : {
      30             : private:
      31             :     sal_uIntPtr   nStartIndex;
      32             :     sal_uIntPtr   nUniqIndex;
      33             :     sal_uIntPtr   nCount;
      34             : 
      35             : public:
      36           0 :     UniqueIndexImpl( sal_uIntPtr _nStartIndex = 0 )
      37             :         : std::map<sal_uInt32, void*>(),
      38           0 :           nStartIndex(_nStartIndex), nUniqIndex(_nStartIndex), nCount(0) {}
      39             : 
      40             :     sal_uIntPtr   Insert( void* p );
      41             :     // insert value with key, replacing existing entry if necessary
      42             :     void          Insert( sal_uIntPtr aIndex, void* p );
      43             :     void*         Remove( sal_uIntPtr aIndex );
      44             :     void*         Get( sal_uIntPtr aIndex ) const;
      45             : 
      46             :     sal_uIntPtr   GetIndexOf( void* p ) const;
      47             :     sal_uIntPtr   FirstIndex() const;
      48             :     sal_uIntPtr   LastIndex() const;
      49             :     sal_uIntPtr   NextIndex( sal_uIntPtr aCurrIndex ) const;
      50             : };
      51             : 
      52             : template<typename T>
      53           0 : class UniqueIndex : private UniqueIndexImpl
      54             : {
      55             : public:
      56           0 :     UniqueIndex<T>( sal_uIntPtr _nStartIndex = 0 ) : UniqueIndexImpl(_nStartIndex) {}
      57             : 
      58           0 :     sal_uIntPtr Insert(T* p) { return UniqueIndexImpl::Insert(p); }
      59           0 :     void        Insert(sal_uIntPtr aIdx, T* p) { return UniqueIndexImpl::Insert(aIdx, p); }
      60           0 :     T*          Get(sal_uIntPtr idx) const { return static_cast<T*>( UniqueIndexImpl::Get(idx) ); }
      61           0 :     T*          Remove(sal_uIntPtr idx) { return static_cast<T*>( UniqueIndexImpl::Remove(idx) ); }
      62           0 :     sal_uIntPtr Count() const { return UniqueIndexImpl::size(); }
      63           0 :     sal_uIntPtr GetIndexOf(T* p) const { return UniqueIndexImpl::GetIndexOf(p); }
      64             : 
      65             :     using UniqueIndexImpl::FirstIndex;
      66             :     using UniqueIndexImpl::LastIndex;
      67             :     using UniqueIndexImpl::NextIndex;
      68             : };
      69             : 
      70             : #endif
      71             : 
      72             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10