SOIL C++
C++ Unified Device Interface
SOIL::Enum Class Reference

SOIL Enum Datatype. More...

#include <Enum.h>

Public Member Functions

 Enum ()
 Constructor. More...
 
 Enum (std::string value)
 Constructor intialized with value. More...
 
 Enum (std::string value, std::vector< std::string > choices)
 Initializing Container. More...
 
 ~Enum ()
 Destructor. More...
 
std::string selected (void) const
 Get selected value. More...
 
std::vector< std::string > choices (void)
 Get Choices. More...
 
int index () const
 Get index of selected element. More...
 
int index (std::string value) const
 Determine index of value. More...
 
void set (int value)
 Set selected item (index) More...
 
void set (std::string value)
 Set selected item (value) More...
 

Detailed Description

C++ class to represent the SOIL Enum datatype. Internally it is based on strings.

Definition at line 15 of file Enum.h.

Constructor & Destructor Documentation

◆ Enum() [1/3]

SOIL::Enum::Enum ( )

Standard constructor which leaves everything uninitialized.

Definition at line 4 of file Enum.cpp.

◆ Enum() [2/3]

SOIL::Enum::Enum ( std::string  value)

Constructor that initializes the enumeration with a selected value.

Todo:
Check whether this constructor is still meaningful in future releases. Usage is not recommended.
Parameters
[in]valueValue for initialization

Definition at line 8 of file Enum.cpp.

◆ Enum() [3/3]

SOIL::Enum::Enum ( std::string  value,
std::vector< std::string >  choices 
)

Constructor that initializes the enumeration with choices and a value.

Parameters
[in]valueValue for initialization
[in]choicesApplicable set of choices for the enumeration

Definition at line 12 of file Enum.cpp.

◆ ~Enum()

SOIL::Enum::~Enum ( )

Standard destructor without special efforts.

Definition at line 17 of file Enum.cpp.

Member Function Documentation

◆ choices()

std::vector< std::string > SOIL::Enum::choices ( void  )

Get the choices that are available for this enumeration.

Returns
Available choices as vector of strings

Definition at line 26 of file Enum.cpp.

◆ index() [1/2]

int SOIL::Enum::index ( ) const

Traversed the vector of choices and return the index of the current element.

Returns
Index of the selected element

Definition at line 31 of file Enum.cpp.

◆ index() [2/2]

int SOIL::Enum::index ( std::string  value) const

Converts a string value to its integer value. This function is useful when interacting with C++ ENUMs consisting of integers.

Exceptions
std::logic_errorIf the value is not found, an exception is thrown.
Parameters
[in]valueValue to search
Returns
Index of the searched value

Definition at line 43 of file Enum.cpp.

◆ selected()

std::string SOIL::Enum::selected ( void  ) const

Get the value that the enum currently holds as selected.

Returns
Current value

Definition at line 21 of file Enum.cpp.

◆ set() [1/2]

void SOIL::Enum::set ( int  value)

Set the currently selected item the enumeration holds based on its integer index.

Exceptions
std::logic_errorIf the index exceeds the number of choices, an exception is thrown.
Parameters
[in]valueIndex of the value to set

Definition at line 55 of file Enum.cpp.

◆ set() [2/2]

void SOIL::Enum::set ( std::string  value)

Set the currently selected item the enumeration holds based on a string value.

Exceptions
std::logic_errorIf the value is not among the choices, an exception is thrown.
Parameters
[in]valueValue to set

Definition at line 67 of file Enum.cpp.


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