MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / readFromStream

Method readFromStream

radiantcore/map/format/Doom3MapReader.cpp:27–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25{}
26
27void 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
61void Doom3MapReader::initPrimitiveParsers()
62{

Callers 2

loadMethod · 0.45
importFromStreamFunction · 0.45

Calls 5

whatMethod · 0.80
formatFunction · 0.50
_Function · 0.50
FailureExceptionClass · 0.50
hasMoreTokensMethod · 0.45

Tested by

no test coverage detected