Exemple #1
0
DeepImageWriterPtr DeepImageWriter::create( const std::string &fileName )
{
	/// \todo We can stop using this deprecated form when we no longer need to be compatible
	/// with boost 1.43. At that point we can use path.extension().string() and compile with
	/// BOOST_FILESYSTEM_NO_DEPRECATED.
	std::string ext = boost::filesystem::extension( boost::filesystem::path( fileName ) );

	ExtensionsToFnsMap *m = extensionsToFns();
	ExtensionsToFnsMap::const_iterator it = m->find( ext );

	if ( it == m->end() )
	{
		throw Exception( std::string( "Unrecognized output file format '") + ext + "'!" );
	}

	for ( it=m->begin(); it != m->end(); it++ )
	{
		if ( it->first == ext )
		{
			if ( it->second.canWrite( fileName ) )
			{
				return it->second.creator( fileName );
			}
		}
	}

	throw Exception( std::string( "Unable to find DeepImageWriter able to write to file of type '") + ext + "'!" );
}
DeepImageWriterPtr DeepImageWriter::create( const std::string &fileName )
{
	std::string ext = boost::filesystem::extension( boost::filesystem::path( fileName ) );

	ExtensionsToFnsMap *m = extensionsToFns();
	ExtensionsToFnsMap::const_iterator it = m->find( ext );

	if ( it == m->end() )
	{
		throw Exception( std::string( "Unrecognized output file format '") + ext + "'!" );
	}

	for ( it=m->begin(); it != m->end(); it++ )
	{
		if ( it->first == ext )
		{
			if ( it->second.canWrite( fileName ) )
			{
				return it->second.creator( fileName );
			}
		}
	}

	throw Exception( std::string( "Unable to find DeepImageWriter able to write to file of type '") + ext + "'!" );
}
Exemple #3
0
void DeepImageWriter::supportedExtensions( std::vector<std::string> &extensions )
{
	extensions.clear();
	ExtensionsToFnsMap *m = extensionsToFns();
	for ( ExtensionsToFnsMap::const_iterator it=m->begin(); it != m->end(); it++ )
	{
		extensions.push_back( it->first.substr( 1 ) );
	}
}
Exemple #4
0
ReaderPtr Reader::create( const std::string &fileName )
{
	bool knownExtension = false;
	ExtensionsToFnsMap *m = extensionsToFns();
	assert( m );
	string ext = extension(boost::filesystem::path(fileName));
	if( ext!="" )
	{
		ExtensionsToFnsMap::const_iterator it = m->find( ext );

		if( it!=m->end() )
		{
			knownExtension = true;

			ExtensionsToFnsMap::const_iterator lastElement = m->upper_bound( ext );

			for ( ; it != lastElement; ++it )
			{
				if( it->second.canRead( fileName ) )
				{
					return it->second.creator( fileName );
				}
			}
		}
	}

	// failed to find a reader based on extension. try all canRead functions
	// as a last ditch attempt.
	for( ExtensionsToFnsMap::const_iterator it=m->begin(); it!=m->end(); it++ )
	{
		if( it->second.canRead( fileName ) )
		{
			return( it->second.creator( fileName ) );
		}
	}
	if ( knownExtension )
	{
		throw Exception( string( "Unable to load file '" ) + fileName + "'!" );
	}
	else
	{
		throw Exception( string( "Unrecognized input file format '") + ext + "'!" );
	}
}
Exemple #5
0
void DeepImageWriter::supportedExtensions( TypeId typeId, std::vector<std::string> &extensions )
{
	extensions.clear();
	ExtensionsToFnsMap *m = extensionsToFns();

	const std::set< TypeId > &derivedTypes = RunTimeTyped::derivedTypeIds( typeId );

	for ( ExtensionsToFnsMap::const_iterator it=m->begin(); it != m->end(); it++ )
	{
		if ( it->second.typeId == typeId || std::find( derivedTypes.begin(), derivedTypes.end(), it->second.typeId ) != derivedTypes.end() )
		{
			extensions.push_back( it->first.substr( 1 ) );
		}
	}
}
Exemple #6
0
void Reader::supportedExtensions( std::vector<std::string> &extensions )
{
	extensions.clear();
	ExtensionsToFnsMap *m = extensionsToFns();
	assert( m );

	std::set<std::string> uniqueExtensions;

	for( ExtensionsToFnsMap::const_iterator it=m->begin(); it!=m->end(); it++ )
	{
		uniqueExtensions.insert( it->first.substr( 1 ) );
	}

	extensions.resize( uniqueExtensions.size() );
	std::copy( uniqueExtensions.begin(), uniqueExtensions.end(), extensions.begin() );
}
Exemple #7
0
void Reader::supportedExtensions( TypeId typeId, std::vector<std::string> &extensions )
{
	extensions.clear();
	ExtensionsToFnsMap *m = extensionsToFns();
	assert( m );

	std::set<std::string> uniqueExtensions;

	const std::set< TypeId > &derivedTypes = RunTimeTyped::derivedTypeIds( typeId );

	for( ExtensionsToFnsMap::const_iterator it=m->begin(); it!=m->end(); it++ )
	{
		if ( it->second.typeId == typeId || std::find( derivedTypes.begin(), derivedTypes.end(), it->second.typeId ) != derivedTypes.end() )
		{
			uniqueExtensions.insert( it->first.substr( 1 ) );
		}
	}

	extensions.resize( uniqueExtensions.size() );
	std::copy( uniqueExtensions.begin(), uniqueExtensions.end(), extensions.begin() );
}