24#include <typelib/typedescription.hxx>
26#include <com/sun/star/uno/Sequence.hxx>
31using ::com::sun::star::uno::TypeDescription;
32using ::comphelper::detail::TypeDescriptionRef;
37std::optional<size_t> hashValue(
size_t hash,
38 void const * val, typelib_TypeDescriptionReference * typeRef )
41 if (typeRef->eTypeClass == typelib_TypeClass_VOID) {
44 assert(val !=
nullptr);
46 switch (typeRef->eTypeClass) {
47 case typelib_TypeClass_INTERFACE: {
50 case typelib_TypeClass_STRUCT:
51 case typelib_TypeClass_EXCEPTION: {
52 TypeDescription typeDescr( typeRef );
54 typeDescr.makeComplete();
58 typelib_CompoundTypeDescription * compType =
59 reinterpret_cast< typelib_CompoundTypeDescription *
>(
61 sal_Int32 nDescr = compType->nMembers;
63 if (compType->pBaseTypeDescription) {
64 std::optional<size_t> tmpHash = hashValue(
65 hash, val,
reinterpret_cast<
67 compType->pBaseTypeDescription)->pWeakRef);
68 if(!tmpHash.has_value())
73 typelib_TypeDescriptionReference ** ppTypeRefs =
75 sal_Int32 * memberOffsets = compType->pMemberOffsets;
77 for ( sal_Int32 nPos = 0;
nPos < nDescr; ++
nPos )
79 TypeDescriptionRef memberType( ppTypeRefs[ nPos ] );
83 std::optional<size_t> tmpHash = hashValue( hash,
84 static_cast< char const *
>(
85 val ) + memberOffsets[ nPos ],
86 memberType->pWeakRef );
87 if(!tmpHash.has_value())
93 case typelib_TypeClass_SEQUENCE: {
94 TypeDescriptionRef typeDescr( typeRef );
98 typelib_TypeDescriptionReference * elementTypeRef =
100 typelib_IndirectTypeDescription *
>(typeDescr.get())->pType;
101 TypeDescriptionRef elementTypeDescr( elementTypeRef );
102 if (!elementTypeDescr.is())
105 sal_Int32 nElementSize = elementTypeDescr->nSize;
107 *
static_cast< uno_Sequence *
const *
>(val);
112 char const * pElements = seq->elements;
115 std::optional<size_t> tmpHash = hashValue( hash,
116 pElements + (nElementSize * nPos),
117 elementTypeDescr->pWeakRef );
118 if(!tmpHash.has_value())
125 case typelib_TypeClass_ANY: {
127 return hashValue( hash, pAny->pData, pAny->pType );
129 case typelib_TypeClass_TYPE: {
130 OUString
const & str = OUString::unacquired(
132 typelib_TypeDescriptionReference *
const *
>(val)
137 case typelib_TypeClass_STRING: {
138 OUString
const & str = OUString::unacquired(
139 static_cast< rtl_uString *
const *
>(val) );
143 case typelib_TypeClass_ENUM: {
144 TypeDescription typeDescr( typeRef );
146 typeDescr.makeComplete();
153 case typelib_TypeClass_BOOLEAN:
154 if (*
static_cast< sal_Bool const *
>(val))
159 case typelib_TypeClass_CHAR: {
163 case typelib_TypeClass_FLOAT:
166 case typelib_TypeClass_DOUBLE:
169 case typelib_TypeClass_BYTE:
172 case typelib_TypeClass_SHORT:
175 case typelib_TypeClass_UNSIGNED_SHORT:
178 case typelib_TypeClass_LONG:
181 case typelib_TypeClass_UNSIGNED_LONG:
184 case typelib_TypeClass_HYPER:
187 case typelib_TypeClass_UNSIGNED_HYPER:
205 return hashValue( hash,
value.getValue(),
value.getValueTypeRef());
struct _typelib_TypeDescription typelib_TypeDescription
std::optional< size_t > anyToHash(uno::Any const &value)
std::enable_if_t<(sizeof(N)==4)> hash_combine(N &nSeed, T const *pValue, size_t nCount)