Ada Programming/Attributes/'Value

Description
The 'Value attribute is defined for any scalar type. This attribute is a function that parses the string and returns the corresponding type value, if it exists. Leading and trailing spaces are trimmed.

S'Value (Arg: String) S'Base;

If the string does not correspond to any value of the type, then the Constraint_Error exception is raised.

There are corresponding attributes for Wide_String and Wide_Wide_String.

Don't confuse this attribute with the Ada Programming/Attributes/'Val attribute.

Example
My_Enum (Enum1, Enum2, Enum3); (My_Enum'Value ("ENUM1")   = Enum1); (My_Enum'Value (" ENUM1 ") = Enum1); (My_Enum'Value ("ZOWIE!")  = Enum1);

Wikibook

 * Ada Programming
 * Ada Programming/Attributes
 * Ada Programming/Attributes/'Image

Ada Reference Manual


|Value