diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-29 14:02:47 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-30 06:36:01 +0000 |
commit | 794c542953ca040d0e039f238bb00c95f6fdbaea (patch) | |
tree | 3c0bd722734796ffac0953ca482c2385cb8c198e /ucbhelper | |
parent | 2833691149af36a7508bed2d5113a599f8460f91 (diff) |
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>
Diffstat (limited to 'ucbhelper')
-rw-r--r-- | ucbhelper/source/provider/propertyvalueset.cxx | 168 |
1 files changed, 79 insertions, 89 deletions
diff --git a/ucbhelper/source/provider/propertyvalueset.cxx b/ucbhelper/source/provider/propertyvalueset.cxx index b53beba0eeb1..4fd70e3e975b 100644 --- a/ucbhelper/source/provider/propertyvalueset.cxx +++ b/ucbhelper/source/provider/propertyvalueset.cxx @@ -130,95 +130,86 @@ class PropertyValues : public std::vector< ucbhelper_impl::PropertyValue > {}; // Welcome to the macro hell... -#define GETVALUE_IMPL_TYPE( _type_, _type_name_, _member_name_, _cppu_type_ ) \ - \ - osl::MutexGuard aGuard( m_aMutex ); \ - \ - _type_ aValue = _type_(); /* default ctor */ \ - \ - m_bWasNull = true; \ - \ - if ( ( columnIndex < 1 ) \ - || ( columnIndex > sal_Int32( m_pValues->size() ) ) ) \ - { \ - OSL_FAIL( "PropertyValueSet - index out of range!" ); \ - } \ - else \ - { \ - ucbhelper_impl::PropertyValue& rValue \ - = (*m_pValues)[ columnIndex - 1 ]; \ - \ - if ( rValue.nOrigValue != PropsSet::NONE ) \ - { \ - if ( rValue.nPropsSet & _type_name_ ) \ - { \ - /* Values is present natively... */ \ - aValue = rValue._member_name_; \ - m_bWasNull = false; \ - } \ - else \ - { \ - if ( !(rValue.nPropsSet & PropsSet::Object) ) \ - { \ - /* Value is not (yet) available as Any. Create it. */ \ - getObject( columnIndex, Reference< XNameAccess >() ); \ - } \ - \ - if ( rValue.nPropsSet & PropsSet::Object ) \ - { \ - /* Value is available as Any. */ \ - \ - if ( rValue.aObject.hasValue() ) \ - { \ - /* Try to convert into native value. */ \ - if ( rValue.aObject >>= aValue ) \ - { \ - rValue._member_name_ = aValue; \ - rValue.nPropsSet |= _type_name_; \ - m_bWasNull = false; \ - } \ - else \ - { \ - /* Last chance. Try type converter service... */ \ - \ - Reference< XTypeConverter > xConverter \ - = getTypeConverter(); \ - if ( xConverter.is() ) \ - { \ - try \ - { \ - Any aConvAny = xConverter->convertTo( \ - rValue.aObject, \ - _cppu_type_ ); \ - \ - if ( aConvAny >>= aValue ) \ - { \ - rValue._member_name_ = aValue; \ - rValue.nPropsSet |= _type_name_; \ - m_bWasNull = false; \ - } \ - } \ - catch (const IllegalArgumentException&) \ - { \ - } \ - catch (const CannotConvertException&) \ - { \ - } \ - } \ - } \ - } \ - } \ - } \ - } \ - } \ +#define GETVALUE_IMPL( _type_, _type_name_, _member_name_ ) \ + \ + osl::MutexGuard aGuard( m_aMutex ); \ + \ + _type_ aValue = _type_(); /* default ctor */ \ + \ + m_bWasNull = true; \ + \ + if ( ( columnIndex < 1 ) \ + || ( columnIndex > sal_Int32( m_pValues->size() ) ) ) \ + { \ + OSL_FAIL( "PropertyValueSet - index out of range!" ); \ + return aValue; \ + } \ + ucbhelper_impl::PropertyValue& rValue \ + = (*m_pValues)[ columnIndex - 1 ]; \ + \ + if ( rValue.nOrigValue == PropsSet::NONE ) \ + return aValue; \ + \ + if ( rValue.nPropsSet & _type_name_ ) \ + { \ + /* Values is present natively... */ \ + aValue = rValue._member_name_; \ + m_bWasNull = false; \ + return aValue; \ + } \ + \ + if ( !(rValue.nPropsSet & PropsSet::Object) ) \ + { \ + /* Value is not (yet) available as Any. Create it. */ \ + getObject( columnIndex, Reference< XNameAccess >() ); \ + } \ + \ + if ( rValue.nPropsSet & PropsSet::Object ) \ + { \ + /* Value is available as Any. */ \ + \ + if ( rValue.aObject.hasValue() ) \ + { \ + /* Try to convert into native value. */ \ + if ( rValue.aObject >>= aValue ) \ + { \ + rValue._member_name_ = aValue; \ + rValue.nPropsSet |= _type_name_; \ + m_bWasNull = false; \ + } \ + else \ + { \ + /* Last chance. Try type converter service... */ \ + \ + Reference< XTypeConverter > xConverter \ + = getTypeConverter(); \ + if ( xConverter.is() ) \ + { \ + try \ + { \ + Any aConvAny = xConverter->convertTo( \ + rValue.aObject, \ + cppu::UnoType<_type_>::get() ); \ + \ + if ( aConvAny >>= aValue ) \ + { \ + rValue._member_name_ = aValue; \ + rValue.nPropsSet |= _type_name_; \ + m_bWasNull = false; \ + } \ + } \ + catch (const IllegalArgumentException&) \ + { \ + } \ + catch (const CannotConvertException&) \ + { \ + } \ + } \ + } \ + } \ + } \ 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_ ) \ \ 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 ) throw( SQLException, RuntimeException, std::exception ) { - GETVALUE_IMPL_TYPE( - bool, PropsSet::Boolean, bBoolean, cppu::UnoType<bool>::get() ); + GETVALUE_IMPL( bool, PropsSet::Boolean, bBoolean ); } |