LCOV - code coverage report
Current view: top level - libreoffice/ucb/source/inc - regexpmap.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 8 12 66.7 %
Date: 2012-12-17 Functions: 8 12 66.7 %
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             : 
      20             : #ifndef _UCB_REGEXPMAP_HXX_
      21             : #define _UCB_REGEXPMAP_HXX_
      22             : 
      23             : #include <rtl/ustring.hxx>
      24             : #include <sal/types.h>
      25             : 
      26             : namespace ucb_impl {
      27             : 
      28             : template< typename Val > class RegexpMap;
      29             : template< typename Val > class RegexpMapIter;
      30             : 
      31             : //============================================================================
      32             : template< typename Val >
      33        5496 : class RegexpMapEntry
      34             : {
      35             : public:
      36        3754 :     inline RegexpMapEntry(rtl::OUString const & rTheRegexp,
      37             :                           Val * pTheValue):
      38        3754 :         m_aRegexp(rTheRegexp), m_pValue(pTheValue) {}
      39             : 
      40           0 :     rtl::OUString getRegexp() const { return m_aRegexp; }
      41             : 
      42           0 :     Val const & getValue() const { return *m_pValue; }
      43             : 
      44         736 :     Val & getValue() { return *m_pValue; }
      45             : 
      46             : private:
      47             :     rtl::OUString m_aRegexp;
      48             :     Val * m_pValue;
      49             : };
      50             : 
      51             : //============================================================================
      52             : template< typename Val > class RegexpMapIterImpl;
      53             :     // MSC doesn't like this to be a private RegexpMapConstIter member
      54             :     // class...
      55             : 
      56             : template< typename Val >
      57             : class RegexpMapConstIter
      58             : {
      59             :     friend class RegexpMap< Val >; // to access m_pImpl, ctor
      60             :     friend class RegexpMapIter< Val >; // to access m_pImpl, ctor
      61             : 
      62             : public:
      63             :     RegexpMapConstIter();
      64             : 
      65             :     RegexpMapConstIter(RegexpMapConstIter const & rOther);
      66             : 
      67             :     ~RegexpMapConstIter();
      68             : 
      69             :     RegexpMapConstIter & operator =(RegexpMapConstIter const & rOther);
      70             : 
      71             :     RegexpMapConstIter & operator ++();
      72             : 
      73             :     RegexpMapConstIter operator ++(int);
      74             : 
      75             :     RegexpMapEntry< Val > const & operator *() const;
      76             : 
      77             :     RegexpMapEntry< Val > const * operator ->() const;
      78             : 
      79             :     bool equals(RegexpMapConstIter const & rOther) const;
      80             :         // for free operator ==(), operator !=()
      81             : 
      82             : private:
      83             :     RegexpMapIterImpl< Val > * m_pImpl;
      84             : 
      85             :     RegexpMapConstIter(RegexpMapIterImpl< Val > * pTheImpl);
      86             : };
      87             : 
      88             : //============================================================================
      89             : template< typename Val >
      90        4024 : class RegexpMapIter: public RegexpMapConstIter< Val >
      91             : {
      92             :     friend class RegexpMap< Val >; // to access ctor
      93             : 
      94             : public:
      95        1006 :     RegexpMapIter() {}
      96             : 
      97             :     RegexpMapIter & operator ++();
      98             : 
      99             :     RegexpMapIter operator ++(int);
     100             : 
     101             :     RegexpMapEntry< Val > & operator *();
     102             : 
     103             :     RegexpMapEntry< Val > const & operator *() const;
     104             : 
     105             :     RegexpMapEntry< Val > * operator ->();
     106             : 
     107             :     RegexpMapEntry< Val > const * operator ->() const;
     108             : 
     109             : private:
     110             :     RegexpMapIter(RegexpMapIterImpl< Val > * pTheImpl);
     111             : };
     112             : 
     113             : //============================================================================
     114             : template< typename Val > struct RegexpMapImpl;
     115             :     // MSC doesn't like this to be a RegexpMap member class...
     116             : 
     117             : template< typename Val >
     118             : class RegexpMap
     119             : {
     120             : public:
     121             :     typedef sal_uInt32 size_type;
     122             :     typedef RegexpMapIter< Val > iterator;
     123             :     typedef RegexpMapConstIter< Val > const_iterator;
     124             : 
     125             :     RegexpMap();
     126             : 
     127             :     RegexpMap(RegexpMap const & rOther);
     128             : 
     129             :     ~RegexpMap();
     130             : 
     131             :     RegexpMap & operator =(RegexpMap const & rOther);
     132             : 
     133             :     bool add(rtl::OUString const & rKey, Val const & rValue, bool bOverwrite,
     134             :              rtl::OUString * pReverse = 0);
     135             :         // throws com::sun::star::lang::IllegalArgumentException
     136             : 
     137             :     iterator find(rtl::OUString const & rKey, rtl::OUString * pReverse = 0);
     138             :         // throws com::sun::star::lang::IllegalArgumentException
     139             : 
     140             :     void erase(iterator const & rPos);
     141             : 
     142             :     iterator begin();
     143             : 
     144             :     const_iterator begin() const;
     145             : 
     146             :     iterator end();
     147             : 
     148             :     const_iterator end() const;
     149             : 
     150             :     bool empty() const;
     151             : 
     152             :     size_type size() const;
     153             : 
     154             :     Val const * map(rtl::OUString const & rString,
     155             :                     rtl::OUString * pTranslation = 0, bool * pTranslated = 0)
     156             :         const;
     157             : 
     158             : private:
     159             :     RegexpMapImpl< Val > * m_pImpl;
     160             : };
     161             : 
     162             : }
     163             : 
     164             : //============================================================================
     165             : template< typename Val >
     166        1006 : inline bool operator ==(ucb_impl::RegexpMapConstIter< Val > const & rIter1,
     167             :                         ucb_impl::RegexpMapConstIter< Val > const & rIter2)
     168             : {
     169        1006 :     return rIter1.equals(rIter2);
     170             : }
     171             : 
     172             : template< typename Val >
     173           0 : inline bool operator !=(ucb_impl::RegexpMapConstIter< Val > const & rIter1,
     174             :                         ucb_impl::RegexpMapConstIter< Val > const & rIter2)
     175             : {
     176           0 :     return !rIter1.equals(rIter2);
     177             : }
     178             : 
     179             : #endif // _UCB_REGEXPMAP_HXX_
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10