MCPcopy Create free account
hub / github.com/BoomingTech/Piccolo / SplitString

Function SplitString

engine/3rdparty/tinyobjloader/tiny_obj_loader.h:1886–1909  ·  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

1884// Split a string with specified delimiter character and escape character.
1885// https://rosettacode.org/wiki/Tokenize_a_string_with_escaping#C.2B.2B
1886static void SplitString(const std::string &s, char delim, char escape,
1887 std::vector<std::string> &elems) {
1888 std::string token;
1889
1890 bool escaping = false;
1891 for (size_t i = 0; i < s.size(); ++i) {
1892 char ch = s[i];
1893 if (escaping) {
1894 escaping = false;
1895 } else if (ch == escape) {
1896 escaping = true;
1897 continue;
1898 } else if (ch == delim) {
1899 if (!token.empty()) {
1900 elems.push_back(token);
1901 }
1902 token.clear();
1903 continue;
1904 }
1905 token += ch;
1906 }
1907
1908 elems.push_back(token);
1909}
1910
1911static std::string JoinPath(const std::string &dir,
1912 const std::string &filename) {

Callers 2

LoadObjFunction · 0.85
LoadObjWithCallbackFunction · 0.85

Calls 4

sizeMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected