casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IBMDataConversion.h
Go to the documentation of this file.
1 //# IBMDataConversion.h: A class with virtual functions to convert IBM format
2 //# Copyright (C) 1996,1999,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_IBMDATACONVERSION_H
29 #define CASA_IBMDATACONVERSION_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
34 
35 
36 namespace casacore { //# NAMESPACE CASACORE - BEGIN
37 
38 // <summary>
39 // A class with virtual functions to convert IBM format.
40 // </summary>
41 
42 // <use visibility=export>
43 
44 // <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tDataConversion" demos="">
45 // </reviewed>
46 
47 // <synopsis>
48 // This class is a specialization of the abstract base class
49 // <linkto class=DataConversion>DataConversion</linkto>.
50 // It contains functions to convert data from/to the old IBM format
51 // using the static functions in class <linkto class=IBMConversion>
52 // IBMConversion</linkto>.
53 // </synopsis>
54 
55 // <example>
56 // See example in class <linkto class=DataConversion>DataConversion</linkto>.
57 // </example>
58 
59 // <motivation>
60 // This class is an addition to <linkto class=IBMConversion>IBMConversion
61 // </linkto> to be able to use the conversion functions in a polymorphic way.
62 // </motivation>
63 
64 // <todo asof="$DATE$">
65 // <li> Support data type long double.
66 // </todo>
67 
68 
70 {
71 public:
72  // Construct the object.
74 
75  virtual ~IBMDataConversion();
76 
77  // Convert one value from IBM format to local format.
78  // The from and to buffer should not overlap.
79  // <note>
80  // The char version converts from EBCDIC to ASCII, while the
81  // unsigned char version is a simple copy.
82  // </note>
83  // <group>
84  virtual size_t toLocal (char& to, const void* from) const;
85  virtual size_t toLocal (unsigned char& to, const void* from) const;
86  virtual size_t toLocal (short& to, const void* from) const;
87  virtual size_t toLocal (unsigned short& to, const void* from) const;
88  virtual size_t toLocal (int& to, const void* from) const;
89  virtual size_t toLocal (unsigned int& to, const void* from) const;
90  virtual size_t toLocal (Int64& to, const void* from) const;
91  virtual size_t toLocal (uInt64& to, const void* from) const;
92  virtual size_t toLocal (float& to, const void* from) const;
93  virtual size_t toLocal (double& to, const void* from) const;
94  // </group>
95 
96  // Convert nr values from IBM format to local format.
97  // The from and to buffer should not overlap.
98  // <note>
99  // The char version converts from EBCDIC to ASCII, while the
100  // unsigned char version is a simple copy.
101  // </note>
102  // <group>
103  virtual size_t toLocal (char* to, const void* from,
104  size_t nr) const;
105  virtual size_t toLocal (unsigned char* to, const void* from,
106  size_t nr) const;
107  virtual size_t toLocal (short* to, const void* from,
108  size_t nr) const;
109  virtual size_t toLocal (unsigned short* to, const void* from,
110  size_t nr) const;
111  virtual size_t toLocal (int* to, const void* from,
112  size_t nr) const;
113  virtual size_t toLocal (unsigned int* to, const void* from,
114  size_t nr) const;
115  virtual size_t toLocal (Int64* to, const void* from,
116  size_t nr) const;
117  virtual size_t toLocal (uInt64* to, const void* from,
118  size_t nr) const;
119  virtual size_t toLocal (float* to, const void* from,
120  size_t nr) const;
121  virtual size_t toLocal (double* to, const void* from,
122  size_t nr) const;
123  // </group>
124 
125  // Convert one value from local format to IBM format.
126  // The from and to buffer should not overlap.
127  // <note>
128  // The char version converts from ASCII to EBCDIC, while the
129  // unsigned char version is a simple copy.
130  // </note>
131  // <group>
132  virtual size_t fromLocal (void* to, char from) const;
133  virtual size_t fromLocal (void* to, unsigned char from) const;
134  virtual size_t fromLocal (void* to, short from) const;
135  virtual size_t fromLocal (void* to, unsigned short from) const;
136  virtual size_t fromLocal (void* to, int from) const;
137  virtual size_t fromLocal (void* to, unsigned int from) const;
138  virtual size_t fromLocal (void* to, Int64 from) const;
139  virtual size_t fromLocal (void* to, uInt64 from) const;
140  virtual size_t fromLocal (void* to, float from) const;
141  virtual size_t fromLocal (void* to, double from) const;
142  // </group>
143 
144  // Convert nr values from local format to IBM format.
145  // The from and to buffer should not overlap.
146  // <note>
147  // The char version converts from ASCII to EBCDIC, while the
148  // unsigned char version is a simple copy.
149  // </note>
150  // <group>
151  virtual size_t fromLocal (void* to, const char* from,
152  size_t nr) const;
153  virtual size_t fromLocal (void* to, const unsigned char* from,
154  size_t nr) const;
155  virtual size_t fromLocal (void* to, const short* from,
156  size_t nr) const;
157  virtual size_t fromLocal (void* to, const unsigned short* from,
158  size_t nr) const;
159  virtual size_t fromLocal (void* to, const int* from,
160  size_t nr) const;
161  virtual size_t fromLocal (void* to, const unsigned int* from,
162  size_t nr) const;
163  virtual size_t fromLocal (void* to, const Int64* from,
164  size_t nr) const;
165  virtual size_t fromLocal (void* to, const uInt64* from,
166  size_t nr) const;
167  virtual size_t fromLocal (void* to, const float* from,
168  size_t nr) const;
169  virtual size_t fromLocal (void* to, const double* from,
170  size_t nr) const;
171  // </group>
172 
173  // Determine if the data for a data type can be simply copied, thus
174  // if no conversion is needed.
175  // <group>
176  virtual Bool canCopy (const char*) const;
177  virtual Bool canCopy (const unsigned char*) const;
178  virtual Bool canCopy (const short*) const;
179  virtual Bool canCopy (const unsigned short*) const;
180  virtual Bool canCopy (const int*) const;
181  virtual Bool canCopy (const unsigned int*) const;
182  virtual Bool canCopy (const Int64*) const;
183  virtual Bool canCopy (const uInt64*) const;
184  virtual Bool canCopy (const float*) const;
185  virtual Bool canCopy (const double*) const;
186  // </group>
187 
188  // Get the external size of the data type.
189  // <group>
190  virtual unsigned int externalSize (const char*) const;
191  virtual unsigned int externalSize (const unsigned char*) const;
192  virtual unsigned int externalSize (const short*) const;
193  virtual unsigned int externalSize (const unsigned short*) const;
194  virtual unsigned int externalSize (const int*) const;
195  virtual unsigned int externalSize (const unsigned int*) const;
196  virtual unsigned int externalSize (const Int64*) const;
197  virtual unsigned int externalSize (const uInt64*) const;
198  virtual unsigned int externalSize (const float*) const;
199  virtual unsigned int externalSize (const double*) const;
200  // </group>
201 };
202 
203 
205 {}
206 
207 
208 
209 } //# NAMESPACE CASACORE - END
210 
211 #endif
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
Abstract base class with functions to convert any format.
virtual size_t toLocal(char &to, const void *from) const
Convert one value from IBM format to local format.
unsigned long long uInt64
Definition: aipsxtype.h:39
IBMDataConversion()
Construct the object.
A class with virtual functions to convert IBM format.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual size_t fromLocal(void *to, char from) const
Convert one value from local format to IBM format.
virtual Bool canCopy(const char *) const
Determine if the data for a data type can be simply copied, thus if no conversion is needed...
virtual unsigned int externalSize(const char *) const
Get the external size of the data type.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42