| 341 | } |
| 342 | |
| 343 | Expected<Node*> ThreeMFLoader::getNodeById_( int id, const char* pathAttr ) |
| 344 | { |
| 345 | auto it = nodeByIdMap_.find( id ); |
| 346 | if ( it != nodeByIdMap_.end() ) |
| 347 | return it->second; |
| 348 | |
| 349 | if ( !pathAttr ) |
| 350 | return unexpected( "Invalid 'p:path attribute'" ); |
| 351 | |
| 352 | std::filesystem::path path = rootPath_ / asU8String( "./" + std::string( pathAttr ) ); |
| 353 | auto docIt = xmlDocuments_.find( utf8string( path.lexically_normal() ) ); |
| 354 | if ( docIt == xmlDocuments_.end() ) |
| 355 | return unexpected( "Cannot find file specified in p:path" ); |
| 356 | |
| 357 | // no progress reporting because this can be called from another loadDocument_ |
| 358 | if ( auto e = loadDocument_( docIt->second, {} ); !e ) |
| 359 | return unexpected( std::move( e.error() ) ); |
| 360 | |
| 361 | it = nodeByIdMap_.find( id ); |
| 362 | if ( it != nodeByIdMap_.end() ) |
| 363 | return it->second; |
| 364 | return unexpected( "Invalid object id" ); |
| 365 | } |
| 366 | |
| 367 | Expected<void> ThreeMFLoader::loadTree_( const ProgressCallback& callback ) |
| 368 | { |
no test coverage detected