Chemical Data Processing Library C++ API - Version 1.1.1
Public Types | Public Member Functions | List of all members
CDPL::Base::DataFormat Class Reference

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

#include <DataFormat.hpp>

Public Types

typedef FileExtensionList::const_iterator ConstFileExtensionIterator
 A constant random access iterator used to iterate over the list of file extensions. More...
 
typedef FileExtensionList::iterator FileExtensionIterator
 A mutable random access iterator used to iterate over the list of file extensions. More...
 

Public Member Functions

template<typename Iter >
 DataFormat (const std::string &name, const std::string &descr, const std::string &mime_type, Iter file_ext_begin, Iter file_ext_end, bool multi_rec)
 Constructs and initializes a DataFormat object with the given attributes. More...
 
 DataFormat ()
 Default constructor. More...
 
const std::string & getDescription () const
 Returns the description of the data format. More...
 
void setDescription (const std::string &descr)
 Sets the description of the data format. More...
 
const std::string & getName () const
 Returns the short-name of the data format. More...
 
void setName (const std::string &name)
 Sets the short-name of the data format. More...
 
const std::string & getMimeType () const
 Returns the mime-type of the data format. More...
 
void setMimeType (const std::string &mime_type)
 Sets the mime-type of the data format. More...
 
std::size_t getNumFileExtensions () const
 Returns the number of registered file extensions. More...
 
ConstFileExtensionIterator getFileExtensionsBegin () const
 Returns a constant iterator pointing to the beginning of the file extension list. More...
 
ConstFileExtensionIterator getFileExtensionsEnd () const
 Returns a constant iterator pointing to the end of the file extension list. More...
 
FileExtensionIterator getFileExtensionsBegin ()
 Returns a mutable iterator pointing to the beginning of the file extension list. More...
 
FileExtensionIterator getFileExtensionsEnd ()
 Returns a mutable iterator pointing to the end of the file extension list. More...
 
ConstFileExtensionIterator begin () const
 Returns a constant iterator pointing to the beginning of the file extension list. More...
 
ConstFileExtensionIterator end () const
 Returns a constant iterator pointing to the end of the file extension list. More...
 
FileExtensionIterator begin ()
 Returns a mutable iterator pointing to the beginning of the file extension list. More...
 
FileExtensionIterator end ()
 Returns a mutable iterator pointing to the end of the file extension list. More...
 
DataFormataddFileExtension (const std::string &file_ext)
 Adds file_ext to the current list of file extensions. More...
 
const std::string & getFileExtension (std::size_t idx) const
 Returns the file extension list entry at index idx. More...
 
void setFileExtension (std::size_t idx, const std::string &file_ext)
 Sets the file extension list entry at index idx to file_ext. More...
 
void removeFileExtension (std::size_t idx)
 Removes the file extension list entry at index idx. More...
 
FileExtensionIterator removeFileExtension (const FileExtensionIterator &it)
 Removes the file extension list entry pointed to by the iterator it. More...
 
void clearFileExtensions ()
 Clears the file extension list. More...
 
bool isMultiRecordFormat () const
 Tells whether or not the data format supports the storage of multiple data records. More...
 
void setMultiRecordFormat (bool multi_rec)
 Specifies whether or not the data format supports the storage of multiple data records. More...
 
bool matchesName (const std::string &name) const
 Tells whether the name of this data format matches the name specified by name. More...
 
bool matchesMimeType (const std::string &mime_type) const
 Tells whether the mime-type of this data format matches the mime-type specified by mime_type. More...
 
bool matchesFileExtension (const std::string &file_ext) const
 Tells whether file_ext is contained in the list of file extensions. More...
 
bool operator== (const DataFormat &fmt) const
 Equality comparison operator. More...
 
bool operator!= (const DataFormat &fmt) const
 Inequality comparison operator. More...
 

Detailed Description

Provides meta-information about a particular data storage format.

Member Typedef Documentation

◆ ConstFileExtensionIterator

typedef FileExtensionList::const_iterator CDPL::Base::DataFormat::ConstFileExtensionIterator

A constant random access iterator used to iterate over the list of file extensions.

◆ FileExtensionIterator

typedef FileExtensionList::iterator CDPL::Base::DataFormat::FileExtensionIterator

A mutable random access iterator used to iterate over the list of file extensions.

Constructor & Destructor Documentation

◆ DataFormat() [1/2]

template<typename Iter >
CDPL::Base::DataFormat::DataFormat ( const std::string &  name,
const std::string &  descr,
const std::string &  mime_type,
Iter  file_ext_begin,
Iter  file_ext_end,
bool  multi_rec 
)
inline

Constructs and initializes a DataFormat object with the given attributes.

Parameters
nameThe short-name of the data format, e.g. "PNG".
descrA string providing a brief human readable description of the data format, e.g. "Portable Network Graphics".
mime_typeThe mime-type associated with the data format (e.g. "image/png"), or an empty string if the mime-type is not available.
file_ext_beginAn iterator pointing to the beginning of the file extension list.
file_ext_endAn iterator pointing to the end of the file extension list.
multi_rectrue if the data format supports the storage of multiple data records, and false otherwise.

