-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Move and rename the tokenise() function for splitting strings to core/foundation #8807
Description
In different ROOT components, it is convenient to have a helper function that takes a string, similar to the str.split function that Python has for example:
"a,b,c,d,e".split(",") # returns ['a', 'b', 'c', 'd', 'e']Currently, there is code duplication to provide such a function in separate ROOT components like roofit and hist:
root/hist/hist/src/TFormula.cxx
Line 1678 in dcf9209
std::vector<std::string> tokenise(const std::string &str, const std::string &delims, bool returnEmptyToken) { root/roofit/roofitcore/src/RooHelpers.cxx
Line 67 in dcf9209
std::vector<std::string> tokenise(const std::string &str, const std::string &delims, bool returnEmptyToken /*= true*/) {
As suggested by @Axel-Naumann in #8801 (comment), this general function should be moved into foundation/core to about the code duplication and make the string-splitting functionality available the every ROOT component.
It is still an open question what the name of the function should be (as well as the name of the file it's in), and whether it should return a std::vector<std::string> or std::vector<std::string_view>.