casa  $Rev:20696$
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
IBMDataConversion.h
Go to the documentation of this file.
00001 //# IBMDataConversion.h: A class with virtual functions to convert IBM format
00002 //# Copyright (C) 1996,1999,2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //# $Id: IBMDataConversion.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00027 
00028 #ifndef CASA_IBMDATACONVERSION_H
00029 #define CASA_IBMDATACONVERSION_H
00030 
00031 //# Includes
00032 #include <casa/aips.h>
00033 #include <casa/OS/DataConversion.h>
00034 
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 // <summary>
00039 // A class with virtual functions to convert IBM format.
00040 // </summary>
00041 
00042 // <use visibility=export>
00043 
00044 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tDataConversion" demos="">
00045 // </reviewed>
00046 
00047 // <synopsis>
00048 // This class is a specialization of the abstract base class
00049 // <linkto class=DataConversion>DataConversion</linkto>.
00050 // It contains functions to convert data from/to the old IBM format
00051 // using the static functions in class <linkto class=IBMConversion>
00052 // IBMConversion</linkto>.
00053 // </synopsis>
00054 
00055 // <example>
00056 // See example in class <linkto class=DataConversion>DataConversion</linkto>.
00057 // </example>
00058 
00059 // <motivation>
00060 // This class is an addition to <linkto class=IBMConversion>IBMConversion
00061 // </linkto> to be able to use the conversion functions in a polymorphic way.
00062 // </motivation>
00063 
00064 // <todo asof="$DATE$">
00065 //  <li> Support data type long double.
00066 // </todo>
00067 
00068 
00069 class IBMDataConversion : public DataConversion
00070 {
00071 public:
00072     // Construct the object.
00073     IBMDataConversion();
00074 
00075     virtual ~IBMDataConversion();
00076 
00077     // Convert one value from IBM format to local format.
00078     // The from and to buffer should not overlap.
00079     // <note>
00080     // The char version converts from EBCDIC to ASCII, while the
00081     // unsigned char version is a simple copy.
00082     // </note>
00083     // <group>
00084     virtual unsigned int toLocal (char&           to, const void* from) const;
00085     virtual unsigned int toLocal (unsigned char&  to, const void* from) const;
00086     virtual unsigned int toLocal (short&          to, const void* from) const;
00087     virtual unsigned int toLocal (unsigned short& to, const void* from) const;
00088     virtual unsigned int toLocal (int&            to, const void* from) const;
00089     virtual unsigned int toLocal (unsigned int&   to, const void* from) const;
00090     virtual unsigned int toLocal (Int64&          to, const void* from) const;
00091     virtual unsigned int toLocal (uInt64&         to, const void* from) const;
00092     virtual unsigned int toLocal (float&          to, const void* from) const;
00093     virtual unsigned int toLocal (double&         to, const void* from) const;
00094     // </group>
00095     
00096     // Convert nr values from IBM format to local format.
00097     // The from and to buffer should not overlap.
00098     // <note>
00099     // The char version converts from EBCDIC to ASCII, while the
00100     // unsigned char version is a simple copy.
00101     // </note>
00102     // <group>
00103     virtual unsigned int toLocal (char*           to, const void* from,
00104                                   unsigned int nr) const;
00105     virtual unsigned int toLocal (unsigned char*  to, const void* from,
00106                                   unsigned int nr) const;
00107     virtual unsigned int toLocal (short*          to, const void* from,
00108                                   unsigned int nr) const;
00109     virtual unsigned int toLocal (unsigned short* to, const void* from,
00110                                   unsigned int nr) const;
00111     virtual unsigned int toLocal (int*            to, const void* from,
00112                                   unsigned int nr) const;
00113     virtual unsigned int toLocal (unsigned int*   to, const void* from,
00114                                   unsigned int nr) const;
00115     virtual unsigned int toLocal (Int64*          to, const void* from,
00116                                   unsigned int nr) const;
00117     virtual unsigned int toLocal (uInt64*         to, const void* from,
00118                                   unsigned int nr) const;
00119     virtual unsigned int toLocal (float*          to, const void* from,
00120                                   unsigned int nr) const;
00121     virtual unsigned int toLocal (double*         to, const void* from,
00122                                   unsigned int nr) const;
00123     // </group>
00124 
00125     // Convert one value from local format to IBM format.
00126     // The from and to buffer should not overlap.
00127     // <note>
00128     // The char version converts from ASCII to EBCDIC, while the
00129     // unsigned char version is a simple copy.
00130     // </note>
00131     // <group>
00132     virtual unsigned int fromLocal (void* to, char           from) const;
00133     virtual unsigned int fromLocal (void* to, unsigned char  from) const;
00134     virtual unsigned int fromLocal (void* to, short          from) const;
00135     virtual unsigned int fromLocal (void* to, unsigned short from) const;
00136     virtual unsigned int fromLocal (void* to, int            from) const;
00137     virtual unsigned int fromLocal (void* to, unsigned int   from) const;
00138     virtual unsigned int fromLocal (void* to, Int64          from) const;
00139     virtual unsigned int fromLocal (void* to, uInt64         from) const;
00140     virtual unsigned int fromLocal (void* to, float          from) const;
00141     virtual unsigned int fromLocal (void* to, double         from) const;
00142     // </group>
00143     
00144     // Convert nr values from local format to IBM format.
00145     // The from and to buffer should not overlap.
00146     // <note>
00147     // The char version converts from ASCII to EBCDIC, while the
00148     // unsigned char version is a simple copy.
00149     // </note>
00150     // <group>
00151     virtual unsigned int fromLocal (void* to, const char*           from,
00152                                     unsigned int nr) const;
00153     virtual unsigned int fromLocal (void* to, const unsigned char*  from,
00154                                     unsigned int nr) const;
00155     virtual unsigned int fromLocal (void* to, const short*          from,
00156                                     unsigned int nr) const;
00157     virtual unsigned int fromLocal (void* to, const unsigned short* from,
00158                                     unsigned int nr) const;
00159     virtual unsigned int fromLocal (void* to, const int*            from,
00160                                     unsigned int nr) const;
00161     virtual unsigned int fromLocal (void* to, const unsigned int*   from,
00162                                     unsigned int nr) const;
00163     virtual unsigned int fromLocal (void* to, const Int64*          from,
00164                                     unsigned int nr) const;
00165     virtual unsigned int fromLocal (void* to, const uInt64*         from,
00166                                     unsigned int nr) const;
00167     virtual unsigned int fromLocal (void* to, const float*          from,
00168                                     unsigned int nr) const;
00169     virtual unsigned int fromLocal (void* to, const double*         from,
00170                                     unsigned int nr) const;
00171     // </group>
00172 
00173     // Determine if the data for a data type can be simply copied, thus
00174     // if no conversion is needed.
00175     // <group>
00176     virtual Bool canCopy (const char*) const;
00177     virtual Bool canCopy (const unsigned char*) const;
00178     virtual Bool canCopy (const short*) const;
00179     virtual Bool canCopy (const unsigned short*) const;
00180     virtual Bool canCopy (const int*) const;
00181     virtual Bool canCopy (const unsigned int*) const;
00182     virtual Bool canCopy (const Int64*) const;
00183     virtual Bool canCopy (const uInt64*) const;
00184     virtual Bool canCopy (const float*) const;
00185     virtual Bool canCopy (const double*) const;
00186     // </group>
00187 
00188     // Get the external size of the data type.
00189     // <group>
00190     virtual unsigned int externalSize (const char*) const;
00191     virtual unsigned int externalSize (const unsigned char*) const;
00192     virtual unsigned int externalSize (const short*) const;
00193     virtual unsigned int externalSize (const unsigned short*) const;
00194     virtual unsigned int externalSize (const int*) const;
00195     virtual unsigned int externalSize (const unsigned int*) const;
00196     virtual unsigned int externalSize (const Int64*) const;
00197     virtual unsigned int externalSize (const uInt64*) const;
00198     virtual unsigned int externalSize (const float*) const;
00199     virtual unsigned int externalSize (const double*) const;
00200     // </group>
00201 };
00202 
00203 
00204 inline IBMDataConversion::IBMDataConversion()
00205 {}
00206 
00207 
00208 
00209 } //# NAMESPACE CASA - END
00210 
00211 #endif