import c.stdio; //For debug output import std.file; template TReadData(T) { /*! * Gets a single value of the type */ T single(inout ubyte *iter) { T t = *(T*) iter; iter += T.size; return t; } /* * Get fixed array. * \param len is the number of characters to get */ T [] fixedArray(inout ubyte *iter, int len) { T [] array; if ( len < 0 ) { printf("[Error] Length less then zero (%d)", len); throw new FileException("Array Length Overflow"); return array; //Return empty array } array.length = len; int bytelen = len * T.size; array[0..len] = cast(T[])iter[0..bytelen]; iter += bytelen; return array; } /* * Gets a array where the length is followed by the array */ T [] array(inout ubyte *iter) { int len = *(int*) iter; iter += int.size; return fixedArray(iter, len); } /* * Get zero-terminated array and turns it into a D array. */ T [] zeroArray(inout ubyte *iter) { T [] array; for ( ;*iter; iter+=T.size) {array ~= *(T*) iter;} return array; } } alias TReadData!(float) ReadFloat; alias TReadData!(int) ReadInt; alias TReadData!(uint) ReadUInt; alias TReadData!(ubyte) ReadUByte; alias TReadData!(char) ReadString; alias ReadVec3.single readVec3; alias ReadInt.single readInt; alias ReadFloat.single readFloat; void printLine(ubyte *iter, ubyte *master) { printf("Line: %d\n", (uint)(iter - master)); } int main( char [] [] args ) { return 1; }