diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-02-26 21:45:06 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-02-27 09:12:59 +0100 |
commit | 573f87f6ea57a248c79f52b1cd4e5f1978112567 (patch) | |
tree | d5425462ab8c9a4a0c2f18e8bf79fe6bef1380ac /comphelper | |
parent | 59363e639b67a8acbd6da240635de47921b2c955 (diff) |
Use for-range loops in comphelper and configmgr
Change-Id: I91033395cb30a4ba9e65adb89712b3c70a39a508
Reviewed-on: https://gerrit.libreoffice.org/50396
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/qa/unit/syntaxhighlighttest.cxx | 9 | ||||
-rw-r--r-- | comphelper/source/container/enumerablemap.cxx | 8 | ||||
-rw-r--r-- | comphelper/source/misc/configuration.cxx | 14 | ||||
-rw-r--r-- | comphelper/source/misc/namedvaluecollection.cxx | 13 | ||||
-rw-r--r-- | comphelper/source/misc/sequenceashashmap.cxx | 18 | ||||
-rw-r--r-- | comphelper/source/property/ChainablePropertySetInfo.cxx | 5 | ||||
-rw-r--r-- | comphelper/source/property/MasterPropertySetInfo.cxx | 5 | ||||
-rw-r--r-- | comphelper/source/xml/attributelist.cxx | 18 | ||||
-rw-r--r-- | comphelper/source/xml/xmltools.cxx | 5 |
9 files changed, 40 insertions, 55 deletions
diff --git a/comphelper/qa/unit/syntaxhighlighttest.cxx b/comphelper/qa/unit/syntaxhighlighttest.cxx index 6a35049fcd08..c502262669a0 100644 --- a/comphelper/qa/unit/syntaxhighlighttest.cxx +++ b/comphelper/qa/unit/syntaxhighlighttest.cxx @@ -107,12 +107,11 @@ void SyntaxHighlightTest::testBasic() aBasicString, aPortions ); sal_Int32 prevEnd = 0; - for(std::vector<HighlightPortion>::const_iterator itr = - aPortions.begin(), itrEnd = aPortions.end(); itr != itrEnd; ++itr) + for (auto const& portion : aPortions) { - CPPUNIT_ASSERT_EQUAL(prevEnd, itr->nBegin); - CPPUNIT_ASSERT(itr->nBegin < itr->nEnd); - prevEnd = itr->nEnd; + CPPUNIT_ASSERT_EQUAL(prevEnd, portion.nBegin); + CPPUNIT_ASSERT(portion.nBegin < portion.nEnd); + prevEnd = portion.nEnd; } CPPUNIT_ASSERT_EQUAL(aBasicString.getLength(), prevEnd); } diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx index 0d2e1483509b..5a6c2ae428c0 100644 --- a/comphelper/source/container/enumerablemap.cxx +++ b/comphelper/source/container/enumerablemap.cxx @@ -556,13 +556,9 @@ namespace comphelper { ComponentMethodGuard aGuard( *this ); impl_checkValue_throw( _value ); - - for ( KeyedValues::const_iterator mapping = m_aData.m_pValues->begin(); - mapping != m_aData.m_pValues->end(); - ++mapping - ) + for (auto const& value : *m_aData.m_pValues) { - if ( mapping->second == _value ) + if ( value.second == _value ) return true; } return false; diff --git a/comphelper/source/misc/configuration.cxx b/comphelper/source/misc/configuration.cxx index 6847f2f7cc00..03396f0bac89 100644 --- a/comphelper/source/misc/configuration.cxx +++ b/comphelper/source/misc/configuration.cxx @@ -229,10 +229,10 @@ void comphelper::ConfigurationListener::removeListener(ConfigurationListenerProp void comphelper::ConfigurationListener::dispose() { - for (auto it = maListeners.begin(); it != maListeners.end(); ++it) + for (auto const& listener : maListeners) { - mxConfig->removePropertyChangeListener( (*it)->maName, this ); - (*it)->dispose(); + mxConfig->removePropertyChangeListener( listener->maName, this ); + listener->dispose(); } maListeners.clear(); } @@ -252,13 +252,13 @@ void SAL_CALL comphelper::ConfigurationListener::propertyChange( comphelper::SolarMutex::get() ); assert( rEvt.Source == mxConfig ); - for ( auto it = maListeners.begin(); it != maListeners.end(); ++it ) + for (auto const& listener : maListeners) { - if ( (*it)->maName == rEvt.PropertyName ) + if ( listener->maName == rEvt.PropertyName ) { // ignore rEvt.NewValue - in theory it could be stale => not set. - css::uno::Any aValue = mxConfig->getPropertyValue( (*it)->maName ); - (*it)->setProperty( aValue ); + css::uno::Any aValue = mxConfig->getPropertyValue( listener->maName ); + listener->setProperty( aValue ); } } } diff --git a/comphelper/source/misc/namedvaluecollection.cxx b/comphelper/source/misc/namedvaluecollection.cxx index d803c6fee8c3..d8a954f9c8a1 100644 --- a/comphelper/source/misc/namedvaluecollection.cxx +++ b/comphelper/source/misc/namedvaluecollection.cxx @@ -126,13 +126,10 @@ namespace comphelper NamedValueCollection& NamedValueCollection::merge( const NamedValueCollection& _rAdditionalValues, bool _bOverwriteExisting ) { - for ( NamedValueRepository::const_iterator namedValue = _rAdditionalValues.m_pImpl->aValues.begin(); - namedValue != _rAdditionalValues.m_pImpl->aValues.end(); - ++namedValue - ) + for (auto const& value : _rAdditionalValues.m_pImpl->aValues) { - if ( _bOverwriteExisting || !impl_has( namedValue->first ) ) - impl_put( namedValue->first, namedValue->second ); + if ( _bOverwriteExisting || !impl_has( value.first ) ) + impl_put( value.first, value.second ); } return *this; @@ -154,9 +151,9 @@ namespace comphelper std::vector< OUString > NamedValueCollection::getNames() const { std::vector< OUString > aNames; - for ( NamedValueRepository::const_iterator it = m_pImpl->aValues.begin(), end = m_pImpl->aValues.end(); it != end; ++it ) + for (auto const& value : m_pImpl->aValues) { - aNames.push_back( it->first ); + aNames.push_back( value.first ); } return aNames; } diff --git a/comphelper/source/misc/sequenceashashmap.cxx b/comphelper/source/misc/sequenceashashmap.cxx index 3468d6731ac4..93e84139352c 100644 --- a/comphelper/source/misc/sequenceashashmap.cxx +++ b/comphelper/source/misc/sequenceashashmap.cxx @@ -204,13 +204,10 @@ const css::uno::Sequence< css::beans::PropertyValue > SequenceAsHashMap::getAsCo bool SequenceAsHashMap::match(const SequenceAsHashMap& rCheck) const { - const_iterator pCheck; - for ( pCheck = rCheck.begin(); - pCheck != rCheck.end() ; - ++pCheck ) + for (auto const& elem : rCheck) { - const OUString& sCheckName = pCheck->first; - const css::uno::Any& aCheckValue = pCheck->second; + const OUString& sCheckName = elem.first; + const css::uno::Any& aCheckValue = elem.second; const_iterator pFound = find(sCheckName); if (pFound == end()) @@ -226,13 +223,10 @@ bool SequenceAsHashMap::match(const SequenceAsHashMap& rCheck) const void SequenceAsHashMap::update(const SequenceAsHashMap& rUpdate) { - const_iterator pUpdate; - for ( pUpdate = rUpdate.begin(); - pUpdate != rUpdate.end() ; - ++pUpdate ) + for (auto const& elem : rUpdate) { - const OUString& sName = pUpdate->first; - const css::uno::Any& aValue = pUpdate->second; + const OUString& sName = elem.first; + const css::uno::Any& aValue = elem.second; (*this)[sName] = aValue; } diff --git a/comphelper/source/property/ChainablePropertySetInfo.cxx b/comphelper/source/property/ChainablePropertySetInfo.cxx index 00f6720324b0..37eba79cea09 100644 --- a/comphelper/source/property/ChainablePropertySetInfo.cxx +++ b/comphelper/source/property/ChainablePropertySetInfo.cxx @@ -59,14 +59,15 @@ Sequence< ::Property > SAL_CALL ChainablePropertySetInfo::getProperties() maProperties.realloc ( nSize ); Property* pProperties = maProperties.getArray(); - for (PropertyInfoHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()); aIter != aEnd; ++aIter, ++pProperties) + for (auto const& elem : maMap) { - PropertyInfo const * pInfo = (*aIter).second; + PropertyInfo const * pInfo = elem.second; pProperties->Name = pInfo->maName; pProperties->Handle = pInfo->mnHandle; pProperties->Type = pInfo->maType; pProperties->Attributes = pInfo->mnAttributes; + ++pProperties; } } return maProperties; diff --git a/comphelper/source/property/MasterPropertySetInfo.cxx b/comphelper/source/property/MasterPropertySetInfo.cxx index 35a9a5faee1d..fc94d8436ce9 100644 --- a/comphelper/source/property/MasterPropertySetInfo.cxx +++ b/comphelper/source/property/MasterPropertySetInfo.cxx @@ -68,14 +68,15 @@ Sequence< ::Property > SAL_CALL MasterPropertySetInfo::getProperties() maProperties.realloc ( nSize ); Property* pProperties = maProperties.getArray(); - for (PropertyDataHash::const_iterator aIter(maMap.begin()), aEnd(maMap.end()) ; aIter != aEnd; ++aIter, ++pProperties) + for (auto const& elem : maMap) { - PropertyInfo const * pInfo = (*aIter).second->mpInfo; + PropertyInfo const * pInfo = elem.second->mpInfo; pProperties->Name = pInfo->maName; pProperties->Handle = pInfo->mnHandle; pProperties->Type = pInfo->maType; pProperties->Attributes = pInfo->mnAttributes; + ++pProperties; } } return maProperties; diff --git a/comphelper/source/xml/attributelist.cxx b/comphelper/source/xml/attributelist.cxx index 4484424ba89f..4aae17a328b7 100644 --- a/comphelper/source/xml/attributelist.cxx +++ b/comphelper/source/xml/attributelist.cxx @@ -77,11 +77,10 @@ OUString SAL_CALL AttributeList::getValueByIndex(sal_Int16 i) OUString SAL_CALL AttributeList::getTypeByName( const OUString& sName ) { - std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin(); - - for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) { - if( (*ii).sName == sName ) { - return (*ii).sType; + for (auto const& attribute : m_pImpl->vecAttribute) + { + if( attribute.sName == sName ) { + return attribute.sType; } } return OUString(); @@ -89,11 +88,10 @@ OUString SAL_CALL AttributeList::getTypeByName( const OUString& sName ) OUString SAL_CALL AttributeList::getValueByName(const OUString& sName) { - std::vector<struct TagAttribute_Impl>::iterator ii = m_pImpl->vecAttribute.begin(); - - for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) { - if( (*ii).sName == sName ) { - return (*ii).sValue; + for (auto const& attribute : m_pImpl->vecAttribute) + { + if( attribute.sName == sName ) { + return attribute.sValue; } } return OUString(); diff --git a/comphelper/source/xml/xmltools.cxx b/comphelper/source/xml/xmltools.cxx index ace7d2661e3b..e9df23c73e1e 100644 --- a/comphelper/source/xml/xmltools.cxx +++ b/comphelper/source/xml/xmltools.cxx @@ -62,10 +62,9 @@ namespace { static_assert(sizeof(aChaffEncoder) == 256, "this has to cover all chars"); - for (std::vector<sal_uInt8>::iterator aI = rChaff.begin(), aEnd = rChaff.end(); - aI != aEnd; ++aI) + for (auto & elem : rChaff) { - *aI = aChaffEncoder[*aI]; + elem = aChaffEncoder[elem]; } } } |