adamdebreceni commented on a change in pull request #1073:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1073#discussion_r645542861
##########
File path: libminifi/include/utils/StringUtils.h
##########
@@ -137,6 +137,7 @@ class StringUtils {
static std::vector<std::string> split(const std::string &str, const
std::string &delimiter);
static std::vector<std::string> splitAndTrim(const std::string &str, const
std::string &delimiter);
+ static std::vector<std::string> splitAndTrimOnString(std::string str, const
std::string& delimiter);
Review comment:
wow this is "great", I wondered why the following test passed knowing
this:
```
TEST_CASE("TestStringUtils::split4", "[test split classname]") {
std::vector<std::string> expected = { "org", "apache", "nifi", "minifi",
"utils", "StringUtils" };
REQUIRE(expected ==
StringUtils::split(org::apache::nifi::minifi::core::getClassName<org::apache::nifi::minifi::utils::StringUtils>(),
"::"));
}
```
turns out two wrongs make a right here :D
the current implementation implicitly discards zero length segments, so
`split("a,,b", ",") == ["a", "b"]` instead of `["a", "", "b"]`, I would
definitely change this, I would keep a single function with `std::string`
delimiter but with the "correct" semantics, if we would like to interpret each
character as a delimiter later, we could add a `splitAny` or something along
those lines
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]