BALL  1.5.0
Static Public Member Functions | List of all members
BALL::MolFileFactory Class Reference

#include <BALL/FORMAT/molFileFactory.h>

Static Public Member Functions

static String getSupportedFormats ()
 
static bool isFileExtensionSupported (String filename)
 
static GenericMolFileopen (const String &name, File::OpenMode open_mode=std::ios::in)
 
static GenericMolFileopen (const String &name, File::OpenMode open_mode, String default_format, bool forced=false)
 
static GenericMolFileopen (const String &name, File::OpenMode open_mode, GenericMolFile *default_format_file)
 

Detailed Description

This class offers a factory method that given a path to a molecule file determines the file type based on the file extension and returns a pointer to an appropriate subclass of GenericMolFile

Definition at line 23 of file molFileFactory.h.

Member Function Documentation

◆ getSupportedFormats()

static String BALL::MolFileFactory::getSupportedFormats ( )
static

This method tries to determine the filetype based on the file extension of name and returns a pointer to an object of the appropriate subclass of GenericMolFile if available. If the file should be opened in read-mode and the extension is unknown or the file does not have an extension, we try to automatically detect the format. If the detection fails, NULL is returned.

Parameters
namethe path to the requested molecule file
Returns
a pointer to a subclass of GenericMolFile, NULL if none is appropriate. Be aware, that the file handle has not been checked for validity and that you have to delete it yourself Return a comma-separated string containing the file-extensions that are supported by MolFileFactory

◆ isFileExtensionSupported()

static bool BALL::MolFileFactory::isFileExtensionSupported ( String  filename)
static

Return true if the extension of the specified filename is supported; otherwise return false.

◆ open() [1/3]

static GenericMolFile* BALL::MolFileFactory::open ( const String name,
File::OpenMode  open_mode,
GenericMolFile default_format_file 
)
static

When trying to open a file in write-mode, this function can be used to pass along a desired default-format. If the given filename does not have a supported extension, the format of 'default_format_file' will be used.

◆ open() [2/3]

static GenericMolFile* BALL::MolFileFactory::open ( const String name,
File::OpenMode  open_mode,
String  default_format,
bool  forced = false 
)
static

When trying to open a file in write-mode, this function can be used to pass along a desired default-format. If the given filename does not have a supported extension and/or forced is set, the specified default format will be used.

◆ open() [3/3]

static GenericMolFile* BALL::MolFileFactory::open ( const String name,
File::OpenMode  open_mode = std::ios::in 
)
static