#include "enum.hfa" #include "fstream.hfa" #include #pragma GCC visibility push(default) forall( istype & | istream( istype ), E, V | CfaEnum( E, V ) ) istype & ?|?( istype & is, E & e ) { if ( eof( is ) ) throwResume ExceptionInst( missing_data ); char val[256]; int args = fmt( is, "%255s", val ); if ( ! eof( is ) && args != 1 ) throwResume ExceptionInst( missing_data ); for ( s; E ) { if ( strcmp(val, label( s )) == 0 ) { e = s; break; } } else { fprintf( stderr, "invalid enumeration constant\n" ); abort(); // cannot use abort stream } // for return is; } forall( ostype & | ostream( ostype ), E, V | CfaEnum( E, V ) ) { ostype & ?|?( ostype & os, E e ) { return os | label( e ); } OSTYPE_VOID_IMPL( E ) } forall( ostype & | ostream( ostype ), E | CfaEnum( E, quasi_void ) ) { ostype & ?|?( ostype & os, E e ) { return os | label( e ); } OSTYPE_VOID_IMPL( E ) }