| 505 | } |
| 506 | |
| 507 | UIWidget* UISceneNode::loadLayoutFromString( const char* layoutString, Node* parent, |
| 508 | const Uint32& marker ) { |
| 509 | RegEx voidTagsRegex( VOIDTAG_REGEX ); |
| 510 | |
| 511 | pugi::xml_document doc; |
| 512 | pugi::xml_parse_result result; |
| 513 | std::string fixedLayout; |
| 514 | bool needsReplacements = voidTagsRegex.matches( layoutString ); |
| 515 | |
| 516 | if ( needsReplacements ) { |
| 517 | fixedLayout = voidTagsRegex.gsub( layoutString, "%1 />" ); |
| 518 | result = |
| 519 | doc.load_string( fixedLayout.c_str(), pugi::parse_default | pugi::parse_ws_pcdata ); |
| 520 | } else { |
| 521 | result = doc.load_string( layoutString, pugi::parse_default | pugi::parse_ws_pcdata ); |
| 522 | } |
| 523 | |
| 524 | if ( result ) { |
| 525 | return loadLayoutNodes( doc.first_child(), NULL != parent ? parent : this, marker ); |
| 526 | } else { |
| 527 | Log::error( "Couldn't load UI Layout from string: %s", |
| 528 | needsReplacements ? fixedLayout.c_str() : layoutString ); |
| 529 | Log::error( "Error description: %s", result.description() ); |
| 530 | Log::error( "Error offset: %d", result.offset ); |
| 531 | Log::error( "Error context: %s", getErrorContext( result.offset, layoutString ) ); |
| 532 | } |
| 533 | |
| 534 | return NULL; |
| 535 | } |
| 536 | |
| 537 | UIWidget* UISceneNode::loadLayoutFromString( const std::string& layoutString, Node* parent, |
| 538 | const Uint32& marker ) { |