[in] Enum value to be converted to a string.
EnumToName
Converts an enum value into a string representation.
Syntax
Section titled “Syntax”template <typename T>bool EnumToName(T enumVal, CString& strName) const;Parameters
Section titled “Parameters”enumVal
strName
[out] String version of the specified enum value.
Return value
Section titled “Return value”Returns true if the conversion was successful, otherwise false.
Remarks
Section titled “Remarks”This function is typically used to report errors when enum values are not supported. For instance, it is much more helpful to the user if an error is reported as “Trigger source cannot be set to Acme4321TriggerSourceExternal” as opposed to “Trigger source cannot be set to 3”.
Note that this function is used for a completely different purpose than the EnumToCommand function, which is used to map between enum values and their associated instrument commands.
Example
Section titled “Example”The following example demonstrates use of the EnumToName function.
HRESULT Acme4321::ConfigureTrigger(IviFgenTriggerSource eSource){ HRESULT hr = S_OK;
// Only internal and external triggering are supported switch (eSource) { case IviFgenTriggerSourceInternal: hr = io.WriteString(_T("TRIG:SOUR INT")); break; case IviFgenTriggerSourceExternal: hr = io.WriteString(_T("TRIG:SOUR EXT")); break; default: CString strEnum; EnumToName<IviFgenTriggerSource>(eSource, strEnum);
hr = err.InvalidValue(_T("eSource"), strEnum); break; }
return hr;}