MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / parseStringArray

Function parseStringArray

engine/Evaluator/Validate.cpp:300–342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

298}
299
300static std::vector<std::string> parseStringArray(const std::string& arr)
301{
302 std::vector<std::string> result;
303 size_t pos = 0;
304 while (true)
305 {
306 pos = arr.find('"', pos);
307 if (pos == std::string::npos)
308 break;
309 pos++;
310 size_t end = pos;
311 // handle escaped quotes
312 while (end < arr.size())
313 {
314 if (arr[end] == '\\')
315 {
316 end += 2;
317 continue;
318 }
319 if (arr[end] == '"')
320 break;
321 end++;
322 }
323 if (end >= arr.size())
324 break;
325 std::string s = arr.substr(pos, end - pos);
326 // unescape
327 std::string unesc;
328 for (size_t i = 0; i < s.size(); i++)
329 {
330 if (s[i] == '\\' && i + 1 < s.size())
331 {
332 unesc += s[i + 1];
333 i++;
334 }
335 else
336 unesc += s[i];
337 }
338 result.push_back(unesc);
339 pos = end + 1;
340 }
341 return result;
342}
343
344static std::string extractJsonString(const std::string& json, const std::string& key)
345{

Callers 1

validateRefFunction · 0.85

Calls 1

sizeMethod · 0.80

Tested by

no test coverage detected