merge the formfield patch from ooo-build
[ooovba.git] / fpicker / source / win32 / filepicker / propmap.hxx
blobca877ccd75f6174ab608a0fac753059b1a421059
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propmap.hxx,v $
10 * $Revision: 1.3 $
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 ************************************************************************/
31 #ifndef _PROPMAP_HXX_
32 #define _PROPMAP_HXX_
34 #include <hash_map>
35 #include <rtl/ustring.hxx>
36 #include <sal/types.h>
38 typedef ::std::hash_map< ::rtl::OUString ,
39 void* ,
40 ::rtl::OUStringHash ,
41 ::std::equal_to< ::rtl::OUString > > TPropMapBase;
43 class TPropMap
45 private:
47 TPropMapBase m_aMap;
49 public:
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 ,
69 TValueType** pValue)
71 TPropMapBase::iterator pIt = m_aMap.find(sKey);
72 if (pIt == m_aMap.end())
73 return sal_False;
75 void* pItem = pIt->second;
76 *pValue = (TValueType*)pItem;
77 return (pItem != 0);
80 template< class TValueType >
81 sal_Bool get_copy(const ::rtl::OUString& sKey ,
82 TValueType& rValue)
84 TPropMapBase::iterator pIt = m_aMap.find(sKey);
85 if (pIt == m_aMap.end())
86 return sal_False;
88 void* pValue = pIt->second;
89 if ( ! pValue)
90 return sal_False;
92 rValue = *((TValueType*)pValue);
93 //delete pValue;
94 m_aMap.erase(pIt);
95 return sal_True;
98 void clear()
100 m_aMap.clear();
104 #endif