39 EndianSwapper::EndianSwapper(QString inputEndian) {
41 if(inputEndian !=
"LSB" && inputEndian !=
"MSB") {
42 string message =
"Invalid parameter-InputEndian must be LSB or MSB";
62 EndianSwapper::~EndianSwapper() {
71 double EndianSwapper::Double(
void *buf) {
72 double result = *(
double *)buf;
75 char *ptr = (
char *)buf + (
sizeof(
double) - 1) * p_needSwap;
77 for(
unsigned int i = 0; i <
sizeof(double); i++) {
78 p_swapper.p_char[i] = *ptr;
79 ptr += p_swapDirection;
82 result = p_swapper.p_double;
94 float EndianSwapper::Float(
void *buf) {
95 float result = *(
float *)buf;
98 char *ptr = (
char *)buf + (
sizeof(
float) - 1) * p_needSwap;
100 for(
unsigned int i = 0; i <
sizeof(float); i++) {
101 p_swapper.p_char[i] = *ptr;
102 ptr += p_swapDirection;
105 result = p_swapper.p_float;
115 int EndianSwapper::ExportFloat(
void *buf) {
124 int EndianSwapper::Int(
void *buf) {
125 int result = *(
int *)buf;
128 char *ptr = (
char *)buf + (
sizeof(
int) - 1) * p_needSwap;
130 for(
unsigned int i = 0; i <
sizeof(int); i++) {
131 p_swapper.p_char[i] = *ptr;
132 ptr += p_swapDirection;
135 result = p_swapper.p_int;
146 uint32_t EndianSwapper::Uint32_t(
void *buf) {
147 uint32_t result = *(uint32_t *)buf;
150 char *ptr = (
char *)buf + (
sizeof(uint32_t) - 1) * p_needSwap;
152 for(
unsigned int i = 0; i <
sizeof(uint32_t); i++) {
153 p_swapper.p_char[i] = *ptr;
154 ptr += p_swapDirection;
157 result = p_swapper.p_uint32;
168 long long int EndianSwapper::LongLongInt(
void *buf) {
169 long long int result = *(
long long int *)buf;
172 char *ptr = (
char *)buf + (
sizeof(
long long int) - 1) * p_needSwap;
174 for(
unsigned int i = 0; i <
sizeof(
long long int); i++) {
175 p_swapper.p_char[i] = *ptr;
176 ptr += p_swapDirection;
179 result = p_swapper.p_longLongInt;
190 short int EndianSwapper::ShortInt(
void *buf) {
191 short int result = *(
short int *)buf;
194 char *ptr = (
char *)buf + (
sizeof(
short int) - 1) * p_needSwap;
196 for(
unsigned int i = 0; i <
sizeof(
short int); i++) {
197 p_swapper.p_char[i] = *ptr;
198 ptr += p_swapDirection;
201 result = p_swapper.p_shortInt;
213 unsigned short int EndianSwapper::UnsignedShortInt(
void *buf) {
214 unsigned short int result = *(
unsigned short int *)buf;
216 char *ptr = (
char *)buf + (
sizeof(
unsigned short int) - 1) * p_needSwap;
218 for(
unsigned int i = 0; i <
sizeof(
unsigned short int); i++) {
219 p_swapper.p_char[i] = *ptr;
220 ptr += p_swapDirection;
223 result = p_swapper.p_uShortInt;
Namespace for the standard library.
#define _FILEINFO_
Macro for the filename and line number.
bool IsLsb()
Return true if this host is an LSB first machine and false if it is not.
Namespace for ISIS/Bullet specific routines.
bool IsMsb()
Return true if this host is an MSB first machine and false if it is not.