Debian Codegraph @

packages/seacas/libraries/ioss/src/tokenize.C

raw
1 // Copyright(C) 1999-2020 National Technology & Engineering Solutions
2 // of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
3 // NTESS, the U.S. Government retains certain rights in this software.
4 //
5 // See packages/seacas/LICENSE for details
6
7 #include <algorithm>
8 #include <tokenize.h>
9
10 using TokenList = std::vector<std::string>;
11 TokenList Ioss::tokenize(const std::string &str, const std::string &separators, bool allow_empty)
12 {
13 TokenList tokens;
14 auto first = std::begin(str);
15 while (first != std::end(str)) {
16 const auto second =
17 std::find_first_of(first, std::end(str), std::begin(separators), std::end(separators));
18 if (allow_empty || (first != second)) {
19 tokens.emplace_back(first, second);
20 }
21 if (second == std::end(str)) {
22 break;
23 }
24 first = std::next(second);
25 }
26 return tokens;
27 }