◆ DataFormat() [2/2]

CDPL::Base::DataFormat::DataFormat ( )
inline

Default constructor.

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

Member Function Documentation

◆ getDescription()

const std::string& CDPL::Base::DataFormat::getDescription ( ) const

Returns the description of the data format.

Returns
The data format description.

◆ setDescription()

void CDPL::Base::DataFormat::setDescription ( const std::string &  descr)

Sets the description of the data format.

Parameters
descrThe data format description.

◆ getName()

const std::string& CDPL::Base::DataFormat::getName ( ) const

Returns the short-name of the data format.

Returns
The short-name of the data format.

◆ setName()

void CDPL::Base::DataFormat::setName ( const std::string &  name)

Sets the short-name of the data format.

Parameters
nameThe short-name of the data format.

◆ getMimeType()

const std::string& CDPL::Base::DataFormat::getMimeType ( ) const

Returns the mime-type of the data format.

Returns
The mime-type of the data format.

◆ setMimeType()

void CDPL::Base::DataFormat::setMimeType ( const std::string &  mime_type)

Sets the mime-type of the data format.

Parameters
mime_typeThe mime-type of the data format.

◆ getNumFileExtensions()

std::size_t CDPL::Base::DataFormat::getNumFileExtensions ( ) const

Returns the number of registered file extensions.

Returns
The number of registered file extensions.

◆ getFileExtensionsBegin() [1/2]

ConstFileExtensionIterator CDPL::Base::DataFormat::getFileExtensionsBegin ( ) const

Returns a constant iterator pointing to the beginning of the file extension list.

Returns
A constant iterator pointing to the beginning of the file extension list.

◆ getFileExtensionsEnd() [1/2]

ConstFileExtensionIterator CDPL::Base::DataFormat::getFileExtensionsEnd ( ) const

Returns a constant iterator pointing to the end of the file extension list.

Returns
A constant iterator pointing to the end of the file extension list.

◆ getFileExtensionsBegin() [2/2]

FileExtensionIterator CDPL::Base::DataFormat::getFileExtensionsBegin ( )

Returns a mutable iterator pointing to the beginning of the file extension list.

Returns
A mutable iterator pointing to the beginning of the file extension list.

◆ getFileExtensionsEnd() [2/2]

FileExtensionIterator CDPL::Base::DataFormat::getFileExtensionsEnd ( )

Returns a mutable iterator pointing to the end of the file extension list.

Returns
A mutable iterator pointing to the end of the file extension list.

◆ begin() [1/2]

ConstFileExtensionIterator CDPL::Base::DataFormat::begin ( ) const

Returns a constant iterator pointing to the beginning of the file extension list.

Returns
A constant iterator pointing to the beginning of the file extension list.

◆ end() [1/2]

ConstFileExtensionIterator CDPL::Base::DataFormat::end ( ) const

Returns a constant iterator pointing to the end of the file extension list.

Returns
A constant iterator pointing to the end of the file extension list.

◆ begin() [2/2]

FileExtensionIterator CDPL::Base::DataFormat::begin ( )

Returns a mutable iterator pointing to the beginning of the file extension list.

Returns
A mutable iterator pointing to the beginning of the file extension list.

◆ end() [2/2]

FileExtensionIterator CDPL::Base::DataFormat::end ( )

Returns a mutable iterator pointing to the end of the file extension list.

Returns
A mutable iterator pointing to the end of the file extension list.

◆ addFileExtension()

DataFormat& CDPL::Base::DataFormat::addFileExtension ( const std::string &  file_ext)

Adds file_ext to the current list of file extensions.

Parameters
file_extThe file extension to add.

◆ getFileExtension()

const std::string& CDPL::Base::DataFormat::getFileExtension ( std::size_t  idx) const

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.

◆ setFileExtension()

void CDPL::Base::DataFormat::setFileExtension ( std::size_t  idx,
const std::string &  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() [1/2]

void CDPL::Base::DataFormat::removeFileExtension ( std::size_t  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.

◆ removeFileExtension() [2/2]

FileExtensionIterator CDPL::Base::DataFormat::removeFileExtension ( const FileExtensionIterator it)

Removes the file extension list entry pointed to by the iterator it.

Parameters
itAn iterator pointing to the extension list entry to remove.
Exceptions
Base::RangeErrorif it is not in the range [getFileExtensionsBegin(), getFileExtensionsEnd() - 1].

◆ clearFileExtensions()

void CDPL::Base::DataFormat::clearFileExtensions ( )

Clears the file extension list.

◆ isMultiRecordFormat()

bool CDPL::Base::DataFormat::isMultiRecordFormat ( ) const

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()

void 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.

◆ matchesName()

bool CDPL::Base::DataFormat::matchesName ( const std::string &  name) const

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 ( const std::string &  mime_type) const

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 ( const std::string &  file_ext) const

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.

◆ operator==()

bool CDPL::Base::DataFormat::operator== ( const DataFormat fmt) const

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.

◆ operator!=()

bool CDPL::Base::DataFormat::operator!= ( const DataFormat fmt) const

Inequality comparison operator.

The result is equivalent to !(*this == 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
operator==()

The documentation for this class was generated from the following file: