MCPcopy Create free account
hub / github.com/Siv3D/OpenSiv3D / SplitString

Function SplitString

Siv3D/src/ThirdParty/tinyobjloader/tiny_obj_loader.h:1783–1806  ·  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

1781// Split a string with specified delimiter character and escape character.
1782// https://rosettacode.org/wiki/Tokenize_a_string_with_escaping#C.2B.2B
1783static void SplitString(const std::string &s, char delim, char escape,
1784 std::vector<std::string> &elems) {
1785 std::string token;
1786
1787 bool escaping = false;
1788 for (size_t i = 0; i < s.size(); ++i) {
1789 char ch = s[i];
1790 if (escaping) {
1791 escaping = false;
1792 } else if (ch == escape) {
1793 escaping = true;
1794 continue;
1795 } else if (ch == delim) {
1796 if (!token.empty()) {
1797 elems.push_back(token);
1798 }
1799 token.clear();
1800 continue;
1801 }
1802 token += ch;
1803 }
1804
1805 elems.push_back(token);
1806}
1807
1808static std::string JoinPath(const std::string &dir,
1809 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