Skip to content

Enumeration type object

Philippe Proulx edited this page Mar 19, 2016 · 2 revisions

A CTF enumeration type.

Each label of an enumeration type is mapped to a single value, or to a range of values.

See also: Type object.

Properties

Property Type Description Required? Default value
class String Set to enum or enumeration Required N/A
value-type Integer type object or string (alias name) Supporting integer type Required N/A
members Array of enumeration type member objects Enumeration members Required N/A

The members property must contain at least one element. If the member is a string, its associated value is computed as follows:

  • If the member is the first one of the members array, its value is 0.
  • If the previous member is a string, its value is the previous member's computed value + 1.
  • If the previous member is a single value member, its value is the previous member's value + 1.
  • If the previous member is a range member, its value is the previous member's upper bound + 1.

The member values cannot overlap each other.

Example

class: enum
value-type: uint8
members:
  - ZERO
  - ONE
  - TWO
  - label: SIX
    value: 6
  - SE7EN
  - label: TWENTY TO FOURTY
    value: [20, 40]
  - FORTY-ONE

Generated C type

Generated C type of supporting integer type (see Integer type object).

Enumeration type member object

The member of a CTF enumeration type.

If it's a string, the string is the member's label, and the members's value depends on the last member's value (see explanation above).

Otherwise, it's a complete member object, with the following properties:

Property Type Description Required? Default value
label String Member's label Required N/A
value Integer (single value) or array of two integers (range value) Member's value Required N/A

If the value property is an array of two integers, the member's label is associated to this range, both lower and upper bounds included. The array's first element must be lesser than or equal to the second element.

Example

label: my enum label
value: [-25, 78]