aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Monahan <david.monahan@arm.com>2020-04-22 11:28:23 +0100
committerDavid Monahan <david.monahan@arm.com>2020-04-22 11:28:23 +0100
commit6544f40295e93fbb8d25582bd3a94341537ec6ca (patch)
tree9642fcffc9152cbb8b8c3e383a4ba80d2da1933d
parent60bf0ae9f43f15a89b57d6c8b4377503b5684c1c (diff)
downloadarmnn-6544f40295e93fbb8d25582bd3a94341537ec6ca.tar.gz
IVGCVSW-4718 Fix failing Execute Network Tests
* Fix for StringTokenizer utility method to match Boost::Split implementation Signed-off-by: David Monahan <david.monahan@arm.com> Change-Id: I50e047ff72191da9aa06b71370c4354c5a78eb9b
-rw-r--r--include/armnn/utility/StringUtils.hpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/include/armnn/utility/StringUtils.hpp b/include/armnn/utility/StringUtils.hpp
index c56a215b83..cc5e8e7349 100644
--- a/include/armnn/utility/StringUtils.hpp
+++ b/include/armnn/utility/StringUtils.hpp
@@ -16,38 +16,38 @@ namespace stringUtils
/// Function to take a string and a list of delimiters and split the string into tokens based on those delimiters
/// This assumes that tokens are also to be split by newlines
-/// Enabling token compression causes this to ignore multiple concurrent delimiters
+/// Enabling tokenCompression merges adjacent delimiters together, preventing empty tokens
inline std::vector<std::string> StringTokenizer(const std::string& str,
const char* delimiters,
bool tokenCompression = true)
{
std::stringstream stringStream(str);
std::string line;
- std::vector<std::string> wordVector;
+ std::vector<std::string> tokenVector;
while (std::getline(stringStream, line))
{
std::size_t prev = 0;
std::size_t pos;
while ((pos = line.find_first_of(delimiters, prev)) != std::string::npos)
{
+ // Ignore adjacent tokens
if (pos > prev)
{
- // If token compression is enabled ignore delimiters that are next to each other
- if (tokenCompression && (pos - prev == 1))
- {
- prev = pos + 1;
- continue;
- }
- wordVector.push_back(line.substr(prev, pos - prev));
+ tokenVector.push_back(line.substr(prev, pos - prev));
+ }
+ // Unless token compression is disabled
+ else if (!tokenCompression)
+ {
+ tokenVector.push_back(line.substr(prev, pos - prev));
}
prev = pos + 1;
}
if (prev < line.length())
{
- wordVector.push_back(line.substr(prev, std::string::npos));
+ tokenVector.push_back(line.substr(prev, std::string::npos));
}
}
- return wordVector;
+ return tokenVector;
}
// Set of 3 utility functions for trimming std::strings