summaryrefslogtreecommitdiff
path: root/include/comphelper
diff options
context:
space:
mode:
authorArkadiy Illarionov <qarkai@gmail.com>2019-06-12 12:18:07 +0300
committerStephan Bergmann <sbergman@redhat.com>2019-08-23 09:10:49 +0200
commit24c17dab2f10ad1b7ba342fbd40dc65b7d8f9b24 (patch)
tree5449a884fc53cf66fe1f02dfa21a5abd268bc3c1 /include/comphelper
parentdd7d90055545cb20aa5c12c0be44cccaefdeac47 (diff)
tdf#39593 extract UnoTunnelId comparison to template function
Change-Id: Ia2b5dea273c8de7b8c54e74780193a8d4cba7b45 Reviewed-on: https://gerrit.libreoffice.org/73874 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/comphelper')
-rw-r--r--include/comphelper/servicehelper.hxx13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/comphelper/servicehelper.hxx b/include/comphelper/servicehelper.hxx
index 82c3585a9a7a..435a4c4ff5b7 100644
--- a/include/comphelper/servicehelper.hxx
+++ b/include/comphelper/servicehelper.hxx
@@ -51,6 +51,13 @@ namespace comphelper {
}
+template <typename T>
+inline bool isUnoTunnelId(const css::uno::Sequence< sal_Int8 >& rId)
+{
+ return rId.getLength() == 16
+ && memcmp( T::getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) == 0;
+}
+
/** the UNO3_GETIMPLEMENTATION_* macros implement a static helper function
that gives access to your implementation for a given interface reference,
if possible.
@@ -83,8 +90,7 @@ const css::uno::Sequence< sal_Int8 > & classname::getUnoTunnelId() throw() \
UNO3_GETIMPLEMENTATION_BASE_IMPL(classname)\
sal_Int64 SAL_CALL classname::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) \
{ \
- if( rId.getLength() == 16 && memcmp( getUnoTunnelId().getConstArray(), \
- rId.getConstArray(), 16 ) == 0 ) \
+ if( isUnoTunnelId<classname>(rId) ) \
{ \
return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); \
} \
@@ -95,8 +101,7 @@ sal_Int64 SAL_CALL classname::getSomething( const css::uno::Sequence< sal_Int8 >
UNO3_GETIMPLEMENTATION_BASE_IMPL(classname)\
sal_Int64 SAL_CALL classname::getSomething( const css::uno::Sequence< sal_Int8 >& rId ) \
{ \
- if( rId.getLength() == 16 && memcmp( getUnoTunnelId().getConstArray(), \
- rId.getConstArray(), 16 ) == 0 ) \
+ if( isUnoTunnelId<classname>(rId) ) \
{ \
return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); \
} \