File OpenBabelStreamHandler.h¶
Implements a StreamHandler leveraging OpenBabel for access to more file formats.
- Copyright
This code is licensed under the 3-clause BSD license.
Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.
See LICENSE.txt for details.
-
namespace
Scine This header file contains functions that allow for common notation for common things that can be done at a different degree of derivatives.
This header contains alias definitions defining which classes to use for the different degrees of derivatives.
-
namespace
Utils -
class
OpenBabelStreamHandler: public Scine::Utils::FormattedStreamHandler - #include <OpenBabelStreamHandler.h>
If obabel is in the PATH, supports IO to range of OpenBabel’s file formats.
- Note
Concerning the GPLv2 OpenBabel license, this StreamHandler very much communicates ‘at arms length’ with OpenBabel (https://www.gnu.org/licenses/old-licenses/gpl-2.0-faq.en.html#TOCGPLInProprietarySystem) by merely calling it via system process-level interaction, if present.
Public Functions
-
OpenBabelStreamHandler()¶
-
~OpenBabelStreamHandler()¶
-
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 toformat: The format to writeatoms: 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 writeatoms: The element type and positional information to write to a filebondOrders: The bond order collection to write to file
- Exceptions
FormatUnsupportedException: If the desired filetype is unsupportedNoBondInformationException: 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 foroperation: 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 Functions
-
static const std::vector<FormatSupportPair> &
getSupportedFormats() List of checked and supported file formats.
- Note
This list is po
-
static bool
checkForBinary() Checks for the presence of ‘obabel’ in the PATH.
- Return
Whether ‘obabel’ is found and can be used
-
static int
indirect(std::istream &is, std::ostream &os, const std::string &inFormat, const std::string &outFormat) Converts between two formats using openbabel with two streams.
- Note
For supported formats,
- See
openBabelFormats
- Warning
This does not check whether obabel is present. Do not use this function without a pre-pended
checkForBinarycall.- Pre
ispopulated with data of formatinFormat- Post
osis populated with data of formatoutFormat- Return
The exit code of obabel execution
- Parameters
is: The input stream for obabelos: The output stream for obabelinFormat: The format string ofisoutFormat: The format string ofos
Public Static Attributes
-
constexpr const char *
model= "OpenBabelStreamHandler"¶
Private Members
-
bool
_enabled= checkForBinary()¶
-
class
-
namespace