00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00014 template<class T> 00015 void switch_endianess_byte4(T &a) { 00016 char *p=(char*) &a; 00017 static char q[4]; 00018 if(sizeof(T)==4) { 00019 q[0]=p[0]; 00020 q[1]=p[1]; 00021 q[2]=p[2]; 00022 q[3]=p[3]; 00023 p[0]=q[3]; 00024 p[1]=q[2]; 00025 p[2]=q[1]; 00026 p[3]=q[0]; 00027 } else error("switch_endianess_byte4: sizeof(T)!=4"); 00028 }