Changes in libcfa/src/enum.hfa [41c8312:07e9df1]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.hfa
r41c8312 r07e9df1 1 1 #pragma once 2 2 3 forall(T) { // T is the based type of enum(T) 4 forall(E) trait Bounded { 5 E lowerBound(); 6 E upperBound(); 7 }; 3 forall( E ) trait Bounded { 4 E lowerBound(); 5 E upperBound(); 6 }; 8 7 9 forall(E| Bounded(T, E)) trait Serial {10 unsigned fromInstance(E e);11 E fromInt(unsigned i);12 E succ(E e);13 E pred(E e);14 8 forall( E | Bounded( E ) ) trait Serial { 9 unsigned fromInstance( E e ); 10 E fromInt( unsigned int posn ); 11 E succ( E e ); 12 E pred( E e ); 13 }; 15 14 16 // Opague Enum + TypedEnum 17 forall(E | Serial(T, E)) trait CfaEnum { 18 char * labelE(E e);19 unsigned int posE(E e);20 15 forall( E, T ) trait TypedEnum { 16 T valueE( E e ); 17 char * labelE( E e ); 18 unsigned int posE( E e ); 19 }; 21 20 22 forall(E| CfaEnum(T, E)) trait TypedEnum { 23 T valueE(E e); 24 }; 25 26 forall(E | TypedEnum(T, E)) { 27 // comparison 28 int ?==?(E l, E r); 29 int ?!=?(E l, E r); 30 int ?!=?(E l, zero_t); 31 int ?<?(E l, E r); 32 int ?<=?(E l, E r); 33 int ?>?(E l, E r); 34 int ?>=?(E l, E r); 35 } 21 forall( E, T | TypedEnum( E, T ) ) { 22 // comparison 23 int ?==?( E l, E r ); // true if l and r are same enumerators 24 int ?!=?( E l, E r ); // true if l and r are different enumerators 25 int ?!=?( E l, zero_t ); // true if l is not the first enumerator 26 int ?<?( E l, E r ); // true if l is an enuemerator before r 27 int ?<=?( E l, E r ); // true if l before or the same as r 28 int ?>?( E l, E r ); // true if l is an enuemrator after r 29 int ?>=?( E l, E r ); // true if l after or the same as r 36 30 }
Note: See TracChangeset
for help on using the changeset viewer.