Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

NativeTypeRead.h

Go to the documentation of this file.
00001 #ifndef Impala_Basis_NativeTypeRead_h
00002 #define Impala_Basis_NativeTypeRead_h
00003 
00004 #include "Basis/NativeTypes.h"
00005 #include "Basis/NativeTypeFormats.h"
00006 #include "Basis/Endian.h"
00007 #include <cstdio>
00008 
00009 namespace Impala
00010 {
00011 
00012 
00013 template <class Type>
00014 inline void
00015 NativeTypeRead(FILE* fp, Type* ptr)
00016 {
00017     NativeTypeRead(fp, ptr, Type());
00018 }
00019 
00020 // does the real work
00021 template <class Type, class IntermediateType>
00022 inline void
00023 NativeTypeRead(FILE* fp, Type* ptr, IntermediateType dummy)
00024 {
00025     String fs = NativeTypeFormat<Type>(0);
00026     IntermediateType buf;
00027     fscanf(fp, fs.c_str(), &buf);
00028     EndianSwap(&buf);
00029     *ptr = (Type) buf;
00030 }
00031 
00032 // template specializations
00033 
00034 template <>
00035 inline void
00036 NativeTypeRead<UInt8>(FILE* fp, UInt8* ptr)
00037 {
00038     NativeTypeRead(fp, ptr, UInt32());
00039 }
00040 
00041 template <>
00042 inline void
00043 NativeTypeRead<UInt16>(FILE* fp, UInt16* ptr)
00044 {
00045     NativeTypeRead(fp, ptr, UInt32());
00046 }
00047 
00048 template <>
00049 inline void
00050 NativeTypeRead<Int8>(FILE* fp, Int8* ptr)
00051 {
00052     NativeTypeRead(fp, ptr, Int32());
00053 }
00054 
00055 template <>
00056 inline void
00057 NativeTypeRead<Int16>(FILE* fp, Int16* ptr)
00058 {
00059     NativeTypeRead(fp, ptr, Int32());
00060 }
00061 
00062 } // namespace Impala
00063 
00064 #endif

Generated on Fri Mar 19 09:30:42 2010 for ImpalaSrc by  doxygen 1.5.1