LCOV - code coverage report
Current view: top level - ucb/source/inc - regexpmap.tpt (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 138 153 90.2 %
Date: 2012-08-25 Functions: 39 39 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 90 163 55.2 %

           Branch data     Line data    Source code
       1                 :            : /*************************************************************************
       2                 :            :  *
       3                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       4                 :            :  * 
       5                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       6                 :            :  *
       7                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       8                 :            :  *
       9                 :            :  * This file is part of OpenOffice.org.
      10                 :            :  *
      11                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      12                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      13                 :            :  * only, as published by the Free Software Foundation.
      14                 :            :  *
      15                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      16                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      17                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      18                 :            :  * GNU Lesser General Public License version 3 for more details
      19                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      20                 :            :  *
      21                 :            :  * You should have received a copy of the GNU Lesser General Public License
      22                 :            :  * version 3 along with OpenOffice.org.  If not, see
      23                 :            :  * <http://www.openoffice.org/license.html>
      24                 :            :  * for a copy of the LGPLv3 License.
      25                 :            :  *
      26                 :            :  ************************************************************************/
      27                 :            : 
      28                 :            : #ifndef _UCB_REGEXPMAP_TPT_
      29                 :            : #define _UCB_REGEXPMAP_TPT_
      30                 :            : 
      31                 :            : #ifndef _UCB_REGEXPMAP_HXX_
      32                 :            : #include <regexpmap.hxx>
      33                 :            : #endif
      34                 :            : 
      35                 :            : #include <list>
      36                 :            : 
      37                 :            : #ifndef _RTL_USTRING_HXX_
      38                 :            : #include <rtl/ustring.hxx>
      39                 :            : #endif
      40                 :            : 
      41                 :            : #ifndef _UCB_REGEXP_HXX_
      42                 :            : #include "regexp.hxx"
      43                 :            : #endif
      44                 :            : 
      45                 :            : using namespace ucb_impl;
      46                 :            : 
      47                 :            : namespace ucb_impl {
      48                 :            : 
      49                 :            : //============================================================================
      50                 :            : 
      51                 :            : template< typename Val >
      52         [ +  - ]:      11019 : struct Entry
      53                 :            : {
      54                 :            :         Regexp m_aRegexp;
      55                 :            :         Val m_aValue;
      56                 :            : 
      57                 :       3715 :         inline Entry(Regexp const & rTheRegexp, Val const & rTheValue):
      58         [ +  - ]:       3715 :                 m_aRegexp(rTheRegexp), m_aValue(rTheValue) {}
      59                 :            : };
      60                 :            : 
      61                 :            : //============================================================================
      62                 :       1500 : template< typename Val > class List: public std::list< Entry< Val > > {};
      63                 :            : 
      64                 :            : //============================================================================
      65                 :            : //
      66                 :            : //  RegexpMapIterImpl
      67                 :            : //
      68                 :            : //============================================================================
      69                 :            : 
      70                 :            : template< typename Val >
      71                 :      13905 : class RegexpMapIterImpl
      72                 :            : {
      73                 :            : public:
      74                 :            :         typedef RegexpMapImpl< Val > MapImpl;
      75                 :            :         typedef typename List< Val >::iterator ListIterator;
      76                 :            : 
      77                 :            :         // Solaris needs these for the ctor...
      78                 :            : 
      79                 :            :         inline RegexpMapIterImpl();
      80                 :            : 
      81                 :            :         inline RegexpMapIterImpl(MapImpl * pTheMap, int nTheList,
      82                 :            :                                                          ListIterator aTheIndex);
      83                 :            : 
      84                 :            :         RegexpMapIterImpl(RegexpMapImpl< Val > * pTheMap, bool bBegin);
      85                 :            : 
      86                 :            :         RegexpMapIterImpl(RegexpMapIterImpl const & rOther);
      87                 :            : 
      88                 :            :         RegexpMapIterImpl & operator =(RegexpMapIterImpl const & rOther);
      89                 :            : 
      90                 :            :         bool operator ==(RegexpMapIterImpl const & rOther) const;
      91                 :            : 
      92                 :          2 :         RegexpMapImpl< Val > const * getMap() const { return m_pMap; }
      93                 :            : 
      94                 :          4 :         int getList() const { return m_nList; }
      95                 :            : 
      96                 :          2 :         typename List< Val >::iterator const & getIndex() const { return m_aIndex; }
      97                 :            : 
      98                 :            :         void next();
      99                 :            : 
     100                 :            :         RegexpMapEntry< Val > & get();
     101                 :            : 
     102                 :            : private:
     103                 :            :         mutable RegexpMapEntry< Val > m_aEntry;
     104                 :            :         typename List< Val >::iterator m_aIndex;
     105                 :            :         RegexpMapImpl< Val > * m_pMap;
     106                 :            :         int m_nList;
     107                 :            :         mutable bool m_bEntrySet;
     108                 :            : 
     109                 :            :         void setEntry() const;
     110                 :            : };
     111                 :            : 
     112                 :            : }
     113                 :            : 
     114                 :            : template< typename Val >
     115                 :       4627 : inline RegexpMapIterImpl< Val >::RegexpMapIterImpl():
     116                 :            :         m_aEntry(rtl::OUString(), 0),
     117                 :            :         m_pMap(0),
     118                 :            :         m_nList(-1),
     119                 :       4627 :         m_bEntrySet(false)
     120                 :       4627 : {}
     121                 :            : 
     122                 :            : template< typename Val >
     123                 :        912 : inline RegexpMapIterImpl< Val >::RegexpMapIterImpl(MapImpl * pTheMap,
     124                 :            :                                                                                                    int nTheList,
     125                 :            :                                                                                                    ListIterator aTheIndex):
     126                 :            :         m_aEntry(rtl::OUString(), 0),
     127                 :            :         m_aIndex(aTheIndex),
     128                 :            :         m_pMap(pTheMap),
     129                 :            :         m_nList(nTheList),
     130                 :        912 :         m_bEntrySet(false)
     131                 :        912 : {}
     132                 :            : 
     133                 :            : //============================================================================
     134                 :            : template< typename Val >
     135                 :       1098 : void RegexpMapIterImpl< Val >::setEntry() const
     136                 :            : {
     137         [ +  + ]:       1098 :         if (!m_bEntrySet)
     138                 :            :         {
     139                 :            :                 Entry< Val > const & rTheEntry
     140         [ -  + ]:       1004 :                         = m_nList == -1 ? *m_pMap->m_pDefault : *m_aIndex;
     141                 :       1004 :                 m_aEntry
     142                 :            :                         = RegexpMapEntry< Val >(rTheEntry.m_aRegexp.getRegexp(false),
     143                 :            :                                                                         const_cast< Val * >(&rTheEntry.m_aValue));
     144                 :       1004 :                 m_bEntrySet = true;
     145                 :            :         }
     146                 :       1098 : }
     147                 :            : 
     148                 :            : //============================================================================
     149                 :            : template< typename Val >
     150                 :       8354 : RegexpMapIterImpl< Val >::RegexpMapIterImpl(RegexpMapImpl< Val > * pTheMap,
     151                 :            :                                                                                         bool bBegin):
     152                 :            :         m_aEntry(rtl::OUString(), 0),
     153                 :            :         m_pMap(pTheMap),
     154                 :       8354 :         m_bEntrySet(false)
     155                 :            : {
     156         [ +  + ]:       8354 :         if (bBegin)
     157                 :            :         {
     158                 :          6 :                 m_nList = -1;
     159         [ +  - ]:          6 :                 if (!m_pMap->m_pDefault)
     160         [ +  - ]:          6 :                         next();
     161                 :            :         }
     162                 :            :         else
     163                 :            :         {
     164                 :       8348 :                 m_nList = Regexp::KIND_DOMAIN;
     165                 :       8348 :                 m_aIndex = m_pMap->m_aList[Regexp::KIND_DOMAIN].end();
     166                 :            :         }
     167                 :       8354 : }
     168                 :            : 
     169                 :            : //============================================================================
     170                 :            : template< typename Val >
     171                 :         12 : RegexpMapIterImpl< Val >::RegexpMapIterImpl(RegexpMapIterImpl const & rOther):
     172                 :            :     m_aEntry(rOther.m_aEntry), m_pMap(rOther.m_pMap), m_nList(rOther.m_nList),
     173                 :         12 :     m_bEntrySet(rOther.m_bEntrySet)
     174                 :            : {
     175         [ +  - ]:         12 :     if (m_nList != -1)
     176                 :         12 :         m_aIndex = rOther.m_aIndex;
     177                 :         12 : }
     178                 :            : 
     179                 :            : //============================================================================
     180                 :            : template< typename Val >
     181                 :       4627 : RegexpMapIterImpl< Val > & RegexpMapIterImpl< Val >::operator =(
     182                 :            :     RegexpMapIterImpl const & rOther)
     183                 :            : {
     184         [ +  - ]:       4627 :     if (this != &rOther)
     185                 :            :     {
     186                 :       4627 :         m_aEntry = rOther.m_aEntry;
     187                 :       4627 :         m_pMap = rOther.m_pMap;
     188                 :       4627 :         m_nList = rOther.m_nList;
     189                 :       4627 :         m_bEntrySet = rOther.m_bEntrySet;
     190         [ -  + ]:       4627 :         if (m_nList == -1)
     191                 :          0 :             m_aIndex = typename List< Val >::iterator();
     192                 :            :         else
     193                 :       4627 :             m_aIndex = rOther.m_aIndex;
     194                 :            :     }
     195                 :       4627 :     return *this;
     196                 :            : }
     197                 :            : 
     198                 :            : //============================================================================
     199                 :            : template< typename Val >
     200                 :       4727 : bool RegexpMapIterImpl< Val >::operator ==(RegexpMapIterImpl const & rOther)
     201                 :            :         const
     202                 :            : {
     203                 :            :         return m_pMap == rOther.m_pMap
     204                 :            :                    && m_nList == rOther.m_nList
     205 [ +  - ][ +  + ]:       4727 :                    && (m_nList == -1 || m_aIndex == rOther.m_aIndex);
         [ +  - ][ +  - ]
     206                 :            : }
     207                 :            : 
     208                 :            : //============================================================================
     209                 :            : template< typename Val >
     210                 :        100 : void RegexpMapIterImpl< Val >::next()
     211                 :            : {
     212      [ -  +  + ]:        100 :         switch (m_nList)
     213                 :            :         {
     214                 :            :                 case Regexp::KIND_DOMAIN:
     215         [ #  # ]:          0 :                         if (m_aIndex == m_pMap->m_aList[m_nList].end())
     216                 :        100 :                                 return;
     217                 :            :                 default:
     218                 :         94 :                         ++m_aIndex;
     219 [ +  + ][ +  - ]:         94 :                         if (m_nList == Regexp::KIND_DOMAIN
         [ +  + ][ +  - ]
     220                 :            :                                 || m_aIndex != m_pMap->m_aList[m_nList].end())
     221                 :         88 :                                 break;
     222                 :            :                 case -1:
     223         [ +  + ]:         48 :                         do
           [ +  +  +  + ]
     224                 :            :                         {
     225                 :         18 :                                 ++m_nList;
     226         [ +  + ]:         48 :                                 m_aIndex = m_pMap->m_aList[m_nList].begin();
     227                 :            :                         }
     228                 :            :                         while (m_nList < Regexp::KIND_DOMAIN
     229                 :            :                                    && m_aIndex == m_pMap->m_aList[m_nList].end());
     230                 :         12 :                         break;
     231                 :            :         }
     232                 :        100 :         m_bEntrySet = false;
     233                 :            : }
     234                 :            : 
     235                 :            : //============================================================================
     236                 :            : template< typename Val >
     237                 :       1098 : RegexpMapEntry< Val > & RegexpMapIterImpl< Val >::get()
     238                 :            : {
     239                 :       1098 :         setEntry();
     240                 :       1098 :         return m_aEntry;
     241                 :            : }
     242                 :            : 
     243                 :            : //============================================================================
     244                 :            : //
     245                 :            : //  RegexpMapConstIter
     246                 :            : //
     247                 :            : //============================================================================
     248                 :            : 
     249                 :            : template< typename Val >
     250                 :       9266 : RegexpMapConstIter< Val >::RegexpMapConstIter(RegexpMapIterImpl< Val > *
     251                 :            :                                                                                               pTheImpl):
     252                 :       9266 :         m_pImpl(pTheImpl)
     253                 :       9266 : {}
     254                 :            : 
     255                 :            : //============================================================================
     256                 :            : template< typename Val >
     257                 :       4627 : RegexpMapConstIter< Val >::RegexpMapConstIter():
     258         [ +  - ]:       4627 :         m_pImpl(new RegexpMapIterImpl< Val >)
     259                 :       4627 : {}
     260                 :            : 
     261                 :            : //============================================================================
     262                 :            : template< typename Val >
     263                 :         12 : RegexpMapConstIter< Val >::RegexpMapConstIter(RegexpMapConstIter const &
     264                 :            :                                                                                               rOther):
     265         [ +  - ]:         12 :         m_pImpl(new RegexpMapIterImpl< Val >(*rOther.m_pImpl))
     266                 :         12 : {}
     267                 :            : 
     268                 :            : //============================================================================
     269                 :            : template< typename Val >
     270                 :      13905 : RegexpMapConstIter< Val >::~RegexpMapConstIter()
     271                 :            : {
     272         [ +  - ]:      13905 :         delete m_pImpl;
     273                 :      13905 : }
     274                 :            : 
     275                 :            : //============================================================================
     276                 :            : template< typename Val >
     277                 :            : RegexpMapConstIter< Val > &
     278                 :       4627 : RegexpMapConstIter< Val >::operator =(RegexpMapConstIter const & rOther)
     279                 :            : {
     280                 :       4627 :         *m_pImpl = *rOther.m_pImpl;
     281                 :       4627 :         return *this;
     282                 :            : }
     283                 :            : 
     284                 :            : //============================================================================
     285                 :            : template< typename Val >
     286                 :         94 : RegexpMapConstIter< Val > & RegexpMapConstIter< Val >::operator ++()
     287                 :            : {
     288                 :         94 :         m_pImpl->next();
     289                 :         94 :         return *this;
     290                 :            : }
     291                 :            : 
     292                 :            : //============================================================================
     293                 :            : template< typename Val >
     294                 :            : RegexpMapConstIter< Val > RegexpMapConstIter< Val >::operator ++(int)
     295                 :            : {
     296                 :            :         RegexpMapConstIter aTemp(*this);
     297                 :            :         m_pImpl->next();
     298                 :            :         return aTemp;
     299                 :            : }
     300                 :            : 
     301                 :            : //============================================================================
     302                 :            : template< typename Val >
     303                 :            : RegexpMapEntry< Val > const & RegexpMapConstIter< Val >::operator *() const
     304                 :            : {
     305                 :            :         return m_pImpl->get();
     306                 :            : }
     307                 :            : 
     308                 :            : //============================================================================
     309                 :            : template< typename Val >
     310                 :        188 : RegexpMapEntry< Val > const * RegexpMapConstIter< Val >::operator ->() const
     311                 :            : {
     312                 :        188 :         return &m_pImpl->get();
     313                 :            : }
     314                 :            : 
     315                 :            : //============================================================================
     316                 :            : template< typename Val >
     317                 :       4727 : bool RegexpMapConstIter< Val >::equals(RegexpMapConstIter const & rOther)
     318                 :            :         const
     319                 :            : {
     320                 :       4727 :         return *m_pImpl == *rOther.m_pImpl;
     321                 :            : }
     322                 :            : 
     323                 :            : //============================================================================
     324                 :            : //
     325                 :            : //  RegexpMapIter
     326                 :            : //
     327                 :            : //============================================================================
     328                 :            : 
     329                 :            : template< typename Val >
     330                 :       9266 : RegexpMapIter< Val >::RegexpMapIter(RegexpMapIterImpl< Val > * pTheImpl):
     331                 :       9266 :         RegexpMapConstIter< Val >(pTheImpl)
     332                 :       9266 : {}
     333                 :            : 
     334                 :            : //============================================================================
     335                 :            : template< typename Val >
     336                 :            : RegexpMapIter< Val > & RegexpMapIter< Val >::operator ++()
     337                 :            : {
     338                 :            :         this->m_pImpl->next();
     339                 :            :         return *this;
     340                 :            : }
     341                 :            : 
     342                 :            : //============================================================================
     343                 :            : template< typename Val >
     344                 :            : RegexpMapIter< Val > RegexpMapIter< Val >::operator ++(int)
     345                 :            : {
     346                 :            :         RegexpMapIter aTemp(*this);
     347                 :            :         this->m_pImpl->next();
     348                 :            :         return aTemp;
     349                 :            : }
     350                 :            : 
     351                 :            : //============================================================================
     352                 :            : template< typename Val >
     353                 :            : RegexpMapEntry< Val > & RegexpMapIter< Val >::operator *()
     354                 :            : {
     355                 :            :         return this->m_pImpl->get();
     356                 :            : }
     357                 :            : 
     358                 :            : //============================================================================
     359                 :            : template< typename Val >
     360                 :            : RegexpMapEntry< Val > const & RegexpMapIter< Val >::operator *() const
     361                 :            : {
     362                 :            :         return this->m_pImpl->get();
     363                 :            : }
     364                 :            : 
     365                 :            : //============================================================================
     366                 :            : template< typename Val >
     367                 :        910 : RegexpMapEntry< Val > * RegexpMapIter< Val >::operator ->()
     368                 :            : {
     369                 :        910 :         return &this->m_pImpl->get();
     370                 :            : }
     371                 :            : 
     372                 :            : //============================================================================
     373                 :            : template< typename Val >
     374                 :            : RegexpMapEntry< Val > const * RegexpMapIter< Val >::operator ->() const
     375                 :            : {
     376                 :            :         return &this->m_pImpl->get();
     377                 :            : }
     378                 :            : 
     379                 :            : //============================================================================
     380                 :            : //
     381                 :            : //  RegexpMap
     382                 :            : //
     383                 :            : //============================================================================
     384                 :            : 
     385                 :            : namespace ucb_impl {
     386                 :            : 
     387                 :            : template< typename Val >
     388                 :            : struct RegexpMapImpl
     389                 :            : {
     390                 :            :         List< Val > m_aList[Regexp::KIND_DOMAIN + 1];
     391                 :            :         Entry< Val > * m_pDefault;
     392                 :            : 
     393 [ +  - ][ +  + ]:       1000 :         RegexpMapImpl(): m_pDefault(0) {}
           [ #  #  #  # ]
     394                 :            : 
     395 [ +  + ][ +  - ]:       1000 :         ~RegexpMapImpl() { delete m_pDefault; }
                 [ +  + ]
     396                 :            : };
     397                 :            : 
     398                 :            : }
     399                 :            : 
     400                 :            : //============================================================================
     401                 :            : template< typename Val >
     402                 :        250 : RegexpMap< Val >::RegexpMap():
     403         [ +  - ]:        250 :         m_pImpl(new RegexpMapImpl< Val >)
     404                 :        250 : {}
     405                 :            : 
     406                 :            : //============================================================================
     407                 :            : template< typename Val >
     408                 :            : RegexpMap< Val >::RegexpMap(RegexpMap const & rOther):
     409                 :            :         m_pImpl(new RegexpMapImpl< Val >(*rOther.m_pImpl))
     410                 :            : {}
     411                 :            : 
     412                 :            : //============================================================================
     413                 :            : template< typename Val >
     414                 :        250 : RegexpMap< Val >::~RegexpMap()
     415                 :            : {
     416         [ +  - ]:        250 :         delete m_pImpl;
     417                 :        250 : }
     418                 :            : 
     419                 :            : //============================================================================
     420                 :            : template< typename Val >
     421                 :            : RegexpMap< Val > & RegexpMap< Val >::operator =(RegexpMap const & rOther)
     422                 :            : {
     423                 :            :         *m_pImpl = *rOther.m_pImpl;
     424                 :            :         return *this;
     425                 :            : }
     426                 :            : 
     427                 :            : //============================================================================
     428                 :            : template< typename Val >
     429                 :       3715 : bool RegexpMap< Val >::add(rtl::OUString const & rKey, Val const & rValue,
     430                 :            :                                                    bool bOverwrite, rtl::OUString * pReverse)
     431                 :            : {
     432         [ +  - ]:       3715 :         Regexp aRegexp(Regexp::parse(rKey));
     433                 :            : 
     434         [ +  + ]:       3715 :         if (aRegexp.isDefault())
     435                 :            :         {
     436         [ -  + ]:         63 :                 if (m_pImpl->m_pDefault)
     437                 :            :                 {
     438         [ #  # ]:          0 :                         if (!bOverwrite)
     439                 :          0 :                                 return false;
     440         [ #  # ]:          0 :                         delete m_pImpl->m_pDefault;
     441                 :            :                 }
     442 [ +  - ][ +  - ]:         63 :                 m_pImpl->m_pDefault = new Entry< Val >(aRegexp, rValue);
     443                 :            :         }
     444                 :            :         else
     445                 :            :         {
     446                 :       3652 :                 List< Val > & rTheList = m_pImpl->m_aList[aRegexp.getKind()];
     447                 :            : 
     448                 :       3652 :                 typename List< Val >::iterator aEnd(rTheList.end());
     449         [ +  + ]:      29047 :                 for (typename List< Val >::iterator aIt(rTheList.begin()); aIt != aEnd; ++aIt)
     450                 :            :                 {
     451         [ -  + ]:      25395 :                         if (aIt->m_aRegexp == aRegexp)
     452                 :            :                         {
     453         [ #  # ]:          0 :                                 if (bOverwrite)
     454                 :            :                                 {
     455         [ #  # ]:          0 :                                         rTheList.erase(aIt);
     456                 :          0 :                                         break;
     457                 :            :                                 }
     458                 :            :                                 else
     459                 :          0 :                                         return false;
     460                 :            :                         }
     461                 :            :                 }
     462                 :            : 
     463 [ +  - ][ +  - ]:       3652 :                 rTheList.push_back(Entry< Val >(aRegexp, rValue));
     464                 :            :         }
     465                 :            : 
     466         [ -  + ]:       3715 :         if (pReverse)
     467         [ #  # ]:          0 :                 *pReverse = aRegexp.getRegexp(true);
     468                 :            : 
     469                 :       3715 :         return true;
     470                 :            : }
     471                 :            : 
     472                 :            : //============================================================================
     473                 :            : template< typename Val >
     474                 :       4627 : typename RegexpMap< Val >::iterator RegexpMap< Val >::find(rtl::OUString const & rKey,
     475                 :            :                                                                                                   rtl::OUString * pReverse)
     476                 :            : {
     477         [ +  - ]:       4627 :         Regexp aRegexp(Regexp::parse(rKey));
     478                 :            : 
     479         [ -  + ]:       4627 :         if (pReverse)
     480         [ #  # ]:          0 :                 *pReverse = aRegexp.getRegexp(true);
     481                 :            : 
     482         [ +  + ]:       4627 :         if (aRegexp.isDefault())
     483                 :            :         {
     484         [ -  + ]:         63 :                 if (m_pImpl->m_pDefault)
     485                 :            :                         return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl,
     486 [ #  # ][ #  # ]:          0 :                                                                                                                                          true));
                 [ #  # ]
     487                 :            :         }
     488                 :            :         else
     489                 :            :         {
     490                 :       4564 :                 List< Val > & rTheList = m_pImpl->m_aList[aRegexp.getKind()];
     491                 :            : 
     492                 :       4564 :                 typename List< Val > ::iterator aEnd(rTheList.end());
     493         [ +  + ]:      36013 :                 for (typename List< Val >::iterator aIt(rTheList.begin()); aIt != aEnd; ++aIt)
     494         [ +  + ]:      31449 :                         if (aIt->m_aRegexp == aRegexp)
     495                 :            :                                 return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(
     496                 :            :                                                                         m_pImpl,
     497 [ +  - ][ +  - ]:        912 :                                                                                                         aRegexp.getKind(), aIt));
                 [ +  - ]
     498                 :            :         }
     499                 :            : 
     500 [ +  - ][ +  - ]:       4627 :         return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl, false));
                 [ +  - ]
     501                 :            : }
     502                 :            : 
     503                 :            : //============================================================================
     504                 :            : template< typename Val >
     505                 :          2 : void RegexpMap< Val >::erase(iterator const & rPos)
     506                 :            : {
     507         [ +  - ]:          2 :         if (rPos.m_pImpl->getMap() == m_pImpl)
     508                 :            :         {
     509         [ -  + ]:          2 :                 if (rPos.m_pImpl->getList() == -1)
     510                 :            :                 {
     511         [ #  # ]:          0 :                         if (m_pImpl->m_pDefault)
     512                 :            :                         {
     513         [ #  # ]:          0 :                                 delete m_pImpl->m_pDefault;
     514                 :          0 :                                 m_pImpl->m_pDefault = 0;
     515                 :            :                         }
     516                 :            :                 }
     517                 :            :                 else
     518                 :          2 :                         m_pImpl->m_aList[rPos.m_pImpl->getList()].
     519                 :            :                                          erase(rPos.m_pImpl->getIndex());
     520                 :            :         }
     521                 :          2 : }
     522                 :            : 
     523                 :            : //============================================================================
     524                 :            : template< typename Val >
     525                 :          6 : typename RegexpMap< Val >::iterator RegexpMap< Val >::begin()
     526                 :            : {
     527         [ +  - ]:          6 :         return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl, true));
     528                 :            : }
     529                 :            : 
     530                 :            : //============================================================================
     531                 :            : template< typename Val >
     532                 :            : typename RegexpMap< Val >::const_iterator RegexpMap< Val >::begin() const
     533                 :            : {
     534                 :            :         return RegexpMapConstIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl,
     535                 :            :                                                                                                                                   true));
     536                 :            : }
     537                 :            : 
     538                 :            : //============================================================================
     539                 :            : template< typename Val >
     540                 :       4633 : typename RegexpMap< Val >::iterator RegexpMap< Val >::end()
     541                 :            : {
     542         [ +  - ]:       4633 :         return RegexpMapIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl, false));
     543                 :            : }
     544                 :            : 
     545                 :            : //============================================================================
     546                 :            : template< typename Val >
     547                 :            : typename RegexpMap< Val >::const_iterator RegexpMap< Val >::end() const
     548                 :            : {
     549                 :            :         return RegexpMapConstIter< Val >(new RegexpMapIterImpl< Val >(m_pImpl,
     550                 :            :                                                                                                                                   false));
     551                 :            : }
     552                 :            : 
     553                 :            : //============================================================================
     554                 :            : template< typename Val >
     555                 :            : bool RegexpMap< Val >::empty() const
     556                 :            : {
     557                 :            :         return !m_pImpl->m_pDefault
     558                 :            :                    && m_pImpl->m_aList[Regexp::KIND_PREFIX].empty()
     559                 :            :                    && m_pImpl->m_aList[Regexp::KIND_AUTHORITY].empty()
     560                 :            :                    && m_pImpl->m_aList[Regexp::KIND_DOMAIN].empty();
     561                 :            : }
     562                 :            : 
     563                 :            : //============================================================================
     564                 :            : template< typename Val >
     565                 :          6 : typename RegexpMap< Val >::size_type RegexpMap< Val >::size() const
     566                 :            : {
     567                 :            :         return (m_pImpl->m_pDefault ? 1 : 0)
     568                 :            :                        + m_pImpl->m_aList[Regexp::KIND_PREFIX].size()
     569                 :            :                        + m_pImpl->m_aList[Regexp::KIND_AUTHORITY].size()
     570         [ -  + ]:          6 :                        + m_pImpl->m_aList[Regexp::KIND_DOMAIN].size();
     571                 :            : }
     572                 :            : 
     573                 :            : //============================================================================
     574                 :            : template< typename Val >
     575                 :     283051 : Val const * RegexpMap< Val >::map(rtl::OUString const & rString,
     576                 :            :                                                                   rtl::OUString * pTranslation,
     577                 :            :                                                                   bool * pTranslated) const
     578                 :            : {
     579         [ +  + ]:     867044 :         for (int n = Regexp::KIND_DOMAIN; n >= Regexp::KIND_PREFIX; --n)
     580                 :            :         {
     581                 :     849153 :                 List< Val > const & rTheList = m_pImpl->m_aList[n];
     582                 :            : 
     583                 :     849153 :                 typename List< Val >::const_iterator aEnd(rTheList.end());
     584         [ +  + ]:    3120420 :                 for (typename List< Val >::const_iterator aIt(rTheList.begin()); aIt != aEnd;
     585                 :            :                          ++aIt)
     586 [ +  - ][ +  + ]:    2536427 :                         if (aIt->m_aRegexp.matches(rString, pTranslation, pTranslated))
     587                 :     265160 :                                 return &aIt->m_aValue;
     588                 :            :         }
     589 [ +  + ][ +  - ]:      17891 :         if (m_pImpl->m_pDefault
                 [ +  + ]
     590                 :            :                 && m_pImpl->m_pDefault->m_aRegexp.matches(rString, pTranslation,
     591                 :            :                                                                                                   pTranslated))
     592                 :       1368 :                 return &m_pImpl->m_pDefault->m_aValue;
     593                 :     283051 :         return 0;
     594                 :            : }
     595                 :            : 
     596                 :            : #endif // _UCB_REGEXPMAP_TPT_

Generated by: LCOV version 1.10