Reads string from between double quotes.
| 269 | |
| 270 | // Reads string from between double quotes. |
| 271 | void 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 | |
| 310 | template<typename T> |
| 311 | static void Parse(const wchar_t *file, T* dst) |