Gromacs  2020.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::OptionValueConverterSimple< OutType > Class Template Reference

#include <gromacs/options/valueconverter.h>

Description

template<typename OutType>
class gmx::OptionValueConverterSimple< OutType >

Helper for converting from Any to a given type.

Template Parameters
OutTypeType this converter converts to.

Default-constructed converter only supports identity mapping from the a Any holding OutType. To add support for additional input types, provide conversion functions with addConverter(). To use a non-identity mapping for an OutType -> OutType conversion, provide an alternative conversion from OutType with addConverter().

Public Member Functions

OutType convert (const Any &value) const
 Converts a Any value to the output type. More...
 
template<typename InType >
void addConverter (std::function< OutType(const InType &)> func)
 Adds a supported conversion. More...
 
template<typename InType >
void addCastConversion ()
 Adds a supported conversion from a type that can be directly cast. More...
 

Member Function Documentation

template<typename OutType>
template<typename InType >
void gmx::OptionValueConverterSimple< OutType >::addCastConversion ( )
inline

Adds a supported conversion from a type that can be directly cast.

Template Parameters
InTypeType to convert from with a simple cast.
template<typename OutType>
template<typename InType >
void gmx::OptionValueConverterSimple< OutType >::addConverter ( std::function< OutType(const InType &)>  func)
inline

Adds a supported conversion.

Template Parameters
InTypeType to convert from.
Parameters
funcFunction to convert from InType to OutType.
template<typename OutType>
OutType gmx::OptionValueConverterSimple< OutType >::convert ( const Any value) const
inline

Converts a Any value to the output type.

Returns
Converted value.
Exceptions
InvalidInputErrorIf the input Any has a type that is not recognized by any conversion.

The documentation for this class was generated from the following file: