File FormattedStreamHandler.h¶
Defines interface for classes handling formatted IO from streams.
- 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
FormattedStreamHandler - #include <FormattedStreamHandler.h>
The interface for all classes handling formatted streaming IO.
Subclassed by Scine::Utils::MOLStreamHandler, Scine::Utils::OpenBabelStreamHandler, Scine::Utils::XYZStreamHandler
Public Types
-
enum
SupportType¶ Which operations are supported for a particular format.
Values:
-
ReadOnly¶
-
ReadWrite¶
-
WriteOnly¶
-
-
using
FormatSupportPair= std::pair<std::string, SupportType> Pair of a format filetype suffix and a
SupportType.
Public Functions
-
FormattedStreamHandler() Default Constructor.
-
virtual
~FormattedStreamHandler() Default Destructor.
-
virtual std::pair<Utils::AtomCollection, Utils::BondOrderCollection>
read(std::istream &is, const std::string &format) const = 0 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
-
virtual void
write(std::ostream &os, const std::string &format, const Utils::AtomCollection &atoms) const = 0 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
-
virtual void
write(std::ostream &os, const std::string &format, const Utils::AtomCollection &atoms, const Utils::BondOrderCollection &bondOrders) const = 0 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
-
virtual std::vector<FormatSupportPair>
formats() const = 0 Returns a list of supported file formats.
- Note
These may, but do not have to be identical to each format’s conventional file suffix
-
virtual bool
formatSupported(const std::string &format, SupportType operation = SupportType::ReadWrite) const = 0 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
-
virtual std::string
name() const = 0 Getter for the name of the FormattedStreamHandler.
- Return
Returns the name of the FormattedStreamHandler.
-
struct
FormatMismatchException: public exception - #include <FormattedStreamHandler.h>
Exception thrown if the specified format and the input stream mismatch.
Public Functions
-
const char *
what() const¶
-
const char *
-
struct
FormatUnsupportedException: public exception - #include <FormattedStreamHandler.h>
Exception thrown if the desired format is unsupported by the handler.
Public Functions
-
const char *
what() const¶
-
const char *
-
struct
NoBondInformationException: public exception - #include <FormattedStreamHandler.h>
Exception thrown if the function yielding or taking a BondOrderCollection reads from or writes to a stream whose format does not include bond order information.
Public Functions
-
const char *
what() const¶
-
const char *
-
enum
-
class
-
namespace