CDPEnum Class
The CDP Enum is a class to hold enums as string/value pairs. More...
| Header: | #include <CDPEnum> |
| Inherits: | ValueNode<CDP::StudioAPI::CDPNode> |
Public Functions
| CDPEnum(const std::string &name) | |
| CDPEnum(const std::string &name, const std::vector<CDPEnumPair> &enums) | |
| ~CDPEnum() | |
| void | AddEnumToList(const std::string &name, int value) |
| void | FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const override |
| const std::string | GetNodeName() const override |
| CDP::StudioAPI::CDPNodeType | GetNodeType() const override |
| std::string | GetNodeTypeName() const override |
| void | Set(const std::vector<CDPEnumPair> &enums) |
| operator const std::string &() const | |
| operator int() const | |
| bool | operator!=(const int val) |
| int | operator=(const int rhs) |
| const std::string & | operator=(const std::string &val) |
| bool | operator==(const int val) |
| bool | operator==(const std::string &val) |
- 9 public functions inherited from ValueNode
- 8 public functions inherited from CDP::StudioAPI::AbstractValueListener
Detailed Description
The CDP Enum is a class to hold enums as string/value pairs.
Example:
CDPEnum enum("StateEnum"); enum.Set({{"e_Stopped",e_Stopped}, {"e_Running",e_Running}, {"e_Error",e_Error}}); enum = e_Stopped; // or you can use enum = "e_Stopped", but that is marginally slower; enum = e_Halted; // this won't change the enum value, as that is not a defined enum! assert(enum==e_Stopped); enum.AddEnumToList("e_Halted",(int)e_Halted); enum = e_Halted; // This changes the enum value to e_Halted assert(enum==e_Halted); // now this works
Member Function Documentation
CDPEnum::CDPEnum(const std::string &name)
Constructs a CDPEnum.
Parameter name should give a unique name to this CDPNode.
CDPEnum::CDPEnum(const std::string &name, const std::vector<CDPEnumPair> &enums)
Constructs a CDPEnum from a list of entries which set all possible enum values.
Parameter name should give a unique name to this CDPNode.
CDPEnum::~CDPEnum()
Destructs the instance.
void CDPEnum::AddEnumToList(const std::string &name, int value)
Adds an enum to the list of enums available in this CDPEnum.
Parameter name will be the string represenation of this enum value. Parameter value will be the numeric value of this enum.
void CDPEnum::FillNodeChildren(CDP::StudioAPI::NodeStream &serializer) const
const std::string CDPEnum::GetNodeName() const
CDP::StudioAPI::CDPNodeType CDPEnum::GetNodeType() const
std::string CDPEnum::GetNodeTypeName() const
void CDPEnum::Set(const std::vector<CDPEnumPair> &enums)
Appends a list of enums.
Could be specified like this: { {"A", 1}, {"B", 2} }
CDPEnum::operator const std::string &() const
Returns the value of this object as a string.
CDPEnum::operator int() const
Returns the value of this object as an integer.
bool CDPEnum::operator!=(const int val)
Inequality operator for type int.
int CDPEnum::operator=(const int rhs)
Assignment operator from an integer.
const std::string &CDPEnum::operator=(const std::string &val)
Assignment operator from const std::string&.
bool CDPEnum::operator==(const int val)
Comparison operator with an integer.
bool CDPEnum::operator==(const std::string &val)
Comparison operator with const std::string&.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.