1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propmap.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
35 #include <rtl/ustring.hxx>
36 #include <sal/types.h>
38 typedef ::std::hash_map
< ::rtl::OUString
,
41 ::std::equal_to
< ::rtl::OUString
> > TPropMapBase
;
51 template< class TValueType
>
52 void put(const ::rtl::OUString
& sKey
,
53 const TValueType
& rValue
)
55 void* pValue
= (void*)&rValue
;
56 m_aMap
[sKey
] = pValue
;
59 template< class TValueType
>
60 void put_copy(const ::rtl::OUString
& sKey
,
61 const TValueType
& rValue
)
63 TValueType
* pCopy
= new TValueType(rValue
);
64 m_aMap
[sKey
] = (void*)pCopy
;
67 template< class TValueType
>
68 sal_Bool
get(const ::rtl::OUString
& sKey
,
71 TPropMapBase::iterator pIt
= m_aMap
.find(sKey
);
72 if (pIt
== m_aMap
.end())
75 void* pItem
= pIt
->second
;
76 *pValue
= (TValueType
*)pItem
;
80 template< class TValueType
>
81 sal_Bool
get_copy(const ::rtl::OUString
& sKey
,
84 TPropMapBase::iterator pIt
= m_aMap
.find(sKey
);
85 if (pIt
== m_aMap
.end())
88 void* pValue
= pIt
->second
;
92 rValue
= *((TValueType
*)pValue
);