Skip to content

v0.2.48..v0.2.49 changeset StringUtils.cpp

Garret Voltz edited this page Oct 2, 2019 · 1 revision
diff --git a/hoot-core/src/main/cpp/hoot/core/util/StringUtils.cpp b/hoot-core/src/main/cpp/hoot/core/util/StringUtils.cpp
index 50a3b74..85ed7d7 100644
--- a/hoot-core/src/main/cpp/hoot/core/util/StringUtils.cpp
+++ b/hoot-core/src/main/cpp/hoot/core/util/StringUtils.cpp
@@ -94,7 +94,8 @@ bool StringUtils::isNumber(const QString& input)
   return isNumber;
 }
 
-std::shared_ptr<boost::property_tree::ptree> StringUtils::jsonStringToPropTree(const QString& jsonStr)
+std::shared_ptr<boost::property_tree::ptree> StringUtils::jsonStringToPropTree(
+  const QString& jsonStr)
 {
   LOG_VART(jsonStr);
   std::stringstream strStrm(jsonStr.toUtf8().constData(), std::ios::in);
@@ -116,7 +117,8 @@ std::shared_ptr<boost::property_tree::ptree> StringUtils::jsonStringToPropTree(c
   return jsonObj;
 }
 
-std::shared_ptr<boost::property_tree::ptree> StringUtils::stringListToJsonStringArray(const QStringList& stringList)
+std::shared_ptr<boost::property_tree::ptree> StringUtils::stringListToJsonStringArray(
+  const QStringList& stringList)
 {
   std::shared_ptr<boost::property_tree::ptree> strArr(new boost::property_tree::ptree());
   for (int i = 0; i < stringList.size(); i++)
@@ -133,4 +135,17 @@ QString StringUtils::getNumberStringPaddedWithZeroes(const int number, const int
   return QString("%1").arg(number, padSize, 10, QChar('0'));
 }
 
+void StringUtils::removeEmptyStrings(QStringList& strings)
+{
+  QStringList output;
+  for (int i = 0; i < strings.size(); i++)
+  {
+    if (!strings.at(i).trimmed().isEmpty())
+    {
+      output.append(strings.at(i));
+    }
+  }
+  strings = output;
+}
+
 }
Clone this wiki locally