00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef CASA_MODCOMPCONVERSION_H
00029 #define CASA_MODCOMPCONVERSION_H
00030
00031 #include <casacore/casa/aips.h>
00032 #include <casacore/casa/Utilities/Assert.h>
00033 #include <casacore/casa/OS/CanonicalConversion.h>
00034
00035 namespace casacore {
00036
00037
00038
00039
00040 #define SIZE_MODCOMP_CHAR 1
00041 #define SIZE_MODCOMP_UCHAR 1
00042 #define SIZE_MODCOMP_SHORT 2
00043 #define SIZE_MODCOMP_USHORT 2
00044 #define SIZE_MODCOMP_INT 4
00045 #define SIZE_MODCOMP_UINT 4
00046 #define SIZE_MODCOMP_INT64 4
00047 #define SIZE_MODCOMP_UINT64 4
00048 #define SIZE_MODCOMP_FLOAT 4
00049 #define SIZE_MODCOMP_DOUBLE 8
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 #define CONVERT_MODCOMP_CHAR 0
00062 #define CONVERT_MODCOMP_UCHAR 0
00063
00064
00065 #if defined(AIPS_LITTLE_ENDIAN)
00066 #define CONVERT_MODCOMP_SHORT 1
00067 #define CONVERT_MODCOMP_USHORT 1
00068 #define CONVERT_MODCOMP_INT 1
00069 #define CONVERT_MODCOMP_UINT 1
00070 #define CONVERT_MODCOMP_INT64 1
00071 #define CONVERT_MODCOMP_UINT64 1
00072 #else
00073
00074
00075 #define CONVERT_MODCOMP_SHORT 0
00076 #define CONVERT_MODCOMP_USHORT 0
00077 #define CONVERT_MODCOMP_INT 0
00078 #define CONVERT_MODCOMP_UINT 0
00079 #define CONVERT_MODCOMP_INT64 1
00080 #define CONVERT_MODCOMP_UINT64 1
00081 #endif
00082
00083 #define CONVERT_MODCOMP_FLOAT 1
00084 #define CONVERT_MODCOMP_DOUBLE 1
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 class ModcompConversion
00117 {
00118 public:
00119
00120
00121
00122 static size_t toLocal(Char& to, const void* from);
00123 static size_t toLocal(uChar& to, const void* from);
00124 static size_t toLocal(Short& to, const void* from);
00125 static size_t toLocal(uShort& to, const void* from);
00126 static size_t toLocal(Int& to, const void* from);
00127 static size_t toLocal(uInt& to, const void* from);
00128 static size_t toLocal(Int64& to, const void* from);
00129 static size_t toLocal(uInt64& to, const void* from);
00130 static size_t toLocal(Float& to, const void* from);
00131 static size_t toLocal(Double& to, const void* from);
00132
00133
00134
00135
00136
00137 static size_t toLocal(Char* to, const void* from, size_t nr);
00138 static size_t toLocal(uChar* to, const void* from, size_t nr);
00139 static size_t toLocal(Short* to, const void* from, size_t nr);
00140 static size_t toLocal(uShort* to, const void* from, size_t nr);
00141 static size_t toLocal(Int* to, const void* from, size_t nr);
00142 static size_t toLocal(uInt* to, const void* from, size_t nr);
00143 static size_t toLocal(Int64* to, const void* from, size_t nr);
00144 static size_t toLocal(uInt64* to, const void* from, size_t nr);
00145 static size_t toLocal(Float* to, const void* from, size_t nr);
00146 static size_t toLocal(Double* to, const void* from, size_t nr);
00147
00148
00149
00150
00151
00152
00153 static size_t fromLocal(void* to, Char from);
00154 static size_t fromLocal(void* to, uChar from);
00155 static size_t fromLocal(void* to, Short from);
00156 static size_t fromLocal(void* to, uShort from);
00157 static size_t fromLocal(void* to, Int from);
00158 static size_t fromLocal(void* to, uInt from);
00159 static size_t fromLocal(void* to, Int64 from);
00160 static size_t fromLocal(void* to, uInt64 from);
00161 static size_t fromLocal(void* to, Float from);
00162 static size_t fromLocal(void* to, Double from);
00163
00164
00165
00166
00167
00168
00169 static size_t fromLocal(void* to, const Char* from, size_t nr);
00170 static size_t fromLocal(void* to, const uChar* from, size_t nr);
00171 static size_t fromLocal(void* to, const Short* from, size_t nr);
00172 static size_t fromLocal(void* to, const uShort* from, size_t nr);
00173 static size_t fromLocal(void* to, const Int* from, size_t nr);
00174 static size_t fromLocal(void* to, const uInt* from, size_t nr);
00175 static size_t fromLocal(void* to, const Int64* from, size_t nr);
00176 static size_t fromLocal(void* to, const uInt64* from, size_t nr);
00177 static size_t fromLocal(void* to, const Float* from, size_t nr);
00178 static size_t fromLocal(void* to, const Double* from, size_t nr);
00179
00180
00181 private:
00182
00183
00184 ModcompConversion();
00185 };
00186
00187 inline size_t ModcompConversion::toLocal(Char& to, const void* from) {
00188 return CanonicalConversion::toLocal(to, from);
00189 }
00190
00191 inline size_t ModcompConversion::toLocal(uChar& to, const void* from) {
00192 return CanonicalConversion::toLocal(to, from);
00193 }
00194
00195 inline size_t ModcompConversion::toLocal(Short& to, const void* from) {
00196 return CanonicalConversion::toLocal(to, from);
00197 }
00198
00199 inline size_t ModcompConversion::toLocal(uShort& to, const void* from) {
00200 return CanonicalConversion::toLocal(to, from);
00201 }
00202
00203 inline size_t ModcompConversion::toLocal(Int& to, const void* from) {
00204 return CanonicalConversion::toLocal(to, from);
00205 }
00206
00207 inline size_t ModcompConversion::toLocal(uInt& to, const void* from) {
00208 return CanonicalConversion::toLocal(to, from);
00209 }
00210
00211 inline size_t ModcompConversion::toLocal(Int64& to, const void* from) {
00212 Int tmp;
00213 size_t res = toLocal (tmp, from);
00214 to = tmp;
00215 return res;
00216 }
00217
00218 inline size_t ModcompConversion::toLocal(uInt64& to, const void* from) {
00219 uInt tmp;
00220 size_t res = toLocal (tmp, from);
00221 to = tmp;
00222 return res;
00223 }
00224
00225 inline size_t ModcompConversion::toLocal(Float& to, const void* from) {
00226 return ModcompConversion::toLocal(&to, from, 1u);
00227 }
00228
00229 inline size_t ModcompConversion::toLocal(Double& to, const void* from) {
00230 return ModcompConversion::toLocal(&to, from, 1u);
00231 }
00232
00233 inline size_t ModcompConversion::toLocal(Char* to, const void* from, size_t nr) {
00234 return CanonicalConversion::toLocalChar(to, from, nr);
00235 }
00236
00237 inline size_t ModcompConversion::toLocal(uChar* to, const void* from, size_t nr) {
00238 return CanonicalConversion::toLocalUChar(to, from, nr);
00239 }
00240
00241 inline size_t ModcompConversion::toLocal(Short* to, const void* from, size_t nr) {
00242 return CanonicalConversion::toLocalShort(to, from, nr);
00243 }
00244
00245 inline size_t ModcompConversion::toLocal(uShort* to, const void* from, size_t nr) {
00246 return CanonicalConversion::toLocalUShort(to, from, nr);
00247 }
00248
00249 inline size_t ModcompConversion::toLocal(Int* to, const void* from, size_t nr) {
00250 return CanonicalConversion::toLocalInt(to, from, nr);
00251 }
00252
00253 inline size_t ModcompConversion::toLocal(uInt* to, const void* from, size_t nr) {
00254 return CanonicalConversion::toLocalUInt(to, from, nr);
00255 }
00256
00257 inline size_t ModcompConversion::fromLocal(void* to, Char from) {
00258 return CanonicalConversion::fromLocal(to, from);
00259 }
00260
00261 inline size_t ModcompConversion::fromLocal(void* to, uChar from) {
00262 return CanonicalConversion::fromLocal(to, from);
00263 }
00264
00265 inline size_t ModcompConversion::fromLocal(void* to, Short from) {
00266 return CanonicalConversion::fromLocal (to, from);
00267 }
00268
00269 inline size_t ModcompConversion::fromLocal(void* to, uShort from) {
00270 return CanonicalConversion::fromLocal(to, from);
00271 }
00272
00273 inline size_t ModcompConversion::fromLocal(void* to, Int from) {
00274 return CanonicalConversion::fromLocal (to, from);
00275 }
00276
00277 inline size_t ModcompConversion::fromLocal(void* to, uInt from) {
00278 return CanonicalConversion::fromLocal (to, from);
00279 }
00280
00281 inline size_t ModcompConversion::fromLocal(void* to, Int64 from) {
00282 return CanonicalConversion::fromLocal (to, (Int) from);
00283 }
00284
00285 inline size_t ModcompConversion::fromLocal(void* to, uInt64 from) {
00286 return CanonicalConversion::fromLocal (to, (uInt) from);
00287 }
00288
00289 inline size_t ModcompConversion::fromLocal(void* to, Float from) {
00290 return ModcompConversion::fromLocal(to, &from, 1u);
00291 }
00292
00293 inline size_t ModcompConversion::fromLocal(void* to, Double from) {
00294 return ModcompConversion::fromLocal(to, &from, 1u);
00295 }
00296
00297 inline size_t ModcompConversion::fromLocal(void* to, const Char* from, size_t nr) {
00298 return CanonicalConversion::fromLocalChar(to, from, nr);
00299 }
00300
00301 inline size_t ModcompConversion::fromLocal(void* to, const uChar* from, size_t nr){
00302 return CanonicalConversion::fromLocalUChar(to, from, nr);
00303 }
00304
00305 inline size_t ModcompConversion::fromLocal(void* to, const Short* from, size_t nr){
00306 return CanonicalConversion::fromLocalShort(to, from, nr);
00307 }
00308
00309 inline size_t ModcompConversion::fromLocal(void* to, const uShort* from,size_t nr){
00310 return CanonicalConversion::fromLocalUShort(to, from, nr);
00311 }
00312
00313 inline size_t ModcompConversion::fromLocal(void* to, const Int* from, size_t nr) {
00314 return CanonicalConversion::fromLocalInt(to, from, nr);
00315 }
00316
00317 inline size_t ModcompConversion::fromLocal(void* to, const uInt* from, size_t nr) {
00318 return CanonicalConversion::fromLocalUInt(to, from, nr);
00319 }
00320
00321
00322
00323 }
00324
00325 #endif