MCPcopy Create free account
hub / github.com/SpartanJ/eepp / loadLayoutFromMemory

Method loadLayoutFromMemory

src/eepp/ui/uiscenenode.cpp:542–575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

540}
541
542UIWidget* UISceneNode::loadLayoutFromMemory( const void* buffer, Int32 bufferSize, Node* parent,
543 const Uint32& marker ) {
544 RegEx voidTagsRegex( VOIDTAG_REGEX );
545
546 pugi::xml_document doc;
547 pugi::xml_parse_result result;
548 std::string_view layoutString( static_cast<const char*>( buffer ), bufferSize );
549 std::string fixedLayout;
550 bool needsReplacements =
551 voidTagsRegex.matches( static_cast<const char*>( buffer ), 0, nullptr, bufferSize );
552
553 if ( needsReplacements ) {
554 fixedLayout = voidTagsRegex.gsub( layoutString.data(), "%1 />" );
555 result = doc.load_buffer( fixedLayout.c_str(), fixedLayout.size(),
556 pugi::parse_default | pugi::parse_ws_pcdata );
557 } else {
558 result = doc.load_buffer( buffer, bufferSize, pugi::parse_default | pugi::parse_ws_pcdata );
559 }
560
561 if ( result ) {
562 return loadLayoutNodes( doc.first_child(), NULL != parent ? parent : this, marker );
563 } else {
564 Log::error( "Couldn't load UI Layout from memory: %s",
565 needsReplacements ? fixedLayout.c_str() : layoutString.data() );
566 Log::error( "Error description: %s", result.description() );
567 Log::error( "Error offset: %d", result.offset );
568 Log::error( "Error context: %s",
569 getErrorContext( result.offset,
570 std::string_view{ static_cast<const char*>( buffer ),
571 static_cast<std::size_t>( bufferSize ) } ) );
572 }
573
574 return NULL;
575}
576
577UIWidget* UISceneNode::loadLayoutFromStream( IOStream& stream, Node* parent,
578 const Uint32& marker ) {

Callers 1

UIDocFindReplaceMethod · 0.80

Calls 7

errorFunction · 0.85
getErrorContextFunction · 0.85
gsubMethod · 0.80
c_strMethod · 0.80
matchesMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected