Template Class DataReader

Class Documentation

template<Utilities::SizedEnum KeyT, typename RealT, typename IdxT>
class DataReader

Reads typed values out of one map of a model data container.

A read method returns the provided value or std::nullopt when the entry is omitted. The model chooses a default or requires a value. Invalid values are rejected with std::invalid_argument naming the model and entry. Real entries accept integer values and must be finite.

Template Parameters:
  • KeyT – Enumeration over the entries of the map.

  • RealT – Real value type.

  • IdxT – Integer value type.

Public Functions

inline DataReader(const MapT &values, const char *model, const char *kind)
Parameters:
  • values – [in] Map to read from.

  • model – [in] Model name used in rejection messages.

  • kind – [in] Kind of entry used in rejection messages.

inline std::optional<RealT> readReal(KeyT key) const

Read an optional real parameter or initial value.

inline std::optional<RealT> readNonNegative(KeyT key) const

Read an optional non-negative real value.

inline std::optional<bool> readBool(KeyT key) const

Read an optional boolean value.

inline std::optional<IdxT> readInteger(KeyT key) const

Read an optional integer value.