MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / Split

Function Split

SampleFramework12/v1.00/Utility.h:38–57  ·  view source on GitHub ↗

Splits up a string using a delimiter

Source from the content-addressed store, hash-verified

36
37// Splits up a string using a delimiter
38inline void Split(const std::wstring& str, std::vector<std::wstring>& parts, const std::wstring& delimiters = L" ")
39{
40 // Skip delimiters at beginning
41 std::wstring::size_type lastPos = str.find_first_not_of(delimiters, 0);
42
43 // Find first "non-delimiter"
44 std::wstring::size_type pos = str.find_first_of(delimiters, lastPos);
45
46 while (std::wstring::npos != pos || std::wstring::npos != lastPos)
47 {
48 // Found a token, add it to the vector
49 parts.push_back(str.substr(lastPos, pos - lastPos));
50
51 // Skip delimiters. Note the "not_of"
52 lastPos = str.find_first_not_of(delimiters, pos);
53
54 // Find next "non-delimiter"
55 pos = str.find_first_of(delimiters, lastPos);
56 }
57}
58
59// Splits up a string using a delimiter
60inline std::vector<std::wstring> Split(const std::wstring& str, const std::wstring& delimiters = L" ")

Callers

nothing calls this directly

Calls 1

push_backMethod · 0.80

Tested by

no test coverage detected