Go to the documentation of this file.00001
00002 #ifndef vnl_matlab_header_h_
00003 #define vnl_matlab_header_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007
00008 #undef swap32
00009 #undef swap64
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <vxl_config.h>
00021
00022 struct vnl_matlab_header
00023 {
00024 vxl_int_32 type;
00025 vxl_int_32 rows;
00026 vxl_int_32 cols;
00027 vxl_int_32 imag;
00028 vxl_int_32 namlen;
00029
00030 enum type_t {
00031
00032 vnl_DOUBLE_PRECISION = 0,
00033 vnl_SINGLE_PRECISION = 10,
00034
00035 vnl_COLUMN_WISE = 0,
00036 vnl_ROW_WISE = 100,
00037
00038 vnl_LITTLE_ENDIAN = 0,
00039 vnl_BIG_ENDIAN = 1000,
00040
00041 vnl_none = 0
00042 };
00043 };
00044
00045 namespace byteswap
00046 {
00047 inline void
00048 swap32(void *ptr)
00049 {
00050 char one_byte;
00051 char *p = reinterpret_cast<char *>(ptr);
00052 one_byte = p[0]; p[0] = p[3]; p[3] = one_byte;
00053 one_byte = p[1]; p[1] = p[2]; p[2] = one_byte;
00054 }
00055 inline void
00056 swap64(void *ptr)
00057 {
00058 char one_byte;
00059 char *p = reinterpret_cast<char *>(ptr);
00060 one_byte = p[0]; p[0] = p[7]; p[7] = one_byte;
00061 one_byte = p[1]; p[1] = p[6]; p[6] = one_byte;
00062 one_byte = p[2]; p[2] = p[5]; p[5] = one_byte;
00063 one_byte = p[3]; p[3] = p[4]; p[4] = one_byte;
00064 }
00065 }
00066
00067 #endif // vnl_matlab_header_h_