System.TypInfo.GetEnumValue

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function GetEnumValue(TypeInfo: PTypeInfo; const Name: string): Integer;

C++

extern DELPHI_PACKAGE int __fastcall GetEnumValue(PTypeInfo TypeInfo, const System::UnicodeString Name);

Properties

Type Visibility Source Unit Parent
function public
System.TypInfo.pas
System.TypInfo.hpp
System.TypInfo System.TypInfo

Description

Returns the value of an enumerated type constant given its string representation.

Use GetEnumValue to convert the string that represents an enumerated value into the corresponding integer that is its implemented value.

TypeInfo is the type information record that describes the enumerated type. You can obtain the type information for a type by calling the TypeInfo function in Delphi or using the __delphirtti operator in C++.

The Name argument should contains a string representation of an enumerated type constant. GetEnumValue uses a case-insensitive match.

GetEnumValue returns the corresponding integer value, or -1 if Name does not match any constant in the supplied TypeInfo.

Sample syntax:

 I := System.TypInfo.GetEnumValue(TypeInfo(TAbc), 'abcSomeOption');

See Also