LCOV - code coverage report
Current view: top level - comphelper/source/xml - attributelist.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 27 43 62.8 %
Date: 2014-11-03 Functions: 13 16 81.2 %
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             : #include <comphelper/attributelist.hxx>
      21             : #include <osl/diagnose.h>
      22             : 
      23             : #include <vector>
      24             : 
      25             : using namespace osl;
      26             : using namespace com::sun::star;
      27             : 
      28             : 
      29             : namespace comphelper {
      30             : 
      31     1223944 : struct TagAttribute_Impl
      32             : {
      33      407928 :     TagAttribute_Impl( const OUString &aName, const OUString &aType,
      34             :                          const OUString &aValue )
      35      407928 :     {
      36      407928 :         this->sName     = aName;
      37      407928 :         this->sType     = aType;
      38      407928 :         this->sValue    = aValue;
      39      407928 :     }
      40             : 
      41             :     OUString sName;
      42             :     OUString sType;
      43             :     OUString sValue;
      44             : };
      45             : 
      46      284744 : struct AttributeList_Impl
      47             : {
      48      284744 :     AttributeList_Impl()
      49      284744 :     {
      50             :         // performance improvement during adding
      51      284744 :         vecAttribute.reserve(20);
      52      284744 :     }
      53             :     ::std::vector<struct TagAttribute_Impl> vecAttribute;
      54             : };
      55             : 
      56      317800 : sal_Int16 SAL_CALL AttributeList::getLength(void) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      57             : {
      58      317800 :     return (sal_Int16)(m_pImpl->vecAttribute.size());
      59             : }
      60             : 
      61      407816 : OUString SAL_CALL AttributeList::getNameByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      62             : {
      63      407816 :     return ( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size()) ) ? m_pImpl->vecAttribute[i].sName : OUString();
      64             : }
      65             : 
      66           0 : OUString SAL_CALL AttributeList::getTypeByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      67             : {
      68           0 :     if( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size() ) ) {
      69           0 :         return m_pImpl->vecAttribute[i].sType;
      70             :     }
      71           0 :     return OUString();
      72             : }
      73             : 
      74      405006 : OUString SAL_CALL  AttributeList::getValueByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      75             : {
      76      405006 :     return ( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size() ) ) ? m_pImpl->vecAttribute[i].sValue : OUString();
      77             : }
      78             : 
      79           0 : OUString SAL_CALL AttributeList::getTypeByName( const OUString& sName ) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      80             : {
      81           0 :     ::std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin();
      82             : 
      83           0 :     for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
      84           0 :         if( (*ii).sName == sName ) {
      85           0 :             return (*ii).sType;
      86             :         }
      87             :     }
      88           0 :     return OUString();
      89             : }
      90             : 
      91           0 : OUString SAL_CALL AttributeList::getValueByName(const OUString& sName) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      92             : {
      93           0 :     ::std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin();
      94             : 
      95           0 :     for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
      96           0 :         if( (*ii).sName == sName ) {
      97           0 :             return (*ii).sValue;
      98             :         }
      99             :     }
     100           0 :     return OUString();
     101             : }
     102             : 
     103             : 
     104      284744 : AttributeList::AttributeList()
     105             : {
     106      284744 :     m_pImpl = new AttributeList_Impl;
     107      284744 : }
     108             : 
     109             : 
     110             : 
     111      854232 : AttributeList::~AttributeList()
     112             : {
     113      284744 :     delete m_pImpl;
     114      569488 : }
     115             : 
     116      407928 : void AttributeList::AddAttribute(   const OUString &sName ,
     117             :                                         const OUString &sType ,
     118             :                                         const OUString &sValue )
     119             : {
     120      407928 :     m_pImpl->vecAttribute.push_back( TagAttribute_Impl( sName , sType , sValue ) );
     121      407928 : }
     122             : 
     123             : } // namespace comphelper
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10