Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
StringUtils.cxx
Go to the documentation of this file.
1/// \file ROOT/StringUtils.hxx
2/// \ingroup Base StdExt
3/// \author Jonas Rembser <jonas.rembser@cern.ch>
4/// \date 2021-08-09
5
6/*************************************************************************
7 * Copyright (C) 1995-2019, Rene Brun and Fons Rademakers. *
8 * All rights reserved. *
9 * *
10 * For the licensing terms see $ROOTSYS/LICENSE. *
11 * For the list of contributors see $ROOTSYS/README/CREDITS. *
12 *************************************************************************/
13
14#include "ROOT/StringUtils.hxx"
15
16namespace ROOT {
17
18/// Splits a string at each character in delims.
19/// The behavior mimics `str.split` from Python,
20/// \param[in] str String to tokenise.
21/// \param[in] delims One or more delimiters used to split the string.
22/// \param[in] skipEmpty Strip empty strings from the output.
23std::vector<std::string> Split(std::string_view str, std::string_view delims, bool skipEmpty /* =false */)
24{
25 std::vector<std::string> out;
26
27 std::size_t beg = 0;
28 std::size_t end = 0;
29 while ((end = str.find_first_of(delims, beg)) != std::string::npos) {
30 if (!skipEmpty || end > beg)
31 out.emplace_back(str.substr(beg, end - beg));
32 beg = end + 1;
33 }
34 if (!skipEmpty || str.size() > beg)
35 out.emplace_back(str.substr(beg, str.size() - beg));
36
37 return out;
38}
39
40} // namespace ROOT
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
#define Split(a, ahi, alo)
Definition triangle.c:4776