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

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 to

  • format: The format to write

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

Exceptions

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 write

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

  • bondOrders: The bond order collection to write to file

Exceptions

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 for

  • operation: 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
struct FormatUnsupportedException : public exception
#include <FormattedStreamHandler.h>

Exception thrown if the desired format is unsupported by the handler.

Public Functions

const char *what() const
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