past as switch( subj )
body of all cases past as formated with one argument (DataType) string
exception in selected cases
enum fmt = q{ auto dst = getTypedArray!(storeDataType!(%1$s))( info.comp, buffer ); auto src = flatData!real(vals); foreach( i, ref t; dst ) t = convertValue!(%1$s)( srci ); }; writeln( genSwitchDataType( "info.type", fmt, ["RAWBYTE": "can't operate RAWBYTE"] ) );
Output like this:
final switch( info.type ) { case DataType.RAWBYTE: throw new DataTypeException( "can't operate RAWBYTE" ); case DataType.BYTE: auto dst = getTypedArray!(storeDataType!(DataType.BYTE))( info.comp, buffer ); auto src = flatData!real(vals); foreach( i, ref t; dst ) t = convertValue!(DataType.BYTE)( srci ); break; case DataType.UBYTE: auto dst = getTypedArray!(storeDataType!(DataType.UBYTE))( info.comp, buffer ); auto src = flatData!real(vals); foreach( i, ref t; dst ) t = convertValue!(DataType.UBYTE)( srci ); break; ... }
generate switch for all DataType elements