Class Scine::Utils::MolStreamHandler

class MolStreamHandler : public Scine::Utils::FormattedStreamHandler

Handler for MOL stream IO.

This class implements the FormattedStreamHandler interface for use with Core’s module management. The core stream IO functions are available as static functions, too.

Static members

const std::vector<std::string> versionStrings

Strings matching MOL format versions.

static void write(std::ostream &os, const AtomCollection &atoms, const boost::optional<BondOrderCollection> &bondOrdersOption, const std::string &formatVersion)

Writes to an output stream in MOL format.

Note

Currently only implements the V2000 format.

Parameters
  • os: The stream to write to

  • atoms: The element and positional data to write

  • bondOrdersOption: An optional BondOrderCollection

  • formatVersion: The string (matching an entry in versionStrings) specifying which MOL format version should be written

static std::pair<AtomCollection, BondOrderCollection> read(std::istream &is)

Reads from an input stream in MOL format.

Return

Elemental and positional data. Optionally also bond order information.

Parameters
  • is: The stream to read from

  • skipBonds: Whether to skip bond information

FormattedStreamHandler interface

std::pair<AtomCollection, BondOrderCollection> read(std::istream &is, const std::string &format) const

Reads from an input stream, extracting element types, positions and bond orders (if present)

Return

An Atomcollection and BondOrderCollection

Parameters
  • is: The input stream to read

Exceptions
  • FormatUnsupportedException: If the desired format is unsupported

void write(std::ostream &os, const std::string &format, const AtomCollection &atoms) const

Writes element types and positional information to an arbitrary filetype.

Parameters
  • os: The output stream to write to

  • format: The format to write

  • atoms: The element type and positional information to write to a file

Exceptions
  • FormatUnsupportedException: If the desired format is unsupported

void write(std::ostream &os, const std::string &format, const AtomCollection &atoms, const BondOrderCollection &bondOrders) const

Writes element types and positional information to an arbitrary filetype.

Parameters
  • os: The output stream to write to.

  • format: The format to write

  • atoms: The element type and positional information to write to a file

  • bondOrders: The bond order collection to write to file

Exceptions
  • FormatUnsupportedException: If the desired filetype is unsupported

  • NoBondInformationException: If the specified filetype does not contain bond order information

std::vector<FormatSupportPair> formats() const

Returns a list of supported file formats.

Note

These may, but do not have to be identical to each format’s conventional file suffix

bool formatSupported(const std::string &format, SupportType operation) const

Check whether a particular operation for a format is supported.

Return

true if the operation is supported for that format

Parameters
  • format: The format filetype suffix to check for

  • operation: The operation for which support is queried

std::string name() const

Getter for the name of the FormattedStreamHandler.

Return

Returns the name of the FormattedStreamHandler.

Public Static Attributes

constexpr const char *model = "MolStreamHandler"

Model string identifier for use in the Module system.