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_VALTYPE_H
00029 #define CASA_VALTYPE_H
00030
00031
00032
00033 #include <casacore/casa/aips.h>
00034 #include <casacore/casa/Utilities/DataType.h>
00035 #include <casacore/casa/BasicSL/String.h>
00036 #include <casacore/casa/BasicSL/Complex.h>
00037 #include <casacore/casa/Utilities/Compare.h>
00038 #include <casacore/casa/Utilities/CountedPtr.h>
00039 #include <casacore/casa/OS/Conversion.h>
00040 #include <casacore/casa/IO/AipsIO.h>
00041 #include <casacore/casa/iosfwd.h>
00042
00043 namespace casacore {
00044
00045
00046 class TableRecord;
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 class ValType {
00080 public:
00081
00082
00083
00084
00085 static Bool undefBool ();
00086 static Char undefChar ();
00087 static uChar undefUChar ();
00088 static Short undefShort ();
00089 static uShort undefUShort ();
00090 static Int undefInt ();
00091 static uInt undefUInt ();
00092 static Int64 undefInt64 ();
00093 static float undefFloat ();
00094 static double undefDouble ();
00095 static Complex undefComplex ();
00096 static DComplex undefDComplex ();
00097 static String undefString ();
00098
00099
00100
00101
00102
00103
00104 static void getUndef (Bool*);
00105 static void getUndef (Char*);
00106 static void getUndef (uChar*);
00107 static void getUndef (Short*);
00108 static void getUndef (uShort*);
00109 static void getUndef (Int*);
00110 static void getUndef (uInt*);
00111 static void getUndef (Int64*);
00112 static void getUndef (float*);
00113 static void getUndef (double*);
00114 static void getUndef (Complex*);
00115 static void getUndef (DComplex*);
00116 static void getUndef (String*);
00117 static void getUndef (void*);
00118
00119
00120
00121
00122
00123 static DataType getType (const Bool*);
00124 static DataType getType (const Char*);
00125 static DataType getType (const uChar*);
00126 static DataType getType (const Short*);
00127 static DataType getType (const uShort*);
00128 static DataType getType (const Int*);
00129 static DataType getType (const uInt*);
00130 static DataType getType (const Int64*);
00131 static DataType getType (const float*);
00132 static DataType getType (const double*);
00133 static DataType getType (const Complex*);
00134 static DataType getType (const DComplex*);
00135 static DataType getType (const String*);
00136 static DataType getType (const TableRecord*);
00137 static DataType getType (const void*);
00138
00139
00140
00141
00142
00143 static const String& getTypeStr (DataType);
00144 static const String& getTypeStr (const Bool*);
00145 static const String& getTypeStr (const Char*);
00146 static const String& getTypeStr (const uChar*);
00147 static const String& getTypeStr (const Short*);
00148 static const String& getTypeStr (const uShort*);
00149 static const String& getTypeStr (const Int*);
00150 static const String& getTypeStr (const uInt*);
00151 static const String& getTypeStr (const Int64*);
00152 static const String& getTypeStr (const float*);
00153 static const String& getTypeStr (const double*);
00154 static const String& getTypeStr (const Complex*);
00155 static const String& getTypeStr (const DComplex*);
00156 static const String& getTypeStr (const String*);
00157 static const String& getTypeStr (const TableRecord*);
00158 static const String& getTypeStr (const void*);
00159
00160
00161
00162 static int getTypeSize (DataType);
00163
00164
00165
00166
00167 static int getCanonicalSize (DataType, Bool BECanonical = True);
00168
00169
00170
00171
00172
00173
00174
00175 static void getCanonicalFunc (DataType dt,
00176 Conversion::ValueFunction*& readFunc,
00177 Conversion::ValueFunction*& writeFunc,
00178 uInt& nrElementsPerValue,
00179 Bool BECanonical = True);
00180
00181
00182 static Bool isPromotable (DataType from, DataType to);
00183
00184
00185 static ObjCompareFunc* getCmpFunc (DataType);
00186
00187
00188 static CountedPtr<BaseCompare> getCmpObj (DataType);
00189
00190
00191
00192
00193
00194 static void put (AipsIO&, const Bool*);
00195 static void put (AipsIO&, const Char*);
00196 static void put (AipsIO&, const uChar*);
00197 static void put (AipsIO&, const Short*);
00198 static void put (AipsIO&, const uShort*);
00199 static void put (AipsIO&, const Int*);
00200 static void put (AipsIO&, const uInt*);
00201 static void put (AipsIO&, const Int64*);
00202 static void put (AipsIO&, const float*);
00203 static void put (AipsIO&, const double*);
00204 static void put (AipsIO&, const Complex*);
00205 static void put (AipsIO&, const DComplex*);
00206 static void put (AipsIO&, const String*);
00207 static void put (AipsIO&, const void*);
00208
00209
00210
00211
00212
00213
00214 static void get (AipsIO&, Bool*);
00215 static void get (AipsIO&, Char*);
00216 static void get (AipsIO&, uChar*);
00217 static void get (AipsIO&, Short*);
00218 static void get (AipsIO&, uShort*);
00219 static void get (AipsIO&, Int*);
00220 static void get (AipsIO&, uInt*);
00221 static void get (AipsIO&, Int64*);
00222 static void get (AipsIO&, float*);
00223 static void get (AipsIO&, double*);
00224 static void get (AipsIO&, Complex*);
00225 static void get (AipsIO&, DComplex*);
00226 static void get (AipsIO&, String*);
00227 static void get (AipsIO&, void*);
00228
00229
00230
00231
00232
00233
00234 static void put (ostream&, const Bool*);
00235 static void put (ostream&, const Char*);
00236 static void put (ostream&, const uChar*);
00237 static void put (ostream&, const Short*);
00238 static void put (ostream&, const uShort*);
00239 static void put (ostream&, const Int*);
00240 static void put (ostream&, const uInt*);
00241 static void put (ostream&, const Int64*);
00242 static void put (ostream&, const float*);
00243 static void put (ostream&, const double*);
00244 static void put (ostream&, const Complex*);
00245 static void put (ostream&, const DComplex*);
00246 static void put (ostream&, const String*);
00247 static void put (ostream&, const void*);
00248
00249
00250
00251
00252
00253
00254
00255 static int isDefined (const Bool* value, const Bool* undef);
00256 static int isDefined (const Char* value, const Char* undef);
00257 static int isDefined (const uChar* value, const uChar* undef);
00258 static int isDefined (const Short* value, const Short* undef);
00259 static int isDefined (const uShort* value, const uShort* undef);
00260 static int isDefined (const Int* value, const Int* undef);
00261 static int isDefined (const uInt* value, const uInt* undef);
00262 static int isDefined (const Int64* value, const Int64* undef);
00263 static int isDefined (const float* value, const float* undef);
00264 static int isDefined (const double* value, const double* undef);
00265 static int isDefined (const Complex* value, const Complex* undef);
00266 static int isDefined (const DComplex* value, const DComplex* undef);
00267 static int isDefined (const String* value, const String* undef);
00268 static int isDefined (const void* value, const void* undef);
00269
00270
00271 private:
00272 static const Bool undefbool ;
00273 static const Char undefchar ;
00274 static const uChar undefuchar ;
00275 static const Short undefshort ;
00276 static const uShort undefushort ;
00277 static const Int undefint ;
00278 static const uInt undefuint ;
00279 static const Int64 undefint64 ;
00280 static const float undeffloat ;
00281 static const double undefdouble ;
00282 static const Complex undefcomplex ;
00283 static const DComplex undefdcomplex;
00284 static const String undefstring ;
00285
00286 static const String strbool;
00287 static const String strchar;
00288 static const String struchar;
00289 static const String strshort;
00290 static const String strushort;
00291 static const String strint;
00292 static const String struint;
00293 static const String strint64;
00294 static const String strfloat;
00295 static const String strdouble;
00296 static const String strcomplex;
00297 static const String strdcomplex;
00298 static const String strstring;
00299 static const String strrecord;
00300 static const String strtable;
00301 static const String strother;
00302 static const String strunknown;
00303
00304
00305
00306 ValType ();
00307 };
00308
00309
00310
00311 inline Bool ValType::undefBool ()
00312 {return undefbool;}
00313 inline Char ValType::undefChar ()
00314 {return undefchar;}
00315 inline uChar ValType::undefUChar ()
00316 {return undefuchar;}
00317 inline Short ValType::undefShort ()
00318 {return undefshort;}
00319 inline uShort ValType::undefUShort ()
00320 {return undefushort;}
00321 inline Int ValType::undefInt ()
00322 {return undefint;}
00323 inline uInt ValType::undefUInt ()
00324 {return undefuint;}
00325 inline Int64 ValType::undefInt64 ()
00326 {return undefint64;}
00327 inline float ValType::undefFloat ()
00328 {return undeffloat;}
00329 inline double ValType::undefDouble ()
00330 {return undefdouble;}
00331 inline Complex ValType::undefComplex ()
00332 {return undefcomplex;}
00333 inline DComplex ValType::undefDComplex ()
00334 {return undefdcomplex;}
00335 inline String ValType::undefString ()
00336 {return undefstring;}
00337
00338
00339 inline void ValType::getUndef (Bool* val)
00340 {*val = undefbool;}
00341 inline void ValType::getUndef (Char* val)
00342 {*val = undefchar;}
00343 inline void ValType::getUndef (uChar* val)
00344 {*val = undefuchar;}
00345 inline void ValType::getUndef (Short* val)
00346 {*val = undefshort;}
00347 inline void ValType::getUndef (uShort* val)
00348 {*val = undefushort;}
00349 inline void ValType::getUndef (Int* val)
00350 {*val = undefint;}
00351 inline void ValType::getUndef (uInt* val)
00352 {*val = undefuint;}
00353 inline void ValType::getUndef (Int64* val)
00354 {*val = undefint64;}
00355 inline void ValType::getUndef (float* val)
00356 {*val = undeffloat;}
00357 inline void ValType::getUndef (double* val)
00358 {*val = undefdouble;}
00359 inline void ValType::getUndef (Complex* val)
00360 {*val = undefcomplex;}
00361 inline void ValType::getUndef (DComplex* val)
00362 {*val = undefdcomplex;}
00363 inline void ValType::getUndef (String* val)
00364 {*val = undefstring;}
00365 inline void ValType::getUndef (void*)
00366 {}
00367
00368 inline DataType ValType::getType (const Bool*)
00369 {return TpBool;}
00370 inline DataType ValType::getType (const Char*)
00371 {return TpChar;}
00372 inline DataType ValType::getType (const uChar*)
00373 {return TpUChar;}
00374 inline DataType ValType::getType (const Short*)
00375 {return TpShort;}
00376 inline DataType ValType::getType (const uShort*)
00377 {return TpUShort;}
00378 inline DataType ValType::getType (const Int*)
00379 {return TpInt;}
00380 inline DataType ValType::getType (const uInt*)
00381 {return TpUInt;}
00382 inline DataType ValType::getType (const Int64*)
00383 {return TpInt64;}
00384 inline DataType ValType::getType (const float*)
00385 {return TpFloat;}
00386 inline DataType ValType::getType (const double*)
00387 {return TpDouble;}
00388 inline DataType ValType::getType (const Complex*)
00389 {return TpComplex;}
00390 inline DataType ValType::getType (const DComplex*)
00391 {return TpDComplex;}
00392 inline DataType ValType::getType (const String*)
00393 {return TpString;}
00394 inline DataType ValType::getType (const TableRecord*)
00395 {return TpRecord;}
00396 inline DataType ValType::getType (const void*)
00397 {return TpOther;}
00398
00399 inline const String& ValType::getTypeStr (const Bool*)
00400 {return strbool;}
00401 inline const String& ValType::getTypeStr (const Char*)
00402 {return strchar;}
00403 inline const String& ValType::getTypeStr (const uChar*)
00404 {return struchar;}
00405 inline const String& ValType::getTypeStr (const Short*)
00406 {return strshort;}
00407 inline const String& ValType::getTypeStr (const uShort*)
00408 {return strushort;}
00409 inline const String& ValType::getTypeStr (const Int*)
00410 {return strint;}
00411 inline const String& ValType::getTypeStr (const uInt*)
00412 {return struint;}
00413 inline const String& ValType::getTypeStr (const Int64*)
00414 {return strint64;}
00415 inline const String& ValType::getTypeStr (const float*)
00416 {return strfloat;}
00417 inline const String& ValType::getTypeStr (const double*)
00418 {return strdouble;}
00419 inline const String& ValType::getTypeStr (const Complex*)
00420 {return strcomplex;}
00421 inline const String& ValType::getTypeStr (const DComplex*)
00422 {return strdcomplex;}
00423 inline const String& ValType::getTypeStr (const String*)
00424 {return strstring;}
00425 inline const String& ValType::getTypeStr (const TableRecord*)
00426 {return strrecord;}
00427 inline const String& ValType::getTypeStr (const void*)
00428 {return strother;}
00429
00430 inline void ValType::put (AipsIO& ios, const Bool* value)
00431 {ios << *value;}
00432 inline void ValType::put (AipsIO& ios, const Char* value)
00433 {ios << *value;}
00434 inline void ValType::put (AipsIO& ios, const uChar* value)
00435 {ios << *value;}
00436 inline void ValType::put (AipsIO& ios, const Short* value)
00437 {ios << *value;}
00438 inline void ValType::put (AipsIO& ios, const uShort* value)
00439 {ios << *value;}
00440 inline void ValType::put (AipsIO& ios, const Int* value)
00441 {ios << *value;}
00442 inline void ValType::put (AipsIO& ios, const uInt* value)
00443 {ios << *value;}
00444 inline void ValType::put (AipsIO& ios, const Int64* value)
00445 {ios << *value;}
00446 inline void ValType::put (AipsIO& ios, const float* value)
00447 {ios << *value;}
00448 inline void ValType::put (AipsIO& ios, const double* value)
00449 {ios << *value;}
00450 inline void ValType::put (AipsIO& ios, const Complex* value)
00451 {ios << *value;}
00452 inline void ValType::put (AipsIO& ios, const DComplex* value)
00453 {ios << *value;}
00454 inline void ValType::put (AipsIO& ios, const String* value)
00455 {ios << *value;}
00456 inline void ValType::put (AipsIO&, const void*)
00457 {}
00458
00459 inline void ValType::get (AipsIO& ios, Bool* value)
00460 {ios >> *value;}
00461 inline void ValType::get (AipsIO& ios, Char* value)
00462 {ios >> *value;}
00463 inline void ValType::get (AipsIO& ios, uChar* value)
00464 {ios >> *value;}
00465 inline void ValType::get (AipsIO& ios, Short* value)
00466 {ios >> *value;}
00467 inline void ValType::get (AipsIO& ios, uShort* value)
00468 {ios >> *value;}
00469 inline void ValType::get (AipsIO& ios, Int* value)
00470 {ios >> *value;}
00471 inline void ValType::get (AipsIO& ios, uInt* value)
00472 {ios >> *value;}
00473 inline void ValType::get (AipsIO& ios, Int64* value)
00474 {ios >> *value;}
00475 inline void ValType::get (AipsIO& ios, float* value)
00476 {ios >> *value;}
00477 inline void ValType::get (AipsIO& ios, double* value)
00478 {ios >> *value;}
00479 inline void ValType::get (AipsIO& ios, Complex* value)
00480 {ios >> *value;}
00481 inline void ValType::get (AipsIO& ios, DComplex* value)
00482 {ios >> *value;}
00483 inline void ValType::get (AipsIO& ios, String* value)
00484 {ios >> *value;}
00485 inline void ValType::get (AipsIO&, void*)
00486 {}
00487
00488 inline void ValType::put (ostream& ios, const Bool* value)
00489 {ios << *value;}
00490 inline void ValType::put (ostream& ios, const Char* value)
00491 {ios << *value;}
00492 inline void ValType::put (ostream& ios, const uChar* value)
00493 {ios << *value;}
00494 inline void ValType::put (ostream& ios, const Short* value)
00495 {ios << *value;}
00496 inline void ValType::put (ostream& ios, const uShort* value)
00497 {ios << *value;}
00498 inline void ValType::put (ostream& ios, const Int* value)
00499 {ios << *value;}
00500 inline void ValType::put (ostream& ios, const uInt* value)
00501 {ios << *value;}
00502 inline void ValType::put (ostream& ios, const Int64* value)
00503 {ios << *value;}
00504 inline void ValType::put (ostream& ios, const float* value)
00505 {ios << *value;}
00506 inline void ValType::put (ostream& ios, const double* value)
00507 {ios << *value;}
00508 inline void ValType::put (ostream& ios, const Complex* value)
00509 {ios << *value;}
00510 inline void ValType::put (ostream& ios, const DComplex* value)
00511 {ios << *value;}
00512 inline void ValType::put (ostream& ios, const String* value)
00513 {ios << *value;}
00514 inline void ValType::put (ostream&, const void*)
00515 {}
00516
00517
00518 inline int ValType::isDefined (const Bool* value, const Bool* undef)
00519 {return *value != *undef;}
00520 inline int ValType::isDefined (const Char* value, const Char* undef)
00521 {return *value != *undef;}
00522 inline int ValType::isDefined (const uChar* value, const uChar* undef)
00523 {return *value != *undef;}
00524 inline int ValType::isDefined (const Short* value, const Short* undef)
00525 {return *value != *undef;}
00526 inline int ValType::isDefined (const uShort* value, const uShort* undef)
00527 {return *value != *undef;}
00528 inline int ValType::isDefined (const Int* value, const Int* undef)
00529 {return *value != *undef;}
00530 inline int ValType::isDefined (const uInt* value, const uInt* undef)
00531 {return *value != *undef;}
00532 inline int ValType::isDefined (const Int64* value, const Int64* undef)
00533 {return *value != *undef;}
00534 inline int ValType::isDefined (const float* value, const float* undef)
00535 {return *value != *undef;}
00536 inline int ValType::isDefined (const double* value, const double* undef)
00537 {return *value != *undef;}
00538 inline int ValType::isDefined (const Complex* value, const Complex* undef)
00539 {return *value != *undef;}
00540 inline int ValType::isDefined (const DComplex* value, const DComplex* undef)
00541 {return *value != *undef;}
00542 inline int ValType::isDefined (const String* value, const String* undef)
00543 {return *value != *undef;}
00544 inline int ValType::isDefined (const void*, const void*)
00545 {return 1;}
00546
00547
00548
00549 }
00550
00551 #endif
00552
00553
00554