summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2017-08-15 09:40:47 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-08-15 09:40:47 +0200
commit774b98ef779275765c0ae7ed121735f9dc90b79b (patch)
tree7980a19e6a3fb9bdf818883ac2f6abf218ab639c
parent9ac3671bb3e1010ed13dbb3b32bd0bbdcd01f7e6 (diff)
Convert explicit for loops to range-based ones where possible
Makes the code a few lines shorter. Change-Id: I39eb3b0c26dac6daf50750ba72823b2dbfd38c2d
-rw-r--r--src/lib/ABWCollector.cpp6
-rw-r--r--src/lib/ABWContentCollector.cpp19
-rw-r--r--src/lib/ABWOutputElements.cpp5
3 files changed, 14 insertions, 16 deletions
diff --git a/src/lib/ABWCollector.cpp b/src/lib/ABWCollector.cpp
index 1bfb918..2f83514 100644
--- a/src/lib/ABWCollector.cpp
+++ b/src/lib/ABWCollector.cpp
@@ -32,11 +32,11 @@ void libabw::parsePropString(const std::string &str, ABWPropertyMap &props)
std::string propString(boost::trim_copy(str));
std::vector<std::string> strVec;
boost::algorithm::split(strVec, propString, boost::is_any_of(";"), boost::token_compress_on);
- for (std::vector<std::string>::size_type i = 0; i < strVec.size(); ++i)
+ for (auto &i : strVec)
{
- boost::algorithm::trim(strVec[i]);
+ boost::algorithm::trim(i);
std::vector<std::string> tmpVec;
- boost::algorithm::split(tmpVec, strVec[i], boost::is_any_of(":"), boost::token_compress_on);
+ boost::algorithm::split(tmpVec, i, boost::is_any_of(":"), boost::token_compress_on);
if (tmpVec.size() == 2)
props[tmpVec[0]] = tmpVec[1];
}
diff --git a/src/lib/ABWContentCollector.cpp b/src/lib/ABWContentCollector.cpp
index af9717e..d133445 100644
--- a/src/lib/ABWContentCollector.cpp
+++ b/src/lib/ABWContentCollector.cpp
@@ -126,12 +126,12 @@ void parseTableColumns(const std::string &str, librevenge::RVNGPropertyListVecto
std::vector<std::string> strVec;
boost::algorithm::split(strVec, propString, boost::is_any_of("/"), boost::token_compress_on);
- for (std::vector<std::string>::size_type i = 0; i < strVec.size(); ++i)
+ for (auto &i : strVec)
{
ABWUnit unit(ABW_NONE);
double value(0.0);
- boost::algorithm::trim(strVec[i]);
- if (findDouble(strVec[i], value, unit) || ABW_IN != unit)
+ boost::algorithm::trim(i);
+ if (findDouble(i, value, unit) || ABW_IN != unit)
{
librevenge::RVNGPropertyList propList;
propList.insert("style:column-width", value);
@@ -207,11 +207,11 @@ void parseTabStops(const std::string &str, librevenge::RVNGPropertyListVector &t
std::string sTabStops(boost::trim_copy_if(str, boost::is_any_of(", ")));
std::vector<std::string> strVec;
boost::algorithm::split(strVec, sTabStops, boost::is_any_of(","), boost::token_compress_on);
- for (std::vector<std::string>::size_type i = 0; i < strVec.size(); ++i)
+ for (auto &i : strVec)
{
- boost::trim(strVec[i]);
+ boost::trim(i);
librevenge::RVNGPropertyList tabStop;
- if (parseTabStop(strVec[i], tabStop))
+ if (parseTabStop(i, tabStop))
tabStops.append(tabStop);
}
}
@@ -462,8 +462,8 @@ void libabw::ABWContentCollector::_recurseTextProperties(const char *name, ABWPr
_recurseTextProperties(iter->second.basedon.c_str(), styleProps);
if (iter != m_textStyles.end())
{
- for (ABWPropertyMap::const_iterator i = iter->second.properties.begin(); i != iter->second.properties.end(); ++i)
- styleProps[i->first] = i->second;
+ for (const auto &propertie : iter->second.properties)
+ styleProps[propertie.first] = propertie.second;
}
// Styles based on "Heading X" style are recognized as headings.
@@ -1283,9 +1283,8 @@ void libabw::ABWContentCollector::_openSpan()
sValue = _findCharacterProperty("text-decoration");
std::vector<std::string> listDecorations;
boost::split(listDecorations, sValue, boost::is_any_of(" "), boost::token_compress_on);
- for (size_t j=0; j<listDecorations.size(); ++j)
+ for (const auto &decoration : listDecorations)
{
- std::string const &decoration=listDecorations[j];
if (decoration == "underline")
{
propList.insert("style:text-underline-type", "single");
diff --git a/src/lib/ABWOutputElements.cpp b/src/lib/ABWOutputElements.cpp
index 35e8ae0..53b08ee 100644
--- a/src/lib/ABWOutputElements.cpp
+++ b/src/lib/ABWOutputElements.cpp
@@ -821,9 +821,8 @@ void libabw::ABWOpenPageSpanElement::_writeElements(librevenge::RVNGTextInterfac
if (iterMap == elements->end() || iterMap->second.empty())
return;
- for (OutputElements_t::const_iterator iterVec = iterMap->second.begin();
- iterVec != iterMap->second.end(); ++iterVec)
- (*iterVec)->write(iface, nullptr, nullptr);
+ for (const auto &iterVec : iterMap->second)
+ iterVec->write(iface, nullptr, nullptr);
}
void libabw::ABWOpenParagraphElement::write(librevenge::RVNGTextInterface *iface,