diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2018-03-18 10:34:42 +0100 |
---|---|---|
committer | Julien Nabet <serval2412@yahoo.fr> | 2018-03-18 11:33:16 +0100 |
commit | 1e3a5bb9e92aea074d7350ccde0dae5c123e885d (patch) | |
tree | 1244921df6b85b0e7ba81e74043a72251be5070f /idlc | |
parent | 2980e65d9728cfee73c1c49d64e19af50f756521 (diff) |
Use for-range loops in hwpfilter, i18n*, idl* and io
Change-Id: I980464162b73ed9ee0a09acbca1b9050af8d1027
Reviewed-on: https://gerrit.libreoffice.org/51492
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
Diffstat (limited to 'idlc')
-rw-r--r-- | idlc/source/astdump.cxx | 5 | ||||
-rw-r--r-- | idlc/source/astinterface.cxx | 41 | ||||
-rw-r--r-- | idlc/source/astoperation.cxx | 7 | ||||
-rw-r--r-- | idlc/source/astscope.cxx | 20 | ||||
-rw-r--r-- | idlc/source/aststruct.cxx | 22 | ||||
-rw-r--r-- | idlc/source/idlccompile.cxx | 8 | ||||
-rw-r--r-- | idlc/source/idlcmain.cxx | 11 | ||||
-rw-r--r-- | idlc/source/idlcproduce.cxx | 11 | ||||
-rw-r--r-- | idlc/source/parser.y | 60 |
9 files changed, 67 insertions, 118 deletions
diff --git a/idlc/source/astdump.cxx b/idlc/source/astdump.cxx index fbdd7232d893..3d9f472f2c4a 100644 --- a/idlc/source/astdump.cxx +++ b/idlc/source/astdump.cxx @@ -394,13 +394,12 @@ void AstAttribute::dumpExceptions( "void", 0, static_cast< sal_uInt16 >(exceptions.size())); sal_uInt16 exceptionIndex = 0; - for (DeclList::const_iterator i(exceptions.begin()); - i != exceptions.end(); ++i) + for (auto const& elem : exceptions) { writer.setMethodExceptionTypeName( idx, exceptionIndex++, OStringToOUString( - (*i)->getRelativName(), RTL_TEXTENCODING_UTF8)); + elem->getRelativName(), RTL_TEXTENCODING_UTF8)); } } } diff --git a/idlc/source/astinterface.cxx b/idlc/source/astinterface.cxx index c013fc009ebd..991759384869 100644 --- a/idlc/source/astinterface.cxx +++ b/idlc/source/astinterface.cxx @@ -195,21 +195,20 @@ bool AstInterface::dump(RegistryKey& rKey) sal_uInt16 superTypeIndex = 0; sal_uInt16 referenceIndex = 0; - for (InheritedInterfaces::iterator i = m_inheritedInterfaces.begin(); - i != m_inheritedInterfaces.end(); ++i) + for (auto const& elem : m_inheritedInterfaces) { - if (i->isOptional()) { + if (elem.isOptional()) { aBlob.setReferenceData( - referenceIndex++, i->getDocumentation(), RTReferenceType::SUPPORTS, + referenceIndex++, elem.getDocumentation(), RTReferenceType::SUPPORTS, RTFieldAccess::OPTIONAL, OStringToOUString( - i->getInterface()->getRelativName(), + elem.getInterface()->getRelativName(), RTL_TEXTENCODING_UTF8)); } else { aBlob.setSuperTypeName( superTypeIndex++, OStringToOUString( - i->getInterface()->getRelativName(), + elem.getInterface()->getRelativName(), RTL_TEXTENCODING_UTF8)); } } @@ -294,13 +293,11 @@ void AstInterface::checkInheritedInterfaceClashes( checkMemberClashes( doubleDeclarations.members, *i, !mainOptional); } - for (InheritedInterfaces::const_iterator i( - ifc->m_inheritedInterfaces.begin()); - i != ifc->m_inheritedInterfaces.end(); ++i) + for (auto const& elem : ifc->m_inheritedInterfaces) { checkInheritedInterfaceClashes( - doubleDeclarations, seenInterfaces, i->getResolved(), - false, i->isOptional(), mainOptional); + doubleDeclarations, seenInterfaces, elem.getResolved(), + false, elem.isOptional(), mainOptional); } } } @@ -322,13 +319,11 @@ void AstInterface::checkMemberClashes( doubleMembers.push_back(d); } } else if (checkOptional) { - for (VisibleMember::Optionals::const_iterator j( - i->second.optionals.begin()); - j != i->second.optionals.end(); ++j) + for (auto const& elem : i->second.optionals) { - if (j->second->getScopedName() != member->getScopedName()) { + if (elem.second->getScopedName() != member->getScopedName()) { DoubleMemberDeclaration d; - d.first = j->second; + d.first = elem.second; d.second = member; doubleMembers.push_back(d); } @@ -357,11 +352,9 @@ void AstInterface::addVisibleInterface( m_visibleMembers.emplace( (*i)->getLocalName(), VisibleMember(*i)); } - for (InheritedInterfaces::const_iterator i( - ifc->m_inheritedInterfaces.begin()); - i != ifc->m_inheritedInterfaces.end(); ++i) + for (auto const& elem : ifc->m_inheritedInterfaces) { - addVisibleInterface(i->getResolved(), false, i->isOptional()); + addVisibleInterface(elem.getResolved(), false, elem.isOptional()); } } } @@ -380,12 +373,10 @@ void AstInterface::addOptionalVisibleMembers(AstInterface const * ifc) { visible->second.optionals.emplace(ifc->getScopedName(), *i); } } - for (InheritedInterfaces::const_iterator i( - ifc->m_inheritedInterfaces.begin()); - i != ifc->m_inheritedInterfaces.end(); ++i) + for (auto const& elem : ifc->m_inheritedInterfaces) { - if (!i->isOptional()) { - addOptionalVisibleMembers(i->getResolved()); + if (!elem.isOptional()) { + addOptionalVisibleMembers(elem.getResolved()); } } } diff --git a/idlc/source/astoperation.cxx b/idlc/source/astoperation.cxx index 122b4a57992f..4dea37576b24 100644 --- a/idlc/source/astoperation.cxx +++ b/idlc/source/astoperation.cxx @@ -101,16 +101,13 @@ void AstOperation::dumpBlob(typereg::Writer & rBlob, sal_uInt16 index) if ( nExcep ) { - DeclList::iterator iter = m_exceptions.begin(); - DeclList::iterator end = m_exceptions.end(); sal_uInt16 exceptIndex = 0; - while ( iter != end ) + for (auto const& exception : m_exceptions) { rBlob.setMethodExceptionTypeName( index, exceptIndex++, OStringToOUString( - (*iter)->getRelativName(), RTL_TEXTENCODING_UTF8)); - ++iter; + exception->getRelativName(), RTL_TEXTENCODING_UTF8)); } } } diff --git a/idlc/source/astscope.cxx b/idlc/source/astscope.cxx index 86c150fa718f..5fd9d5339d68 100644 --- a/idlc/source/astscope.cxx +++ b/idlc/source/astscope.cxx @@ -196,15 +196,10 @@ AstDeclaration* AstScope::lookupByName(const OString& scopedName) AstDeclaration* AstScope::lookupByNameLocal(const OString& name) const { - DeclList::const_iterator iter(m_declarations.begin()); - DeclList::const_iterator end(m_declarations.end()); - - while ( iter != end ) + for (auto const& declaration : m_declarations) { - AstDeclaration* pDecl = *iter; - if ( pDecl->getLocalName() == name ) - return pDecl; - ++iter; + if ( declaration->getLocalName() == name ) + return declaration; } return nullptr; } @@ -223,20 +218,15 @@ AstDeclaration* AstScope::lookupInInherited(const OString& scopedName) const } // OK, loop through inherited interfaces. Stop when you find it - AstInterface::InheritedInterfaces::const_iterator iter( - pInterface->getAllInheritedInterfaces().begin()); - AstInterface::InheritedInterfaces::const_iterator end( - pInterface->getAllInheritedInterfaces().end()); - while ( iter != end ) + for (auto const& elem : pInterface->getAllInheritedInterfaces()) { - AstInterface const * resolved = iter->getResolved(); + AstInterface const * resolved = elem.getResolved(); AstDeclaration* pDecl = resolved->lookupByNameLocal(scopedName); if ( pDecl ) return pDecl; pDecl = resolved->lookupInInherited(scopedName); if ( pDecl ) return pDecl; - ++iter; } // Not found return nullptr; diff --git a/idlc/source/aststruct.cxx b/idlc/source/aststruct.cxx index 8b683d085f23..a7db14faaf7f 100644 --- a/idlc/source/aststruct.cxx +++ b/idlc/source/aststruct.cxx @@ -30,11 +30,10 @@ AstStruct::AstStruct( , AstScope(NT_struct) , m_pBaseType(pBaseType) { - for (std::vector< OString >::const_iterator i(typeParameters.begin()); - i != typeParameters.end(); ++i) + for (auto const& elem : typeParameters) { m_typeParameters.push_back( - new AstType(NT_type_parameter, *i, nullptr)); + new AstType(NT_type_parameter, elem, nullptr)); } } @@ -50,21 +49,19 @@ AstStruct::AstStruct(const NodeType type, AstStruct::~AstStruct() { - for (DeclList::iterator i(m_typeParameters.begin()); - i != m_typeParameters.end(); ++i) + for (auto const& elem : m_typeParameters) { - delete *i; + delete elem; } } AstDeclaration const * AstStruct::findTypeParameter(OString const & name) const { - for (DeclList::const_iterator i(m_typeParameters.begin()); - i != m_typeParameters.end(); ++i) + for (auto const& elem : m_typeParameters) { - if ((*i)->getLocalName() == name) { - return *i; + if (elem->getLocalName() == name) { + return elem; } } return nullptr; @@ -148,13 +145,12 @@ bool AstStruct::dump(RegistryKey& rKey) } sal_uInt16 index = 0; - for (DeclList::iterator i(m_typeParameters.begin()); - i != m_typeParameters.end(); ++i) + for (auto const& elem : m_typeParameters) { aBlob.setReferenceData( index++, "", RTReferenceType::TYPE_PARAMETER, RTFieldAccess::INVALID, OStringToOUString( - (*i)->getLocalName(), RTL_TEXTENCODING_UTF8)); + elem->getLocalName(), RTL_TEXTENCODING_UTF8)); } sal_uInt32 aBlobSize; diff --git a/idlc/source/idlccompile.cxx b/idlc/source/idlccompile.cxx index 7a065428c1f2..c7e69362ec8a 100644 --- a/idlc/source/idlccompile.cxx +++ b/idlc/source/idlccompile.cxx @@ -317,12 +317,10 @@ sal_Int32 compileFile(const OString * pathname) rtl_uString** pCmdArgs = nullptr; pCmdArgs = static_cast<rtl_uString**>(rtl_allocateZeroMemory(nCmdArgs * sizeof(rtl_uString*))); - ::std::vector< OUString >::iterator iter = lCppArgs.begin(); - ::std::vector< OUString >::iterator end = lCppArgs.end(); int i = 0; - while ( iter != end ) { - pCmdArgs[i++] = (*iter).pData; - ++iter; + for (auto const& elem : lCppArgs) + { + pCmdArgs[i++] = elem.pData; } procError = osl_executeProcess( cpp.pData, pCmdArgs, nCmdArgs, osl_Process_WAIT, diff --git a/idlc/source/idlcmain.cxx b/idlc/source/idlcmain.cxx index 3affd278ad77..0c4ded92be10 100644 --- a/idlc/source/idlcmain.cxx +++ b/idlc/source/idlcmain.cxx @@ -79,13 +79,14 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) options.getProgramName().getStr(), static_cast<int>(files.size()) ); fflush( stdout ); } - for (std::vector< OString >::const_iterator i(files.begin()); - i != files.end() && nErrors == 0; ++i) + for (auto const& elem : files) { - OString sysFileName( convertToAbsoluteSystemPath(*i) ); + if (nErrors) + break; + OString sysFileName( convertToAbsoluteSystemPath(elem) ); if ( !options.quiet() ) - fprintf(stdout, "Compiling: %s\n", (*i).getStr()); + fprintf(stdout, "Compiling: %s\n", elem.getStr()); nErrors = compileFile(&sysFileName); if ( idlc()->getWarningCount() && !options.quiet() ) @@ -93,7 +94,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) options.getProgramName().getStr(), sal::static_int_cast< unsigned long >( idlc()->getWarningCount()), - (*i).getStr()); + elem.getStr()); // prepare output file name OString const strippedFileName( diff --git a/idlc/source/idlcproduce.cxx b/idlc/source/idlcproduce.cxx index 81e6f3abc9e7..f87992d6b859 100644 --- a/idlc/source/idlcproduce.cxx +++ b/idlc/source/idlcproduce.cxx @@ -95,21 +95,18 @@ static bool cleanPath() { if ( pCreatedDirectories ) { - std::list< OString >::iterator iter = pCreatedDirectories->begin(); - std::list< OString >::iterator end = pCreatedDirectories->end(); - while ( iter != end ) + for (auto const& createdDirectory : *pCreatedDirectories) { //#ifdef SAL_UNX -// if (rmdir((char*)(*iter).getStr(), 0777) == -1) +// if (rmdir((char*)createdDirectory.getStr(), 0777) == -1) //#else - if (rmdir((*iter).getStr()) == -1) + if (rmdir(createdDirectory.getStr()) == -1) //#endif { fprintf(stderr, "%s: cannot remove directory '%s'\n", - idlc()->getOptions()->getProgramName().getStr(), (*iter).getStr()); + idlc()->getOptions()->getProgramName().getStr(), createdDirectory.getStr()); return false; } - ++iter; } delete pCreatedDirectories; } diff --git a/idlc/source/parser.y b/idlc/source/parser.y index 0fe8eb8049c1..9cc9e8d5ab5d 100644 --- a/idlc/source/parser.y +++ b/idlc/source/parser.y @@ -96,11 +96,9 @@ void checkIdentifier(::rtl::OString const * id) void reportDoubleMemberDeclarations( AstInterface::DoubleMemberDeclarations const & doubleMembers) { - for (AstInterface::DoubleMemberDeclarations::const_iterator i( - doubleMembers.begin()); - i != doubleMembers.end(); ++i) + for (auto const& doubleMember : doubleMembers) { - ErrorHandler::error2(ErrorCode::DoubleMember, i->first, i->second); + ErrorHandler::error2(ErrorCode::DoubleMember, doubleMember.first, doubleMember.second); } } @@ -127,12 +125,10 @@ void addInheritedInterface( static_cast< AstType * >(decl), optional, documentation); } else { - for (AstInterface::DoubleInterfaceDeclarations::iterator i( - doubleDecls.interfaces.begin()); - i != doubleDecls.interfaces.end(); ++i) + for (auto const& elem : doubleDecls.interfaces) { ErrorHandler::error1( - ErrorCode::DoubleInheritance, *i); + ErrorCode::DoubleInheritance, elem); } reportDoubleMemberDeclarations(doubleDecls.members); } @@ -1618,12 +1614,9 @@ service_export : */ if ( pScope && $2 ) { - std::list< OString >::iterator iter = $2->begin(); - std::list< OString >::iterator end = $2->end(); - - while ( iter != end ) + for (auto const& elem : *($2)) { - pDecl = pScope->lookupByName(*iter); + pDecl = pScope->lookupByName(elem); if ( pDecl && (pDecl->getNodeType() == NT_interface) ) { /* we relax the strict published check and allow to add new @@ -1633,14 +1626,13 @@ service_export : if ( ErrorHandler::checkPublished(pDecl, bOptional) ) { pIMember = new AstInterfaceMember( - $1, static_cast<AstInterface*>(pDecl), *iter, pScope); + $1, static_cast<AstInterface*>(pDecl), elem, pScope); pScope->addDeclaration(pIMember); } } else { - ErrorHandler::lookupError(ErrorCode::InterfaceMemberLookup, *iter, scopeAsDecl(pScope)); + ErrorHandler::lookupError(ErrorCode::InterfaceMemberLookup, elem, scopeAsDecl(pScope)); } - ++iter; } } } @@ -1662,12 +1654,9 @@ service_export : */ if ( pScope && $2 ) { - std::list< OString >::iterator iter = $2->begin(); - std::list< OString >::iterator end = $2->end(); - - while ( iter != end ) + for (auto const& elem : *($2)) { - pDecl = pScope->lookupByName(*iter); + pDecl = pScope->lookupByName(elem); if ( pDecl && (pDecl->getNodeType() == NT_service) ) { if ( static_cast< AstService * >(pDecl)->isSingleInterfaceBasedService() || (pScope->getScopeNodeType() == NT_singleton && pScope->nMembers() > 0) ) @@ -1675,14 +1664,13 @@ service_export : else if ( ErrorHandler::checkPublished(pDecl) ) { pSMember = new AstServiceMember( - $1, static_cast<AstService*>(pDecl), *iter, pScope); + $1, static_cast<AstService*>(pDecl), elem, pScope); pScope->addDeclaration(pSMember); } } else { - ErrorHandler::lookupError(ErrorCode::ServiceMemberLookup, *iter, scopeAsDecl(pScope)); + ErrorHandler::lookupError(ErrorCode::ServiceMemberLookup, elem, scopeAsDecl(pScope)); } - ++iter; } } delete $2; @@ -1708,21 +1696,17 @@ service_export : */ if ( pScope && $2 ) { - std::list< OString >::iterator iter = $2->begin(); - std::list< OString >::iterator end = $2->end(); - - while ( iter != end ) + for (auto const& elem : *($2)) { - pDecl = pScope->lookupByName(*iter); + pDecl = pScope->lookupByName(elem); if ( pDecl && (pDecl->getNodeType() == NT_interface) ) { - pObserves = new AstObserves(static_cast<AstInterface*>(pDecl), *iter, pScope); + pObserves = new AstObserves(static_cast<AstInterface*>(pDecl), elem, pScope); pScope->addDeclaration(pObserves); } else { - ErrorHandler::lookupError(ErrorCode::InterfaceMemberLookup, *iter, scopeAsDecl(pScope)); + ErrorHandler::lookupError(ErrorCode::InterfaceMemberLookup, elem, scopeAsDecl(pScope)); } - ++iter; } } } @@ -1749,21 +1733,17 @@ service_export : */ if ( pScope && $2 ) { - std::list< OString >::iterator iter = $2->begin(); - std::list< OString >::iterator end = $2->end(); - - while ( iter != end ) + for (auto const& elem : *($2)) { - pDecl = pScope->lookupByName(*iter); + pDecl = pScope->lookupByName(elem); if ( pDecl && (pDecl->getNodeType() == NT_service) ) { - pNeeds = new AstNeeds(static_cast<AstService*>(pDecl), *iter, pScope); + pNeeds = new AstNeeds(static_cast<AstService*>(pDecl), elem, pScope); pScope->addDeclaration(pNeeds); } else { - ErrorHandler::lookupError(ErrorCode::ServiceMemberLookup, *iter, scopeAsDecl(pScope)); + ErrorHandler::lookupError(ErrorCode::ServiceMemberLookup, elem, scopeAsDecl(pScope)); } - ++iter; } } } |