xref: /AOO42X/main/xmloff/inc/xmloff/PropertySetInfoHash.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 #ifndef _XMLOFF_PROPERTYSETINFOHASH_HXX
28 #define _XMLOFF_PROPERTYSETINFOHASH_HXX
29 
30 #include <xmloff/PropertySetInfoKey.hxx>
31 
32 #include <string.h>
33 #include <memory>
34 
35 struct PropertySetInfoHash
36 {
37     inline size_t operator()( const PropertySetInfoKey& r ) const;
38     inline bool operator()( const PropertySetInfoKey& r1,
39                             const PropertySetInfoKey& r2 ) const;
40 };
41 
42 inline size_t PropertySetInfoHash::operator()(
43         const PropertySetInfoKey& r ) const
44 {
45     const sal_Int32* pBytesAsInt32Array =
46         (const sal_Int32*)r.aImplementationId.getConstArray();
47     sal_Int32 nId32 =   pBytesAsInt32Array[0] ^
48                         pBytesAsInt32Array[1] ^
49                         pBytesAsInt32Array[2] ^
50                         pBytesAsInt32Array[3];
51     return (size_t)nId32 ^ (size_t)r.xPropInfo.get();
52 }
53 
54 inline bool PropertySetInfoHash::operator()(
55         const PropertySetInfoKey& r1,
56         const PropertySetInfoKey& r2 ) const
57 {
58     if( r1.xPropInfo != r2.xPropInfo )
59         return sal_False;
60 
61     const sal_Int8* pId1 = r1.aImplementationId.getConstArray();
62     const sal_Int8* pId2 = r2.aImplementationId.getConstArray();
63     return memcmp( pId1, pId2, 16 * sizeof( sal_Int8 ) ) == 0;
64 }
65 #endif
66