MCPcopy Create free account
hub / github.com/SaschaWillems/HowToVulkan / SplitString

Function SplitString

source/external/tinyobj/tiny_obj_loader.h:2040–2063  ·  view source on GitHub ↗

Split a string with specified delimiter character and escape character. https://rosettacode.org/wiki/Tokenize_a_string_with_escaping#C.2B.2B

Source from the content-addressed store, hash-verified

2038// Split a string with specified delimiter character and escape character.
2039// https://rosettacode.org/wiki/Tokenize_a_string_with_escaping#C.2B.2B
2040static void SplitString(const std::string &s, char delim, char escape,
2041 std::vector<std::string> &elems) {
2042 std::string token;
2043
2044 bool escaping = false;
2045 for (size_t i = 0; i < s.size(); ++i) {
2046 char ch = s[i];
2047 if (escaping) {
2048 escaping = false;
2049 } else if (ch == escape) {
2050 escaping = true;
2051 continue;
2052 } else if (ch == delim) {
2053 if (!token.empty()) {
2054 elems.push_back(token);
2055 }
2056 token.clear();
2057 continue;
2058 }
2059 token += ch;
2060 }
2061
2062 elems.push_back(token);
2063}
2064
2065static std::string JoinPath(const std::string &dir,
2066 const std::string &filename) {

Callers 2

LoadObjFunction · 0.85
LoadObjWithCallbackFunction · 0.85

Calls 1

clearMethod · 0.80

Tested by

no test coverage detected