| 25 | {} |
| 26 | |
| 27 | void Doom3MapReader::readFromStream(std::istream& stream) |
| 28 | { |
| 29 | // Call the virtual method to initialise the primitve parser map (if not done yet) |
| 30 | initPrimitiveParsers(); |
| 31 | |
| 32 | // The tokeniser used to split the stream into pieces |
| 33 | parser::BasicDefTokeniser<std::istream> tok(stream); |
| 34 | |
| 35 | // Try to parse the map version (throws on failure) |
| 36 | parseMapVersion(tok); |
| 37 | |
| 38 | // Read each entity in the map, until EOF is reached |
| 39 | while (tok.hasMoreTokens()) |
| 40 | { |
| 41 | // Create an entity node by parsing from the stream. If there is an |
| 42 | // exception, display it and return |
| 43 | try |
| 44 | { |
| 45 | parseEntity(tok); |
| 46 | } |
| 47 | catch (FailureException& e) |
| 48 | { |
| 49 | std::string text = fmt::format(_("Failed parsing entity {0:d}:\n{1}"), _entityCount, e.what()); |
| 50 | |
| 51 | // Re-throw with more text |
| 52 | throw FailureException(text); |
| 53 | } |
| 54 | |
| 55 | _entityCount++; |
| 56 | } |
| 57 | |
| 58 | // EOF reached, success |
| 59 | } |
| 60 | |
| 61 | void Doom3MapReader::initPrimitiveParsers() |
| 62 | { |
no test coverage detected