MCPcopy Create free account
hub / github.com/ImageEngine/cortex / create

Method create

src/IECore/Reader.cpp:82–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82ReaderPtr Reader::create( const std::string &fileName )
83{
84 bool knownExtension = false;
85 ExtensionsToFnsMap *m = extensionsToFns();
86 assert( m );
87 string ext = boost::filesystem::path( fileName ).extension().string();
88 if( ext!="" )
89 {
90 ExtensionsToFnsMap::const_iterator it = m->find( ext );
91
92 if( it!=m->end() )
93 {
94 knownExtension = true;
95
96 ExtensionsToFnsMap::const_iterator lastElement = m->upper_bound( ext );
97
98 for ( ; it != lastElement; ++it )
99 {
100 if( it->second.canRead( fileName ) )
101 {
102 return it->second.creator( fileName );
103 }
104 }
105 }
106 }
107
108 // failed to find a reader based on extension. try all canRead functions
109 // as a last ditch attempt.
110 for( ExtensionsToFnsMap::const_iterator it=m->begin(); it!=m->end(); it++ )
111 {
112 if( it->second.canRead( fileName ) )
113 {
114 return( it->second.creator( fileName ) );
115 }
116 }
117 if ( knownExtension )
118 {
119 throw Exception( string( "Unable to load file '" ) + fileName + "'!" );
120 }
121 else
122 {
123 throw Exception( string( "Unrecognized input file format '") + ext + "'!" );
124 }
125}
126
127void Reader::supportedExtensions( std::vector<std::string> &extensions )
128{

Callers

nothing calls this directly

Calls 6

pathFunction · 0.85
extensionMethod · 0.80
findMethod · 0.45
endMethod · 0.45
canReadMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected