simplify macros

Change-Id: Ib56bdc2f8a7015afc8ac83d7cfd6eb65089682bb
Reviewed-on: https://gerrit.libreoffice.org/31364
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin
2016-11-29 14:02:47 +02:00
parent 2833691149
commit 794c542953

View File

@@ -130,95 +130,86 @@ class PropertyValues : public std::vector< ucbhelper_impl::PropertyValue > {};
// Welcome to the macro hell... // Welcome to the macro hell...
#define GETVALUE_IMPL_TYPE( _type_, _type_name_, _member_name_, _cppu_type_ ) \ #define GETVALUE_IMPL( _type_, _type_name_, _member_name_ ) \
\ \
osl::MutexGuard aGuard( m_aMutex ); \ osl::MutexGuard aGuard( m_aMutex ); \
\ \
_type_ aValue = _type_(); /* default ctor */ \ _type_ aValue = _type_(); /* default ctor */ \
\ \
m_bWasNull = true; \ m_bWasNull = true; \
\ \
if ( ( columnIndex < 1 ) \ if ( ( columnIndex < 1 ) \
|| ( columnIndex > sal_Int32( m_pValues->size() ) ) ) \ || ( columnIndex > sal_Int32( m_pValues->size() ) ) ) \
{ \ { \
OSL_FAIL( "PropertyValueSet - index out of range!" ); \ OSL_FAIL( "PropertyValueSet - index out of range!" ); \
} \ return aValue; \
else \ } \
{ \ ucbhelper_impl::PropertyValue& rValue \
ucbhelper_impl::PropertyValue& rValue \ = (*m_pValues)[ columnIndex - 1 ]; \
= (*m_pValues)[ columnIndex - 1 ]; \ \
\ if ( rValue.nOrigValue == PropsSet::NONE ) \
if ( rValue.nOrigValue != PropsSet::NONE ) \ return aValue; \
{ \ \
if ( rValue.nPropsSet & _type_name_ ) \ if ( rValue.nPropsSet & _type_name_ ) \
{ \ { \
/* Values is present natively... */ \ /* Values is present natively... */ \
aValue = rValue._member_name_; \ aValue = rValue._member_name_; \
m_bWasNull = false; \ m_bWasNull = false; \
} \ return aValue; \
else \ } \
{ \ \
if ( !(rValue.nPropsSet & PropsSet::Object) ) \ if ( !(rValue.nPropsSet & PropsSet::Object) ) \
{ \ { \
/* Value is not (yet) available as Any. Create it. */ \ /* Value is not (yet) available as Any. Create it. */ \
getObject( columnIndex, Reference< XNameAccess >() ); \ getObject( columnIndex, Reference< XNameAccess >() ); \
} \ } \
\ \
if ( rValue.nPropsSet & PropsSet::Object ) \ if ( rValue.nPropsSet & PropsSet::Object ) \
{ \ { \
/* Value is available as Any. */ \ /* Value is available as Any. */ \
\ \
if ( rValue.aObject.hasValue() ) \ if ( rValue.aObject.hasValue() ) \
{ \ { \
/* Try to convert into native value. */ \ /* Try to convert into native value. */ \
if ( rValue.aObject >>= aValue ) \ if ( rValue.aObject >>= aValue ) \
{ \ { \
rValue._member_name_ = aValue; \ rValue._member_name_ = aValue; \
rValue.nPropsSet |= _type_name_; \ rValue.nPropsSet |= _type_name_; \
m_bWasNull = false; \ m_bWasNull = false; \
} \ } \
else \ else \
{ \ { \
/* Last chance. Try type converter service... */ \ /* Last chance. Try type converter service... */ \
\ \
Reference< XTypeConverter > xConverter \ Reference< XTypeConverter > xConverter \
= getTypeConverter(); \ = getTypeConverter(); \
if ( xConverter.is() ) \ if ( xConverter.is() ) \
{ \ { \
try \ try \
{ \ { \
Any aConvAny = xConverter->convertTo( \ Any aConvAny = xConverter->convertTo( \
rValue.aObject, \ rValue.aObject, \
_cppu_type_ ); \ cppu::UnoType<_type_>::get() ); \
\ \
if ( aConvAny >>= aValue ) \ if ( aConvAny >>= aValue ) \
{ \ { \
rValue._member_name_ = aValue; \ rValue._member_name_ = aValue; \
rValue.nPropsSet |= _type_name_; \ rValue.nPropsSet |= _type_name_; \
m_bWasNull = false; \ m_bWasNull = false; \
} \ } \
} \ } \
catch (const IllegalArgumentException&) \ catch (const IllegalArgumentException&) \
{ \ { \
} \ } \
catch (const CannotConvertException&) \ catch (const CannotConvertException&) \
{ \ { \
} \ } \
} \ } \
} \ } \
} \ } \
} \ } \
} \
} \
} \
return aValue; return aValue;
#define GETVALUE_IMPL( _type_, _type_name_, _member_name_ ) \
GETVALUE_IMPL_TYPE( _type_, \
_type_name_, \
_member_name_, \
cppu::UnoType<_type_>::get() )
#define SETVALUE_IMPL( _prop_name_, _type_name_, _member_name_, _value_ ) \ #define SETVALUE_IMPL( _prop_name_, _type_name_, _member_name_, _value_ ) \
\ \
osl::MutexGuard aGuard( m_aMutex ); \ osl::MutexGuard aGuard( m_aMutex ); \
@@ -314,8 +305,7 @@ OUString SAL_CALL PropertyValueSet::getString( sal_Int32 columnIndex )
sal_Bool SAL_CALL PropertyValueSet::getBoolean( sal_Int32 columnIndex ) sal_Bool SAL_CALL PropertyValueSet::getBoolean( sal_Int32 columnIndex )
throw( SQLException, RuntimeException, std::exception ) throw( SQLException, RuntimeException, std::exception )
{ {
GETVALUE_IMPL_TYPE( GETVALUE_IMPL( bool, PropsSet::Boolean, bBoolean );
bool, PropsSet::Boolean, bBoolean, cppu::UnoType<bool>::get() );
} }