AAO DRAMA/DRAMA2 C++ Interface
|
A class which reads Enumerated values from a SDS argument structures.
This is an template class used for cases where we want to fetch a STRING action argument which must then be converted to an enum type. That is, the string is a representation of an enumerated value.
drama::gitarg::Enum is a template class. Two template arguments are required - "LookupClass" and "EnumType". The former must be a sub-class of drama::gitarg::EnumLookupClass. The later is a normally simple enum type - it must be possible to cast this class from an integer and cast back to an integer from this class.
LookupClass | A sub-class of drama::gitarg::EnumLookupClass with GetMaxValue() and GetStringArray() implemented. |
EnumType | The underlying enumerated type. Must be possible to cast to and from an int. Must have values for 0 through to LookupClass->GetMaxValue()+1 inclusive (no gaps), where GetMaxValues()+1 is used to indicate an invalid value. |
#include "gitarg.hh"
Public Member Functions | |
Enum () | |
Default contructor for the object. More... | |
Enum (EnumType InitialValue) | |
Constructor with initial value supplied. More... | |
Enum (const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr) | |
Constructor which contructs the value from an item in an SDS structure. More... | |
virtual | ~Enum () |
Destructor. More... | |
void | Get (const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr) |
Get the value of the object from an SDS structure. More... | |
operator EnumType () const | |
Return the underlying value of this object. More... | |
operator std::string () const | |
Return the underlying value of this object as a string. More... | |
|
inline |
Default contructor for the object.
This will set the value of the object to be the invalid value, obtained by setting the value to the lookup class's GetMaxValue() value + 1.
|
inline |
Constructor with initial value supplied.
The initial value must be one of the values in the enum type.
InitialValue | The initial value for the objects. |
|
inline |
Constructor which contructs the value from an item in an SDS structure.
The value is fetched from the named item (arg #2) within the SDS structure specified. or the Position (constructor arg #3) item in the structure if the item named does not exist.
Id | The SDS structure. |
Name | The name of the item within the structure. |
Position | If the item does not exist by the name, then presume this position. |
Default | The default value. If not specified, the first enum value is used. |
flags | Which GIT Flags to apply. If you specify KeepErr, then an exception is thrown if the value in the SDS structure is invalid. If you don't specify KeepErr and and the SDS structure is invalid, then the enum value is set to the Invalid value. |
|
inlinevirtual |
Destructor.
|
inline |
Get the value of the object from an SDS structure.
The value is fetch from the named item (arg #2) within the SDS structure specified. or the Position (constructor arg #3) item in the structure if the item named does not exist.
Id | The SDS structure. |
Name | The name of the item within the structure. |
Position | If the item does not exist by the name, then presume this position. |
Default | The default value. If not specified use 0 (first enum val) |
flags | Which GIT Flags to apply. If you specify KeepErr, then an exception is thrown if the value in the SDS structure is invalid. If you don't specify KeepErr and and the SDS structure does not contain a value item, then the enum value is set to the Invalid value. |
Referenced by drama::gitarg::Enum< ResetEnumLookup, ResetEnum >::Enum().
|
inline |
Return the underlying value of this object.
|
inline |
Return the underlying value of this object as a string.
Click here for the DRAMA home page and here for the AAO home page.
For more information, contact tjf@aao.gov.au Generated on Mon Feb 22 2016 15:57:53 for AAO DRAMA/DRAMA2 C++ Interface by