MCPcopy Create free account
hub / github.com/VerySleepy/verysleepy / readQuote

Function readQuote

src/utils/stringutils.cpp:271–308  ·  view source on GitHub ↗

Reads string from between double quotes.

Source from the content-addressed store, hash-verified

269
270// Reads string from between double quotes.
271void readQuote(std::wistream& stream, std::wstring& str_out)
272{
273 wchar_t c;
274 str_out = L"";
275
276 // Parse to first "
277 for (;;)
278 {
279 stream.get(c);
280 enforce(stream.good(), "Expected quoted string, got end of stream");
281 if (c == '"')
282 break;
283 enforce(isspace(c), std::wstring(L"Expected quoted string, got ") + c);
284 }
285
286 // Parse quoted text
287 bool escaping = false;
288 for (;;)
289 {
290 stream.get(c);
291 enforce(stream.good(), "Unexpected end of stream while reading quoted string");
292 if (escaping)
293 {
294 str_out.push_back(c);
295 escaping = false;
296 }
297 else
298 {
299 if (c == '\\')
300 escaping = true;
301 else
302 if (c == '"')
303 break;
304 else
305 str_out.push_back(c);
306 }
307 }
308}
309
310template<typename T>
311static void Parse(const wchar_t *file, T* dst)

Callers 1

loadSymbolsMethod · 0.85

Calls 1

enforceFunction · 0.70

Tested by

no test coverage detected