Remove boost::split
Replaced boost::split with a simple std::string_view-based split to
reduce Boost dependency and template instantiation during compilation
Tested: added UT and verified all tests passed
Change-Id: Icc84794a3d5a98088bdbce032dc76055a035f0dc
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/src/entity_manager/utils.cpp b/src/entity_manager/utils.cpp
index 9e379e9..6f51ec8 100644
--- a/src/entity_manager/utils.cpp
+++ b/src/entity_manager/utils.cpp
@@ -6,9 +6,7 @@
#include "phosphor-logging/lg2.hpp"
#include <boost/algorithm/string/case_conv.hpp>
-#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/replace.hpp>
-#include <boost/algorithm/string/split.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus/match.hpp>
@@ -217,15 +215,14 @@
// operate on the rest
std::string end = strPtr->substr(nextItemIdx);
- std::vector<std::string> split;
- boost::split(split, end, boost::is_any_of(" "));
+ std::vector<std::string> splitResult = split(end, ' ');
// need at least 1 operation and number
- if (split.size() < 2)
+ if (splitResult.size() < 2)
{
lg2::error("Syntax error on template replacement of {STR}", "STR",
*strPtr);
- for (const std::string& data : split)
+ for (const std::string& data : splitResult)
{
lg2::error("{SPLIT} ", "SPLIT", data);
}
@@ -237,8 +234,8 @@
// only do math on numbers.. we might concatenate strings in the
// future, but thats later
int number = std::visit(VariantToIntVisitor(), propValue);
- auto exprBegin = split.begin();
- auto exprEnd = split.end();
+ auto exprBegin = splitResult.begin();
+ auto exprEnd = splitResult.end();
number = expression::evaluate(number, exprBegin, exprEnd);
@@ -250,7 +247,7 @@
ret = replaced;
std::string result = prefix + std::to_string(number);
- while (exprEnd != split.end())
+ while (exprEnd != splitResult.end())
{
result.append(" ").append(*exprEnd++);
}