26#ifndef CASA_LITTLEENDIANCONVERSION_H
27#define CASA_LITTLEENDIANCONVERSION_H
30#include <casacore/casa/aips.h>
31#include <casacore/casa/OS/CanonicalConversion.h>
68 static void toLocal(
char& to,
const void* from);
69 static void toLocal(
unsigned char& to,
const void* from);
70 static void toLocal(
short& to,
const void* from);
71 static void toLocal(
unsigned short& to,
const void* from);
72 static void toLocal(
int& to,
const void* from);
73 static void toLocal(
unsigned int& to,
const void* from);
76 static void toLocal(
float& to,
const void* from);
77 static void toLocal(
double& to,
const void* from);
83 static void toLocal(
char* to,
const void* from,
size_t nr);
84 static void toLocal(
unsigned char* to,
const void* from,
size_t nr);
85 static void toLocal(
short* to,
const void* from,
size_t nr);
86 static void toLocal(
unsigned short* to,
const void* from,
size_t nr);
87 static void toLocal(
int* to,
const void* from,
size_t nr);
88 static void toLocal(
unsigned int* to,
const void* from,
size_t nr);
91 static void toLocal(
float* to,
const void* from,
size_t nr);
92 static void toLocal(
double* to,
const void* from,
size_t nr);
98 static void fromLocal(
void* to,
char from);
99 static void fromLocal(
void* to,
unsigned char from);
100 static void fromLocal(
void* to,
short from);
101 static void fromLocal(
void* to,
unsigned short from);
102 static void fromLocal(
void* to,
int from);
103 static void fromLocal(
void* to,
unsigned int from);
106 static void fromLocal(
void* to,
float from);
107 static void fromLocal(
void* to,
double from);
113 static void fromLocal(
void* to,
const char* from,
size_t nr);
114 static void fromLocal(
void* to,
const unsigned char* from,
size_t nr);
115 static void fromLocal(
void* to,
const short* from,
size_t nr);
116 static void fromLocal(
void* to,
const unsigned short* from,
size_t nr);
117 static void fromLocal(
void* to,
const int* from,
size_t nr);
118 static void fromLocal(
void* to,
const unsigned int* from,
size_t nr);
121 static void fromLocal(
void* to,
const float* from,
size_t nr);
122 static void fromLocal(
void* to,
const double* from,
size_t nr);
134 to = *(
unsigned char*)from;
138 if (
sizeof(
short) != 2) {
139 if (((
signed char*)from)[2] < 0) {
145#if !defined(AIPS_LITTLE_ENDIAN)
153 if (
sizeof(
unsigned short) != 2) {
156#if !defined(AIPS_LITTLE_ENDIAN)
164 if (
sizeof(
int) != 4) {
165 if (((
signed char*)from)[3] < 0) {
171#if !defined(AIPS_LITTLE_ENDIAN)
179 if (
sizeof(
unsigned int) != 4) {
182#if !defined(AIPS_LITTLE_ENDIAN)
202#if !defined(AIPS_LITTLE_ENDIAN)
210#if !defined(AIPS_LITTLE_ENDIAN)
219 *(
unsigned char*)to = from;
223#if !defined(AIPS_LITTLE_ENDIAN)
231#if !defined(AIPS_LITTLE_ENDIAN)
239#if !defined(AIPS_LITTLE_ENDIAN)
247#if !defined(AIPS_LITTLE_ENDIAN)
255#if !defined(AIPS_LITTLE_ENDIAN)
263#if !defined(AIPS_LITTLE_ENDIAN)
271#if !defined(AIPS_LITTLE_ENDIAN)
279#if !defined(AIPS_LITTLE_ENDIAN)
static void reverse8(void *to, const void *from)
Reverse 8 bytes.
static void move8(void *to, const void *from)
Move 8 bytes.
static void reverse4(void *to, const void *from)
Reverse 4 bytes.
static void reverse2(void *to, const void *from)
Reverse 2 bytes.
static void move2(void *to, const void *from)
Move 2 bytes.
static void move4(void *to, const void *from)
Move 4 bytes.
static void fromLocal(void *to, const short *from, size_t nr)
static void toLocal(unsigned int *to, const void *from, size_t nr)
static void fromLocal(void *to, const char *from, size_t nr)
Convert nr values from local format to littleEndian format.
static void fromLocal(void *to, const float *from, size_t nr)
static void toLocal(Int64 *to, const void *from, size_t nr)
static void fromLocal(void *to, const Int64 *from, size_t nr)
static void toLocal(unsigned char *to, const void *from, size_t nr)
static void toLocal(int *to, const void *from, size_t nr)
static void toLocal(unsigned short *to, const void *from, size_t nr)
static void toLocal(char *to, const void *from, size_t nr)
Convert nr values from littleEndian format to local format.
static void fromLocal(void *to, const double *from, size_t nr)
static void toLocal(uInt64 *to, const void *from, size_t nr)
static void fromLocal(void *to, const unsigned short *from, size_t nr)
static void fromLocal(void *to, const unsigned char *from, size_t nr)
static void toLocal(char &to, const void *from)
Convert one value from littleEndian format to local format.
static void toLocal(float *to, const void *from, size_t nr)
static void toLocal(double *to, const void *from, size_t nr)
static void fromLocal(void *to, const unsigned int *from, size_t nr)
LittleEndianConversion()
This class should not be constructed (so declare the constructor private).
static void fromLocal(void *to, const uInt64 *from, size_t nr)
static void toLocal(short *to, const void *from, size_t nr)
static void fromLocal(void *to, const int *from, size_t nr)
static void fromLocal(void *to, char from)
Convert one value from local format to littleEndian format.
For temporary backward namespace compatibility, use casa as alias for casacore.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size).
unsigned long long uInt64