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

Method parsePrimitive

radiantcore/map/format/Quake3MapReader.cpp:71–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void Quake3MapReader::parsePrimitive(parser::DefTokeniser& tok, const scene::INodePtr& parentEntity)
72{
73 _primitiveCount++;
74
75 std::string primitiveKeyword = tok.peek();
76
77 // Get a parser for this keyword
78 PrimitiveParsers::const_iterator p = _primitiveParsers.find(primitiveKeyword);
79
80 if (p == _primitiveParsers.end())
81 {
82 throw FailureException("Unknown primitive type: " + primitiveKeyword);
83 }
84
85 const PrimitiveParserPtr& parser = p->second;
86
87 // All primitive formats except for the legacy brushDef format have a proper keyword
88 // which should be parsed away before reading in the tokens.
89 if (primitiveKeyword != "(")
90 {
91 tok.nextToken();
92 }
93
94 // Try to parse the primitive, throwing exception if failed
95 try
96 {
97 scene::INodePtr primitive = parser->parse(tok);
98
99 if (!primitive)
100 {
101 std::string text = fmt::format(_("Primitive #{0:d}: parse error"), _primitiveCount);
102 throw FailureException(text);
103 }
104
105 // Now add the primitive as a child of the entity
106 _importFilter.addPrimitiveToEntity(primitive, parentEntity);
107 }
108 catch (parser::ParseException& e)
109 {
110 // Translate ParseExceptions to FailureExceptions
111 std::string text = fmt::format(_("Primitive #{0:d}: parse exception {1}"), _primitiveCount, e.what());
112 throw FailureException(text);
113 }
114}
115
116scene::INodePtr Quake3MapReader::createEntity(const EntityKeyValues& keyValues)
117{

Callers

nothing calls this directly

Calls 10

whatMethod · 0.80
FailureExceptionClass · 0.50
formatFunction · 0.50
_Function · 0.50
peekMethod · 0.45
findMethod · 0.45
endMethod · 0.45
nextTokenMethod · 0.45
parseMethod · 0.45
addPrimitiveToEntityMethod · 0.45

Tested by

no test coverage detected