MCPcopy Create free account
hub / github.com/ariccio/altWinDirStat / SplitString

Function SplitString

Reference code/osImageTool/stringutils.cpp:76–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76bool SplitString(const string& str, StringList& strlist, bool bWithEscape/*= true*/)
77{
78 string::const_iterator pos= str.begin();
79 bool bQuoted= false;
80 bool bEscaped= false;
81 string current;
82
83 while (pos != str.end())
84 {
85 if (bEscaped)
86 {
87 current += *pos++;
88 bEscaped= false;
89 }
90 else if (bQuoted)
91 {
92 switch(*pos)
93 {
94 case '"':
95 bQuoted= false;
96 strlist.push_back(string(current));
97 //debug("added %hs\n", current.c_str());
98 current.clear();
99 ++pos;
100 break;
101 case '\\':
102 if (bWithEscape)
103 {
104 bEscaped= true;
105 ++pos; // skip escaped char
106 }
107 // else fall through
108 default:
109 current += *pos++;
110 }
111 }
112 else // not escaped, and not quoted
113 {
114 switch(*pos)
115 {
116 case ' ':
117 case '\t':
118 ++pos;
119 if (!current.empty())
120 {
121 strlist.push_back(string(current));
122 //debug("added %hs\n", current.c_str());
123 current.clear();
124 }
125 break;
126
127 case '"':
128 bQuoted=true;
129 ++pos;
130 break;
131 case '\\':
132 if (bWithEscape) {
133 bEscaped= true;

Callers 1

ParseCommandLineMethod · 0.85

Calls 4

debugFunction · 0.85
beginMethod · 0.80
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected