LCOV - code coverage report
Current view: top level - comphelper/source/xml - attributelist.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 43 0.0 %
Date: 2014-04-14 Functions: 0 16 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             : 
      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           0 : struct TagAttribute_Impl
      32             : {
      33           0 :     TagAttribute_Impl( const OUString &aName, const OUString &aType,
      34             :                          const OUString &aValue )
      35           0 :     {
      36           0 :         this->sName     = aName;
      37           0 :         this->sType     = aType;
      38           0 :         this->sValue    = aValue;
      39           0 :     }
      40             : 
      41             :     OUString sName;
      42             :     OUString sType;
      43             :     OUString sValue;
      44             : };
      45             : 
      46           0 : struct AttributeList_Impl
      47             : {
      48           0 :     AttributeList_Impl()
      49           0 :     {
      50             :         // performance improvement during adding
      51           0 :         vecAttribute.reserve(20);
      52           0 :     }
      53             :     ::std::vector<struct TagAttribute_Impl> vecAttribute;
      54             : };
      55             : 
      56           0 : sal_Int16 SAL_CALL AttributeList::getLength(void) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      57             : {
      58           0 :     return (sal_Int16)(m_pImpl->vecAttribute.size());
      59             : }
      60             : 
      61           0 : OUString SAL_CALL AttributeList::getNameByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      62             : {
      63           0 :     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           0 : OUString SAL_CALL  AttributeList::getValueByIndex(sal_Int16 i) throw( ::com::sun::star::uno::RuntimeException, std::exception )
      75             : {
      76           0 :     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           0 : AttributeList::AttributeList()
     105             : {
     106           0 :     m_pImpl = new AttributeList_Impl;
     107           0 : }
     108             : 
     109             : 
     110             : 
     111           0 : AttributeList::~AttributeList()
     112             : {
     113           0 :     delete m_pImpl;
     114           0 : }
     115             : 
     116           0 : void AttributeList::AddAttribute(   const OUString &sName ,
     117             :                                         const OUString &sType ,
     118             :                                         const OUString &sValue )
     119             : {
     120           0 :     m_pImpl->vecAttribute.push_back( TagAttribute_Impl( sName , sType , sValue ) );
     121           0 : }
     122             : 
     123             : } // namespace comphelper
     124             : 
     125             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10