1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _XMLOFF_PROPERTYSETINFOHASH_HXX 24 #define _XMLOFF_PROPERTYSETINFOHASH_HXX 25 26 #include <xmloff/PropertySetInfoKey.hxx> 27 28 #include <string.h> 29 #include <memory> 30 31 struct PropertySetInfoHash 32 { 33 inline size_t operator()( const PropertySetInfoKey& r ) const; 34 inline bool operator()( const PropertySetInfoKey& r1, 35 const PropertySetInfoKey& r2 ) const; 36 }; 37 operator ()(const PropertySetInfoKey & r) const38inline size_t PropertySetInfoHash::operator()( 39 const PropertySetInfoKey& r ) const 40 { 41 const sal_Int32* pBytesAsInt32Array = 42 (const sal_Int32*)r.aImplementationId.getConstArray(); 43 sal_Int32 nId32 = pBytesAsInt32Array[0] ^ 44 pBytesAsInt32Array[1] ^ 45 pBytesAsInt32Array[2] ^ 46 pBytesAsInt32Array[3]; 47 return (size_t)nId32 ^ (size_t)r.xPropInfo.get(); 48 } 49 operator ()(const PropertySetInfoKey & r1,const PropertySetInfoKey & r2) const50inline bool PropertySetInfoHash::operator()( 51 const PropertySetInfoKey& r1, 52 const PropertySetInfoKey& r2 ) const 53 { 54 if( r1.xPropInfo != r2.xPropInfo ) 55 return sal_False; 56 57 const sal_Int8* pId1 = r1.aImplementationId.getConstArray(); 58 const sal_Int8* pId2 = r2.aImplementationId.getConstArray(); 59 return memcmp( pId1, pId2, 16 * sizeof( sal_Int8 ) ) == 0; 60 } 61 #endif 62