LCOV - code coverage report
Current view: top level - sax/source/expatwrap - attrlistimpl.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 58 0.0 %
Date: 2014-04-14 Functions: 0 21 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 "attrlistimpl.hxx"
      21             : 
      22             : #include <vector>
      23             : 
      24             : #include <cppuhelper/weak.hxx>
      25             : 
      26             : using namespace ::std;
      27             : using namespace ::rtl;
      28             : using namespace ::cppu;
      29             : using namespace ::com::sun::star::uno;
      30             : using namespace ::com::sun::star::util;
      31             : using namespace ::com::sun::star::xml::sax;
      32             : 
      33             : 
      34             : namespace sax_expatwrap {
      35           0 : struct TagAttribute
      36             : {
      37           0 :     TagAttribute( const OUString &aName, const OUString &aType , const OUString &aValue )
      38           0 :     {
      39           0 :         this->sName     = aName;
      40           0 :         this->sType     = aType;
      41           0 :         this->sValue    = aValue;
      42           0 :     }
      43             : 
      44             :     OUString sName;
      45             :     OUString sType;
      46             :     OUString sValue;
      47             : };
      48             : 
      49           0 : struct AttributeList_impl
      50             : {
      51           0 :     AttributeList_impl()
      52           0 :     {
      53             :         // performance improvement during adding
      54           0 :         vecAttribute.reserve(20);
      55           0 :     }
      56             :     vector<struct TagAttribute> vecAttribute;
      57             : };
      58             : 
      59             : 
      60             : 
      61           0 : sal_Int16 AttributeList::getLength(void) throw (RuntimeException, std::exception)
      62             : {
      63           0 :     return static_cast<sal_Int16>(m_pImpl->vecAttribute.size());
      64             : }
      65             : 
      66             : 
      67           0 : AttributeList::AttributeList( const AttributeList &r ) :
      68           0 :     cppu::WeakImplHelper2<XAttributeList, XCloneable>()
      69             : {
      70           0 :     m_pImpl = new AttributeList_impl;
      71           0 :     *m_pImpl = *(r.m_pImpl);
      72           0 : }
      73             : 
      74           0 : OUString AttributeList::getNameByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
      75             : {
      76           0 :     if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
      77           0 :         return m_pImpl->vecAttribute[i].sName;
      78             :     }
      79           0 :     return OUString();
      80             : }
      81             : 
      82             : 
      83           0 : OUString AttributeList::getTypeByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
      84             : {
      85           0 :     if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
      86           0 :         return m_pImpl->vecAttribute[i].sType;
      87             :     }
      88           0 :     return OUString();
      89             : }
      90             : 
      91           0 : OUString AttributeList::getValueByIndex(sal_Int16 i) throw (RuntimeException, std::exception)
      92             : {
      93           0 :     if( std::vector< TagAttribute >::size_type(i) < m_pImpl->vecAttribute.size() ) {
      94           0 :         return m_pImpl->vecAttribute[i].sValue;
      95             :     }
      96           0 :     return OUString();
      97             : 
      98             : }
      99             : 
     100           0 : OUString AttributeList::getTypeByName( const OUString& sName ) throw (RuntimeException, std::exception)
     101             : {
     102           0 :     vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
     103             : 
     104           0 :     for (; ii != m_pImpl->vecAttribute.end(); ++ii )
     105             :     {
     106           0 :         if( (*ii).sName == sName )
     107             :         {
     108           0 :             return (*ii).sType;
     109             :         }
     110             :     }
     111           0 :     return OUString();
     112             : }
     113             : 
     114           0 : OUString AttributeList::getValueByName(const OUString& sName) throw (RuntimeException, std::exception)
     115             : {
     116           0 :     vector<struct TagAttribute>::iterator ii = m_pImpl->vecAttribute.begin();
     117             : 
     118           0 :     for (; ii != m_pImpl->vecAttribute.end(); ++ii)
     119             :     {
     120           0 :         if( (*ii).sName == sName )
     121             :         {
     122           0 :             return (*ii).sValue;
     123             :         }
     124             :     }
     125           0 :     return OUString();
     126             : }
     127             : 
     128             : 
     129           0 : Reference< XCloneable > AttributeList::createClone() throw (RuntimeException, std::exception)
     130             : {
     131           0 :     AttributeList *p = new AttributeList( *this );
     132           0 :     return Reference< XCloneable > ( (XCloneable * ) p );
     133             : }
     134             : 
     135             : 
     136             : 
     137           0 : AttributeList::AttributeList()
     138             : {
     139           0 :     m_pImpl = new AttributeList_impl;
     140           0 : }
     141             : 
     142             : 
     143             : 
     144           0 : AttributeList::~AttributeList()
     145             : {
     146           0 :     delete m_pImpl;
     147           0 : }
     148             : 
     149             : 
     150           0 : void AttributeList::addAttribute(   const OUString &sName ,
     151             :                                         const OUString &sType ,
     152             :                                         const OUString &sValue )
     153             : {
     154           0 :     m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) );
     155           0 : }
     156             : 
     157           0 : void AttributeList::clear()
     158             : {
     159           0 :     m_pImpl->vecAttribute.clear();
     160           0 : }
     161             : 
     162             : }
     163             : 
     164             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10