MCPcopy Create free account
hub / github.com/OGRECave/ogre-next / parseScript

Method parseScript

OgreMain/src/OgreRenderSystemCapabilitiesSerializer.cpp:195–331  ·  view source on GitHub ↗

-----------------------------------------------------------------------

Source from the content-addressed store, hash-verified

193
194 //-----------------------------------------------------------------------
195 void RenderSystemCapabilitiesSerializer::parseScript(DataStreamPtr& stream)
196 {
197 // reset parsing data to NULL
198 mCurrentLineNumber = 0;
199 mCurrentLine = 0;
200 mCurrentStream.reset();
201 mCurrentCapabilities = 0;
202
203 mCurrentStream = stream;
204
205 // parser operating data
206 String line;
207 ParseAction parseAction = PARSE_HEADER;
208 StringVector tokens;
209 bool parsedAtLeastOneRSC = false;
210
211 // collect capabilities lines (i.e. everything that is not header, "{", "}",
212 // comment or empty line) for further processing
213 CapabilitiesLinesList capabilitiesLines;
214
215 // for reading data
216 char tmpBuf[OGRE_STREAM_TEMP_SIZE];
217
218
219 // TODO: build a smarter tokenizer so that "{" and "}"
220 // don't need separate lines
221 while (!stream->eof())
222 {
223 stream->readLine(tmpBuf, OGRE_STREAM_TEMP_SIZE-1);
224 line = String(tmpBuf);
225 StringUtil::trim(line);
226
227 // keep track of parse position
228 mCurrentLine = &line;
229 mCurrentLineNumber++;
230
231 tokens = StringUtil::split(line);
232
233 // skip empty and comment lines
234 // TODO: handle end of line comments
235 if (tokens[0] == "" || tokens[0].substr(0,2) == "//")
236 continue;
237
238 switch (parseAction)
239 {
240 // header line must look like this:
241 // render_system_capabilities "Vendor Card Name Version xx.xxx"
242
243 case PARSE_HEADER:
244
245 if(tokens[0] != "render_system_capabilities")
246 {
247 logParseError("The first keyword must be render_system_capabilities. RenderSystemCapabilities NOT created!");
248 return;
249 }
250 else
251 {
252 // the rest of the tokens are irrevelant, beause everything between "..." is one name

Callers

nothing calls this directly

Calls 9

readLineMethod · 0.80
resetMethod · 0.45
eofMethod · 0.45
substrMethod · 0.45
sizeMethod · 0.45
logMessageMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected