84 DataBuffer* buffer = GetCurrentBuffer (); |
84 DataBuffer* buffer = GetCurrentBuffer (); |
85 buffer->Write<T> (stuff); |
85 buffer->Write<T> (stuff); |
86 return; |
86 return; |
87 } |
87 } |
88 |
88 |
89 // Cannot use default arguments in function templates.. |
89 // Default to word |
90 void Write (word stuff) {Write<word> (stuff);} |
90 void Write (word stuff) { |
|
91 Write<word> (stuff); |
|
92 } |
91 |
93 |
92 template <class T> void WriteDataToFile (T stuff) { |
94 template <class T> void WriteDataToFile (T stuff) { |
93 // One byte at a time |
95 // One byte at a time |
94 for (unsigned int x = 0; x < sizeof (T); x++) { |
96 for (unsigned int x = 0; x < sizeof (T); x++) { |
95 unsigned char c = GetByteIndex<T> (stuff, x); |
97 union_t<T> uni; |
96 fwrite (&c, 1, 1, fp); |
98 uni.val = stuff; |
|
99 fwrite (&uni.b[x], 1, 1, fp); |
97 numWrittenBytes++; |
100 numWrittenBytes++; |
98 } |
101 } |
99 } |
102 } |
100 }; |
103 }; |
101 |
104 |