diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-10-12 20:32:17 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-05-30 16:22:30 +0200 |
commit | ad4105e469bd80176e51919c32af19fe3cd37c3c (patch) | |
tree | 4aff6b3ca2d776bad9bf0b8fcdc2f2854be7fa93 | |
parent | e19635027d39cda6b7ee4da5d6c7e974be17968a (diff) |
Use loop ranges in jvmfwk
to simplify and avoid all the typedefs
(cherry picked from commit 2ea531c0578bb7f0a34ec7de0aaea595e0387928)
Conflicts:
jvmfwk/plugins/sunmajor/pluginlib/gnujre.cxx
jvmfwk/plugins/sunmajor/pluginlib/util.cxx
Change-Id: Ia14337dd71b55fc24f162b5436af76aeeb8d2575
Reviewed-on: https://gerrit.libreoffice.org/43346
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 40 | ||||
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx | 37 | ||||
-rw-r--r-- | jvmfwk/source/elements.cxx | 15 | ||||
-rw-r--r-- | jvmfwk/source/framework.cxx | 26 |
4 files changed, 47 insertions, 71 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 1f4dac0e9e25..0db41bec8e87 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -310,31 +310,28 @@ javaPluginError jfw_plugin_getAllJavaInfos( addAllJREInfos(checkJavaHomeAndPath, infos); vector<rtl::Reference<VendorBase> > vecVerifiedInfos; - typedef vector<rtl::Reference<VendorBase> >::iterator it; - for (it i= vecInfos.begin(); i != vecInfos.end(); ++i) + for (auto const& vecInfo : vecInfos) { - const rtl::Reference<VendorBase>& cur = *i; - if (sVendor != cur->getVendor()) + if (sVendor != vecInfo->getVendor()) continue; javaPluginError err = checkJavaVersionRequirements( - cur, sMinVersion, sMaxVersion, arExcludeList); + vecInfo, sMinVersion, sMaxVersion, arExcludeList); if (err == javaPluginError::FailedVersion || err == javaPluginError::WrongArch) continue; else if (err == javaPluginError::WrongVersionFormat) return err; - vecVerifiedInfos.push_back(*i); + vecVerifiedInfos.push_back(vecInfo); } //Now vecVerifiedInfos contains all those JREs which meet the version requirements //Transfer them into the array that is passed out. parJavaInfo->clear(); - typedef vector<rtl::Reference<VendorBase> >::const_iterator cit; - for (cit ii = vecVerifiedInfos.begin(); ii != vecVerifiedInfos.end(); ++ii) + for (auto const& vecVerifiedInfo : vecVerifiedInfos) { - parJavaInfo->push_back(createJavaInfo(*ii)); + parJavaInfo->push_back(createJavaInfo(vecVerifiedInfo)); } return javaPluginError::NONE; @@ -388,11 +385,10 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome( assert(infoJavaHome.size() == 1); //Check if the detected JRE matches the version requirements - typedef std::vector<pair<OUString, jfw::VersionInfo>>::const_iterator ci_pl; - for (ci_pl vendorInfo = vecVendorInfos.begin(); vendorInfo != vecVendorInfos.end(); ++vendorInfo) + for (auto const& vendorInfo : vecVendorInfos) { - const OUString& vendor = vendorInfo->first; - jfw::VersionInfo versionInfo = vendorInfo->second; + const OUString& vendor = vendorInfo.first; + jfw::VersionInfo versionInfo = vendorInfo.second; if (vendor == infoJavaHome[0]->getVendor()) { @@ -425,28 +421,24 @@ javaPluginError jfw_plugin_getJavaInfosFromPath( vector<std::unique_ptr<JavaInfo>> vecVerifiedInfos; // copy infos of JREs that meet version requirements to vecVerifiedInfos - typedef vector<rtl::Reference<VendorBase> >::iterator it; - for (it i= vecInfosFromPath.begin(); i != vecInfosFromPath.end(); ++i) + for (auto const& infosFromPath : vecInfosFromPath) { - const rtl::Reference<VendorBase>& currentInfo = *i; - - typedef std::vector<pair<OUString, jfw::VersionInfo>>::const_iterator ci_pl; - for (ci_pl vendorInfo = vecVendorInfos.begin(); vendorInfo != vecVendorInfos.end(); ++vendorInfo) + for (auto const& vendorInfo : vecVendorInfos) { - const OUString& vendor = vendorInfo->first; - jfw::VersionInfo const & versionInfo = vendorInfo->second; + const OUString& vendor = vendorInfo.first; + jfw::VersionInfo const & versionInfo = vendorInfo.second; - if (vendor == currentInfo->getVendor()) + if (vendor == infosFromPath->getVendor()) { javaPluginError errorcode = checkJavaVersionRequirements( - currentInfo, + infosFromPath, versionInfo.sMinVersion, versionInfo.sMaxVersion, versionInfo.vecExcludeVersions); if (errorcode == javaPluginError::NONE) { - vecVerifiedInfos.push_back(createJavaInfo(currentInfo)); + vecVerifiedInfos.push_back(createJavaInfo(infosFromPath)); } } } diff --git a/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx b/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx index 1f7423045bc1..92be3f3c96db 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/vendorbase.cxx @@ -58,32 +58,29 @@ bool VendorBase::initialize(vector<pair<OUString, OUString> > props) //get java.vendor, java.version, java.home, //javax.accessibility.assistive_technologies from system properties - typedef vector<pair<OUString, OUString> >::const_iterator it_prop; - bool bVersion = false; bool bVendor = false; bool bHome = false; bool bAccess = false; bool bArch = false; - typedef vector<pair<OUString, OUString> >::const_iterator it_prop; - for (it_prop i = props.begin(); i != props.end(); ++i) + for (auto const& prop : props) { - if(! bVendor && i->first == "java.vendor") + if(! bVendor && prop.first == "java.vendor") { - m_sVendor = i->second; + m_sVendor = prop.second; bVendor = true; } - else if (!bVersion && i->first == "java.version") + else if (!bVersion && prop.first == "java.version") { - m_sVersion = i->second; + m_sVersion = prop.second; bVersion = true; } - else if (!bHome && i->first == "java.home") + else if (!bHome && prop.first == "java.home") { #ifndef JVM_ONE_PATH_CHECK OUString fileURL; - if (osl_getFileURLFromSystemPath(i->second.pData,& fileURL.pData) == + if (osl_getFileURLFromSystemPath(prop.second.pData,& fileURL.pData) == osl_File_E_None) { //make sure that the drive letter have all the same case @@ -96,19 +93,19 @@ bool VendorBase::initialize(vector<pair<OUString, OUString> > props) } } #else - m_sHome = i->second; + m_sHome = prop.second; bHome = true; #endif } - else if (!bArch && i->first == "os.arch") + else if (!bArch && prop.first == "os.arch") { - m_sArch = i->second; + m_sArch = prop.second; bArch = true; } else if (!bAccess - && i->first == "javax.accessibility.assistive_technologies") + && prop.first == "javax.accessibility.assistive_technologies") { - if (!i->second.isEmpty()) + if (!prop.second.isEmpty()) { m_bAccessibility = true; bAccess = true; @@ -130,11 +127,10 @@ bool VendorBase::initialize(vector<pair<OUString, OUString> > props) vector<OUString> libpaths = getVectorFromCharArray(arRtPaths, size); bool bRt = false; - typedef vector<OUString>::const_iterator i_path; - for(i_path ip = libpaths.begin(); ip != libpaths.end(); ++ip) + for (auto const& libpath : libpaths) { //Construct an absolute path to the possible runtime - OUString usRt= m_sHome + *ip; + OUString usRt= m_sHome + libpath; DirectoryItem item; if(DirectoryItem::get(usRt, item) == File::E_None) { @@ -157,9 +153,9 @@ bool VendorBase::initialize(vector<pair<OUString, OUString> > props) OUString sPathSep= OUString::createFromAscii(arSep); bool bLdPath = true; int c = 0; - for(i_path il = ld_paths.begin(); il != ld_paths.end(); ++il, ++c) + for (auto const& ld_path : ld_paths) { - OUString usAbsUrl= m_sHome + *il; + OUString usAbsUrl= m_sHome + ld_path; // convert to system path OUString usSysPath; if(File::getSystemPathFromFileURL(usAbsUrl, usSysPath) == File::E_None) @@ -174,6 +170,7 @@ bool VendorBase::initialize(vector<pair<OUString, OUString> > props) bLdPath = false; break; } + ++c; } return bLdPath; } diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index 353eab37ba6f..c72870cb6c6f 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -496,11 +496,10 @@ void NodeJava::write() const xmlAddChild(vmParameters, nodeCrLf); } - typedef std::vector<OUString>::const_iterator cit; - for (cit i = m_vmParameters->begin(); i != m_vmParameters->end(); ++i) + for (auto const & vmParameter : *m_vmParameters) { xmlNewTextChild(vmParameters, nullptr, reinterpret_cast<xmlChar const *>("param"), - CXmlCharPtr(*i)); + CXmlCharPtr(vmParameter)); //add a new line xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n")); xmlAddChild(vmParameters, nodeCrLf); @@ -537,11 +536,10 @@ void NodeJava::write() const xmlAddChild(jreLocationsNode, nodeCrLf); } - typedef std::vector<OUString>::const_iterator cit; - for (cit i = m_JRELocations->begin(); i != m_JRELocations->end(); ++i) + for (auto const & JRELocation : *m_JRELocations) { xmlNewTextChild(jreLocationsNode, nullptr, reinterpret_cast<xmlChar const *>("location"), - CXmlCharPtr(*i)); + CXmlCharPtr(JRELocation)); //add a new line xmlNode * nodeCrLf = xmlNewText(reinterpret_cast<xmlChar const *>("\n")); xmlAddChild(jreLocationsNode, nodeCrLf); @@ -989,10 +987,9 @@ void MergedSettings::merge(const NodeJava & share, const NodeJava & user) ::std::vector< OString> MergedSettings::getVmParametersUtf8() const { ::std::vector< OString> ret; - typedef ::std::vector< OUString>::const_iterator cit; - for (cit i = m_vmParams.begin(); i != m_vmParams.end(); ++i) + for (auto const & vmParam : m_vmParams) { - ret.push_back( OUStringToOString(*i, RTL_TEXTENCODING_UTF8)); + ret.push_back( OUStringToOString(vmParam, RTL_TEXTENCODING_UTF8)); } return ret; } diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 5d401a0486ca..a1a0fe47fd5a 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -264,10 +264,9 @@ javaFrameworkError jfw_startVM( //add the options set by options dialog int index = 2; - typedef std::vector<OString>::const_iterator cit; - for (cit i = vmParams.begin(); i != vmParams.end(); ++i) + for (auto const & vmParam : vmParams) { - arOpt[index].optionString = const_cast<sal_Char*>(i->getStr()); + arOpt[index].optionString = const_cast<sal_Char*>(vmParam.getStr()); arOpt[index].extraInfo = nullptr; index ++; } @@ -344,10 +343,8 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) // save vendors and respective version requirements pair-wise in a vector std::vector<std::pair<OUString, jfw::VersionInfo>> versionInfos; - typedef std::vector<OUString>::const_iterator ciVendor; - for (ciVendor i = vecVendors.begin(); i != vecVendors.end(); ++i) + for (auto const & vendor : vecVendors) { - const OUString & vendor = *i; jfw::VersionInfo versionInfo = aVendorSettings.getVersionInformation(vendor); @@ -409,10 +406,8 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) { //Use every vendor to get Java installations. At the first usable //Java the loop will break - typedef std::vector<OUString>::const_iterator ci_pl; - for (ci_pl i = vecVendors.begin(); i != vecVendors.end(); ++i) + for (auto const & vendor : vecVendors) { - const OUString & vendor = *i; jfw::VersionInfo versionInfo = aVendorSettings.getVersionInformation(vendor); @@ -467,19 +462,16 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) const std::vector<OUString> & vecJRELocations = settings.getJRELocations(); //use every plug-in to determine the JavaInfo objects - for (ci_pl i = vecVendors.begin(); i != vecVendors.end(); ++i) + for (auto const & vendor : vecVendors) { - const OUString & vendor = *i; jfw::VersionInfo versionInfo = aVendorSettings.getVersionInformation(vendor); - typedef std::vector<OUString>::const_iterator citLoc; - for (citLoc it = vecJRELocations.begin(); - it != vecJRELocations.end(); ++it) + for (auto const & JRELocation : vecJRELocations) { std::unique_ptr<JavaInfo> aInfo; javaPluginError err = jfw_plugin_getJavaInfoByPath( - *it, + JRELocation, vendor, versionInfo.sMinVersion, versionInfo.sMaxVersion, @@ -634,10 +626,8 @@ javaFrameworkError jfw_getJavaInfoByPath(OUString const & pPath, std::unique_ptr //Use every plug-in library to determine if the path represents a //JRE. If a plugin recognized it then the loop will break - typedef std::vector<OUString>::const_iterator ci_pl; - for (ci_pl i = vecVendors.begin(); i != vecVendors.end(); ++i) + for (auto const & vendor : vecVendors) { - const OUString & vendor = *i; jfw::VersionInfo versionInfo = aVendorSettings.getVersionInformation(vendor); |