| 261 | } |
| 262 | |
| 263 | ObjectPtr Object::LoadContext::loadObjectOrReference( const IndexedIO *container, const IndexedIO::EntryID &name ) |
| 264 | { |
| 265 | IndexedIO::Entry e = container->entry( name ); |
| 266 | if( e.entryType()==IndexedIO::File ) |
| 267 | { |
| 268 | IndexedIO::EntryIDList pathParts; |
| 269 | if ( e.dataType() == IndexedIO::InternedStringArray ) |
| 270 | { |
| 271 | pathParts.resize( e.arrayLength() ); |
| 272 | InternedString *p = &(pathParts[0]); |
| 273 | container->read( name, p, e.arrayLength() ); |
| 274 | } |
| 275 | else |
| 276 | { |
| 277 | // for backward compatibility... |
| 278 | string path; |
| 279 | container->read( name, path ); |
| 280 | typedef boost::tokenizer<boost::char_separator<char> > Tokenizer; |
| 281 | // \todo: this would have trouble if the name of the object contains slashes... |
| 282 | Tokenizer tokens(path, boost::char_separator<char>("/")); |
| 283 | Tokenizer::iterator t = tokens.begin(); |
| 284 | |
| 285 | for ( ; t != tokens.end(); t++ ) |
| 286 | { |
| 287 | pathParts.push_back( *t ); |
| 288 | } |
| 289 | } |
| 290 | std::pair<LoadedObjects::iterator, bool> ret = m_loadedObjects->insert( std::pair<IndexedIO::EntryIDList, ObjectPtr>( pathParts, nullptr ) ); |
| 291 | if ( ret.second ) |
| 292 | { |
| 293 | // jump to the path.. |
| 294 | ConstIndexedIOPtr ioObject = m_ioInterface->directory( pathParts ); |
| 295 | // add the loaded object to the map. |
| 296 | ret.first->second = loadObject( ioObject.get() ); |
| 297 | } |
| 298 | return ret.first->second; |
| 299 | } |
| 300 | else |
| 301 | { |
| 302 | ConstIndexedIOPtr ioObject = container->subdirectory( name ); |
| 303 | |
| 304 | IndexedIO::EntryIDList pathParts; |
| 305 | ioObject->path( pathParts ); |
| 306 | |
| 307 | std::pair<LoadedObjects::iterator, bool> ret = m_loadedObjects->insert( std::pair<IndexedIO::EntryIDList, ObjectPtr>( pathParts, nullptr ) ); |
| 308 | if ( ret.second ) |
| 309 | { |
| 310 | // add the loaded object to the map. |
| 311 | ret.first->second = loadObject( ioObject.get() ); |
| 312 | } |
| 313 | return ret.first->second; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | // this function can only load concrete objects. it can't load references to |
| 318 | // objects. path is relative to the root of m_ioInterface |
nothing calls this directly
no test coverage detected