LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/comphelper/source/xml - attributelist.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 27 43 62.8 %
Date: 2013-07-09 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       74927 : struct TagAttribute_Impl
      32             : {
      33             :     TagAttribute_Impl(){}
      34       24949 :     TagAttribute_Impl( const OUString &aName, const OUString &aType,
      35             :                          const OUString &aValue )
      36       24949 :     {
      37       24949 :         this->sName     = aName;
      38       24949 :         this->sType     = aType;
      39       24949 :         this->sValue    = aValue;
      40       24949 :     }
      41             : 
      42             :     OUString sName;
      43             :     OUString sType;
      44             :     OUString sValue;
      45             : };
      46             : 
      47       23072 : struct AttributeList_Impl
      48             : {
      49       23072 :     AttributeList_Impl()
      50       23072 :     {
      51             :         // performance improvement during adding
      52       23072 :         vecAttribute.reserve(20);
      53       23072 :     }
      54             :     ::std::vector<struct TagAttribute_Impl> vecAttribute;
      55             : };
      56             : 
      57       38802 : sal_Int16 SAL_CALL AttributeList::getLength(void) throw( ::com::sun::star::uno::RuntimeException )
      58             : {
      59       38802 :     return (sal_Int16)(m_pImpl->vecAttribute.size());
      60             : }
      61             : 
      62       24901 : OUString SAL_CALL AttributeList::getNameByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException )
      63             : {
      64       24901 :     return ( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size()) ) ? m_pImpl->vecAttribute[i].sName : OUString();
      65             : }
      66             : 
      67           0 : OUString SAL_CALL AttributeList::getTypeByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException )
      68             : {
      69           0 :     if( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size() ) ) {
      70           0 :         return m_pImpl->vecAttribute[i].sType;
      71             :     }
      72           0 :     return OUString();
      73             : }
      74             : 
      75       25541 : OUString SAL_CALL  AttributeList::getValueByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException )
      76             : {
      77       25541 :     return ( i < static_cast < sal_Int16 > (m_pImpl->vecAttribute.size() ) ) ? m_pImpl->vecAttribute[i].sValue : OUString();
      78             : }
      79             : 
      80           0 : OUString SAL_CALL AttributeList::getTypeByName( const OUString& sName ) throw( ::com::sun::star::uno::RuntimeException )
      81             : {
      82           0 :     ::std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin();
      83             : 
      84           0 :     for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
      85           0 :         if( (*ii).sName == sName ) {
      86           0 :             return (*ii).sType;
      87             :         }
      88             :     }
      89           0 :     return OUString();
      90             : }
      91             : 
      92           0 : OUString SAL_CALL AttributeList::getValueByName(const OUString& sName) throw( ::com::sun::star::uno::RuntimeException )
      93             : {
      94           0 :     ::std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin();
      95             : 
      96           0 :     for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) {
      97           0 :         if( (*ii).sName == sName ) {
      98           0 :             return (*ii).sValue;
      99             :         }
     100             :     }
     101           0 :     return OUString();
     102             : }
     103             : 
     104             : 
     105       23072 : AttributeList::AttributeList()
     106             : {
     107       23072 :     m_pImpl = new AttributeList_Impl;
     108       23072 : }
     109             : 
     110             : 
     111             : 
     112       69216 : AttributeList::~AttributeList()
     113             : {
     114       23072 :     delete m_pImpl;
     115       46144 : }
     116             : 
     117       24949 : void AttributeList::AddAttribute(   const OUString &sName ,
     118             :                                         const OUString &sType ,
     119             :                                         const OUString &sValue )
     120             : {
     121       24949 :     m_pImpl->vecAttribute.push_back( TagAttribute_Impl( sName , sType , sValue ) );
     122       24949 : }
     123             : 
     124             : } // namespace comphelper
     125             : 
     126             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10