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 : #ifndef _XMLOFF_PROPERTYSETINFOHASH_HXX
20 : #define _XMLOFF_PROPERTYSETINFOHASH_HXX
21 :
22 : #include <xmloff/PropertySetInfoKey.hxx>
23 :
24 : #include <string.h>
25 : #include <memory>
26 :
27 : struct PropertySetInfoHash
28 : {
29 : inline size_t operator()( const PropertySetInfoKey& r ) const;
30 : inline bool operator()( const PropertySetInfoKey& r1,
31 : const PropertySetInfoKey& r2 ) const;
32 : };
33 :
34 3656 : inline size_t PropertySetInfoHash::operator()(
35 : const PropertySetInfoKey& r ) const
36 : {
37 : const sal_Int32* pBytesAsInt32Array =
38 3656 : (const sal_Int32*)r.aImplementationId.getConstArray();
39 7312 : sal_Int32 nId32 = pBytesAsInt32Array[0] ^
40 7312 : pBytesAsInt32Array[1] ^
41 7312 : pBytesAsInt32Array[2] ^
42 7312 : pBytesAsInt32Array[3];
43 3656 : return (size_t)nId32 ^ (size_t)r.xPropInfo.get();
44 : }
45 :
46 3067 : inline bool PropertySetInfoHash::operator()(
47 : const PropertySetInfoKey& r1,
48 : const PropertySetInfoKey& r2 ) const
49 : {
50 3067 : if( r1.xPropInfo != r2.xPropInfo )
51 0 : return sal_False;
52 :
53 3067 : const sal_Int8* pId1 = r1.aImplementationId.getConstArray();
54 3067 : const sal_Int8* pId2 = r2.aImplementationId.getConstArray();
55 3067 : return memcmp( pId1, pId2, 16 * sizeof( sal_Int8 ) ) == 0;
56 : }
57 : #endif
58 :
59 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|