MCPcopy Create free account
hub / github.com/JACoders/OpenJK / Parse

Method Parse

codeJK2/game/genericparser2.cpp:204–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

202{}
203
204bool CGPGroup::Parse( gsl::cstring_view& data, const bool topLevel )
205{
206 while ( true )
207 {
208 gsl::cstring_view token = GetToken( data, true );
209
210 if ( token.empty() )
211 {
212 if ( topLevel )
213 {
214 // top level parse; there was no opening "{", so there should be no closing one either.
215 return true;
216 }
217 else
218 {
219 // end of data - error!
220 return false;
221 }
222 }
223 else if ( token == CSTRING_VIEW( "}" ) )
224 {
225 if ( topLevel )
226 {
227 // top-level group; there was no opening "{" so there should be no closing one, either.
228 return false;
229 }
230 else
231 {
232 // ending brace for this group
233 return true;
234 }
235 }
236 gsl::cstring_view lastToken = token;
237
238 // read ahead to see what we are doing
239 token = GetToken( data, true, true );
240 if ( token == CSTRING_VIEW( "{" ) )
241 {
242 // new sub group
243 mSubGroups.emplace_back( lastToken );
244 if ( !mSubGroups.back().Parse( data, false ) )
245 {
246 return false;
247 }
248 }
249 else if ( token == CSTRING_VIEW( "[" ) )
250 {
251 // new list
252 mProperties.emplace_back( lastToken );
253 CGPProperty& list = mProperties.back();
254 while ( true )
255 {
256 token = GetToken( data, true, true );
257 if ( token.empty() )
258 {
259 return false;
260 }
261 if ( token == CSTRING_VIEW( "]" ) )

Callers 1

RegisterEffectMethod · 0.45

Calls 7

ReadFileFunction · 0.85
backMethod · 0.80
viewMethod · 0.80
GetTokenFunction · 0.70
emptyMethod · 0.45
AddValueMethod · 0.45
validMethod · 0.45

Tested by

no test coverage detected