Enum interface. Use this interface to convert an enum to a string, and set an enum from a string. More...
#include <EnumIface.hh>
Public Member Functions | |
| EnumIface (T _start, T _end, const std::vector< std::string > &_names) | |
| Constructor. | |
| T | Begin () |
| Get the beginning enum value. | |
| T | End () |
| Get the end enum value. | |
| void | Set (T &_e, const std::string &_str) |
| Set an enum from a string. This function requires a valid string, and an array of names for the enum must exist. | |
| std::string | Str (T const &_e) |
| Convert enum value to string. | |
Public Attributes | |
| std::vector< std::string > | names |
| T | range [2] |
Detailed Description
class gz::common::EnumIface< T >
Enum interface. Use this interface to convert an enum to a string, and set an enum from a string.
Constructor & Destructor Documentation
◆ EnumIface()
|
inline |
Constructor.
- Parameters
-
[in] _start Starting enum value. [in] _end Ending enum value. [in] _names Name of each enum value.
References EnumIface< T >::range.
Member Function Documentation
◆ Begin()
|
inline |
Get the beginning enum value.
- Returns
- Enum value that marks the beginning of the enum list.
References EnumIface< T >::range.
◆ End()
|
inline |
Get the end enum value.
- Returns
- Enum value that marks the end of the enum list.
References EnumIface< T >::range.
◆ Set()
|
inline |
Set an enum from a string. This function requires a valid string, and an array of names for the enum must exist.
- Parameters
-
[in] _str String value to convert to enum value. [in] _e Enum variable to set.
- See also
- EnumIterator
References std::begin(), std::distance(), std::end(), std::find(), and EnumIface< T >::names.
◆ Str()
|
inline |
Convert enum value to string.
- Parameters
-
[in] _e Enum value to convert.
- Returns
- String representation of the enum. An empty string is returned if _e is invalid, or the names for the enum have not been set.
References EnumIface< T >::names, and vector< T >::size().
Member Data Documentation
◆ names
| std::vector<std::string> names |
Referenced by EnumIface< T >::Set(), and EnumIface< T >::Str().
◆ range
| T range[2] |
Referenced by EnumIface< T >::EnumIface(), EnumIface< T >::Begin(), and EnumIface< T >::End().
The documentation for this class was generated from the following file: