Chemical Data Processing Library Python API - Version 1.1.1
Classes | Public Member Functions | Properties | List of all members
CDPL.Base.DataFormat Class Reference

Provides meta-information about a particular data storage format. More...

+ Inheritance diagram for CDPL.Base.DataFormat:

Classes

class  FileExtensionSequence
 

Public Member Functions

None __init__ ()
 Default constructor. More...
 
None __init__ (DataFormat fmt)
 Initializes a copy of the DataFormat instance fmt. More...
 
None __init__ (str name, str descr, str mime_type, bool multi_rec)
 Initializes the DataFormat instance. More...
 
None __init__ (str name, str descr, str mime_type, object file_exts, bool multi_rec)
 Initializes the DataFormat instance. More...
 
int getNumFileExtensions ()
 Returns the number of registered file extensions. More...
 
str getFileExtension (int idx)
 Returns the file extension list entry at index idx. More...
 
DataFormat addFileExtension (str file_ext)
 Adds file_ext to the current list of file extensions. More...
 
None setFileExtension (int idx, str file_ext)
 Sets the file extension list entry at index idx to file_ext. More...
 
None clearFileExtensions ()
 Clears the file extension list.
 
None removeFileExtension (int idx)
 Removes the file extension list entry at index idx. More...
 
bool matchesName (str name)
 Tells whether the name of this data format matches the name specified by name. More...
 
bool matchesMimeType (str mime_type)
 Tells whether the mime-type of this data format matches the mime-type specified by mime_type. More...
 
bool matchesFileExtension (str file_ext)
 Tells whether file_ext is contained in the list of file extensions. More...
 
str getDescription ()
 Returns the description of the data format. More...
 
None setDescription (str descr)
 Sets the description of the data format. More...
 
str getName ()
 Returns the short-name of the data format. More...
 
None setName (str name)
 Sets the short-name of the data format. More...
 
str getMimeType ()
 Returns the mime-type of the data format. More...
 
None setMimeType (str mime_type)
 Sets the mime-type of the data format. More...
 
bool isMultiRecordFormat ()
 Tells whether or not the data format supports the storage of multiple data records. More...
 
None setMultiRecordFormat (bool multi_rec)
 Specifies whether or not the data format supports the storage of multiple data records. More...
 
FileExtensionSequence getFileExtensions ()
 
DataFormat assign (DataFormat fmt)
 Replaces the current state of self with a copy of the state of the DataFormat instance fmt. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
str __str__ ()
 Returns a string representation of the DataFormat instance. More...
 
bool __ne__ (DataFormat fmt)
 Inequality comparison operator. More...
 
bool __eq__ (DataFormat fmt)
 Equality comparison operator. More...
 

Properties

 objectID = property(getObjectID)
 
 numFileExtensions = property(getNumFileExtensions)
 
 description = property(getDescription, setDescription)
 
 name = property(getName, setName)
 
 mimeType = property(getMimeType, setMimeType)
 
 multiRecordFormat = property(isMultiRecordFormat, setMultiRecordFormat)
 
 fileExtensions = property(getFileExtensions)
 

Detailed Description

Provides meta-information about a particular data storage format.

Constructor & Destructor Documentation

◆ __init__() [1/4]

None CDPL.Base.DataFormat.__init__ ( )

Default constructor.

All string attributes are initialized to an empty string, and the multi record format flag is set to False.

◆ __init__() [2/4]

None CDPL.Base.DataFormat.__init__ ( DataFormat  fmt)

Initializes a copy of the DataFormat instance fmt.

Parameters
fmtThe DataFormat instance to copy.

◆ __init__() [3/4]

None CDPL.Base.DataFormat.__init__ ( str  name,
str  descr,
str  mime_type,
bool  multi_rec 
)

Initializes the DataFormat instance.

Parameters
name
descr
mime_type
multi_rec

◆ __init__() [4/4]

None CDPL.Base.DataFormat.__init__ ( str  name,
str  descr,
str  mime_type,
object  file_exts,
bool  multi_rec 
)

Initializes the DataFormat instance.

Parameters
name
descr
mime_type
file_exts
multi_rec

Member Function Documentation

◆ getNumFileExtensions()

int CDPL.Base.DataFormat.getNumFileExtensions ( )

Returns the number of registered file extensions.

Returns
The number of registered file extensions.

◆ getFileExtension()

str CDPL.Base.DataFormat.getFileExtension ( int  idx)

Returns the file extension list entry at index idx.

Parameters
idxThe zero-based index of the requested file extension list entry.
Returns
The file extension list entry at index idx.
Exceptions
Base.IndexErrorif idx is out of bounds.

◆ addFileExtension()

DataFormat CDPL.Base.DataFormat.addFileExtension ( str  file_ext)

Adds file_ext to the current list of file extensions.

Parameters
file_extThe file extension to add.

◆ setFileExtension()

None CDPL.Base.DataFormat.setFileExtension ( int  idx,
str  file_ext 
)

Sets the file extension list entry at index idx to file_ext.

Parameters
idxThe zero-based index of the file extension list entry to set.
file_extThe new file extension list entry.
Exceptions
Base.IndexErrorif idx is out of bounds.

◆ removeFileExtension()

None CDPL.Base.DataFormat.removeFileExtension ( int  idx)

Removes the file extension list entry at index idx.

Parameters
idxThe zero-based index of the file extension list entry to remove.
Exceptions
Base.IndexErrorif idx is out of bounds.

◆ matchesName()

bool CDPL.Base.DataFormat.matchesName ( str  name)

Tells whether the name of this data format matches the name specified by name.

Parameters
nameThe name to match.
Returns
True if the name of the data format matches the argument, and False otherwise.
Note
The name matching is case-insensitive.

◆ matchesMimeType()

bool CDPL.Base.DataFormat.matchesMimeType ( str  mime_type)

Tells whether the mime-type of this data format matches the mime-type specified by mime_type.

Parameters
mime_typeThe mime-type to match.
Returns
True if the mime-type of the data format matches the argument, and False otherwise.
Note
The mime-type matching is case-insensitive.

◆ matchesFileExtension()

bool CDPL.Base.DataFormat.matchesFileExtension ( str  file_ext)

Tells whether file_ext is contained in the list of file extensions.

Parameters
file_extThe file extension to search for.
Returns
True if file_ext is contained in the list of file extensions, and False otherwise.
Note
The file extension matching is case-insensitive.

◆ getDescription()

str CDPL.Base.DataFormat.getDescription ( )

Returns the description of the data format.

Returns
The data format description.

◆ setDescription()

None CDPL.Base.DataFormat.setDescription ( str  descr)

Sets the description of the data format.

Parameters
descrThe data format description.

◆ getName()

str CDPL.Base.DataFormat.getName ( )

Returns the short-name of the data format.

Returns
The short-name of the data format.

◆ setName()

None CDPL.Base.DataFormat.setName ( str  name)

Sets the short-name of the data format.

Parameters
nameThe short-name of the data format.

◆ getMimeType()

str CDPL.Base.DataFormat.getMimeType ( )

Returns the mime-type of the data format.

Returns
The mime-type of the data format.

◆ setMimeType()

None CDPL.Base.DataFormat.setMimeType ( str  mime_type)

Sets the mime-type of the data format.

Parameters
mime_typeThe mime-type of the data format.

◆ isMultiRecordFormat()

bool CDPL.Base.DataFormat.isMultiRecordFormat ( )

Tells whether or not the data format supports the storage of multiple data records.

Returns
True if the data format supports the storage of multiple data records, and False otherwise.

◆ setMultiRecordFormat()

None CDPL.Base.DataFormat.setMultiRecordFormat ( bool  multi_rec)

Specifies whether or not the data format supports the storage of multiple data records.

Parameters
multi_recTrue if the data format supports the storage of multiple data records, and False otherwise.

◆ getFileExtensions()

FileExtensionSequence CDPL.Base.DataFormat.getFileExtensions ( )
Returns

◆ assign()

DataFormat CDPL.Base.DataFormat.assign ( DataFormat  fmt)

Replaces the current state of self with a copy of the state of the DataFormat instance fmt.

Parameters
fmtThe DataFormat instance to copy.
Returns
self

◆ getObjectID()

int CDPL.Base.DataFormat.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python DataFormat instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two DataFormat instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ __str__()

str CDPL.Base.DataFormat.__str__ ( )

Returns a string representation of the DataFormat instance.

Returns
The generated string representation.

◆ __ne__()

bool CDPL.Base.DataFormat.__ne__ ( DataFormat  fmt)

Inequality comparison operator.

The result is equivalent to !(self == fmt).

Parameters
fmtThe other DataFormat object to be compared with.
Returns
True if the names and/or mime-types compare non-equal (case-insensitive!), and False otherwise.
See also
eq()

◆ __eq__()

bool CDPL.Base.DataFormat.__eq__ ( DataFormat  fmt)

Equality comparison operator.

Parameters
fmtThe other DataFormat object to be compared with.
Returns
True if the names and mime-types compare equal (case-insensitive!), and False otherwise.