MCPcopy Create free account
hub / github.com/SoarGroup/Soar / ParseElement

Method ParseElement

Core/ElementXML/src/ParseXML.cpp:299–487  ·  view source on GitHub ↗

* * Parse an XML element and its children. This is the main parsing * function. The lexical analyser contains a references to the input * stream being parsed. The function calls itself recursively to * parse its children. * * @param lex The lexical analyser for this parse. * * @return The element that has just been read from the input stream. * *******************************************

Source from the content-addressed store, hash-verified

297*
298*************************************************************************/
299ElementXMLImpl* ParseXML::ParseElement()
300{
301 // Check if we're starting with a comment
302 while (Have(kComment))
303 {
304 SetLastComment(GetTokenValue()) ;
305 GetNextToken() ;
306 }
307
308 // We must start with an open tag marker
309 MustBe(kOpenTagChar) ;
310
311 // For now ignore header tags
312 if (Have(kHeaderChar))
313 {
314 while (!IsError() && !Have(kCloseTagChar))
315 {
316 GetNextToken() ;
317 }
318
319 // We must start with an open tag marker
320 MustBe(kOpenTagChar) ;
321
322 //return NULL ;
323 }
324
325 // Create the object we'll be returning
326 ElementXMLImpl* pElement = new ElementXMLImpl() ;
327
328 // Get the tag name
329 ParseString tagName ;
330 MustBe(kIdentifier, tagName) ;
331
332 pElement->SetTagName(tagName.c_str()) ;
333
334 if (HasLastComment())
335 {
336 pElement->SetComment(GetLastComment()) ;
337 SetLastComment("") ;
338 }
339
340 // Used to record whether data is encoded binary
341 bool dataIsEncoded = false ;
342
343 // Read all of the attributes (if there are any)
344 while (!IsError() && Have(kIdentifier))
345 {
346 ParseString name = GetTokenValue() ;
347
348 // Consume the name
349 GetNextToken() ;
350
351 // Must be followed by "="
352 MustBe(kEqualsChar) ;
353
354 // Then must be followed by a string containing the value
355 ParseString value ;
356 MustBe(kQuotedString, value) ;

Callers 3

soarxml_ParseXMLFromFileFunction · 0.45

Calls 8

SetTagNameMethod · 0.80
SetCommentMethod · 0.80
SetCharacterDataMethod · 0.80
ReleaseRefMethod · 0.80
AddAttributeMethod · 0.45
AddChildMethod · 0.45
GetTagNameMethod · 0.45

Tested by

no test coverage detected