1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <comphelper/attributelist.hxx>
21 #include <osl/diagnose.h>
26 using namespace com::sun::star
;
29 namespace comphelper
{
31 struct TagAttribute_Impl
33 TagAttribute_Impl( const OUString
&aName
, const OUString
&aType
,
34 const OUString
&aValue
)
38 this->sValue
= aValue
;
46 struct AttributeList_Impl
50 // performance improvement during adding
51 vecAttribute
.reserve(20);
53 ::std::vector
<struct TagAttribute_Impl
> vecAttribute
;
56 sal_Int16 SAL_CALL
AttributeList::getLength(void) throw( ::com::sun::star::uno::RuntimeException
, std::exception
)
58 return (sal_Int16
)(m_pImpl
->vecAttribute
.size());
61 OUString SAL_CALL
AttributeList::getNameByIndex(sal_Int16 i
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
)
63 return ( i
< static_cast < sal_Int16
> (m_pImpl
->vecAttribute
.size()) ) ? m_pImpl
->vecAttribute
[i
].sName
: OUString();
66 OUString SAL_CALL
AttributeList::getTypeByIndex(sal_Int16 i
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
)
68 if( i
< static_cast < sal_Int16
> (m_pImpl
->vecAttribute
.size() ) ) {
69 return m_pImpl
->vecAttribute
[i
].sType
;
74 OUString SAL_CALL
AttributeList::getValueByIndex(sal_Int16 i
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
)
76 return ( i
< static_cast < sal_Int16
> (m_pImpl
->vecAttribute
.size() ) ) ? m_pImpl
->vecAttribute
[i
].sValue
: OUString();
79 OUString SAL_CALL
AttributeList::getTypeByName( const OUString
& sName
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
)
81 ::std::vector
<struct TagAttribute_Impl
>::iterator ii
= m_pImpl
->vecAttribute
.begin();
83 for( ; ii
!= m_pImpl
->vecAttribute
.end() ; ++ii
) {
84 if( (*ii
).sName
== sName
) {
91 OUString SAL_CALL
AttributeList::getValueByName(const OUString
& sName
) throw( ::com::sun::star::uno::RuntimeException
, std::exception
)
93 ::std::vector
<struct TagAttribute_Impl
>::iterator ii
= m_pImpl
->vecAttribute
.begin();
95 for( ; ii
!= m_pImpl
->vecAttribute
.end() ; ++ii
) {
96 if( (*ii
).sName
== sName
) {
104 AttributeList::AttributeList()
106 m_pImpl
= new AttributeList_Impl
;
111 AttributeList::~AttributeList()
116 void AttributeList::AddAttribute( const OUString
&sName
,
117 const OUString
&sType
,
118 const OUString
&sValue
)
120 m_pImpl
->vecAttribute
.push_back( TagAttribute_Impl( sName
, sType
, sValue
) );
123 } // namespace comphelper
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */