This file is indexed.

/usr/include/casacore/casa/OS/LECanonicalConversion.h is in casacore-dev 2.2.0-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
//# LECanonicalConversion.h: A class with static functions to convert little endian canonical format
//# Copyright (C) 2002
//# Associated Universities, Inc. Washington DC, USA.
//#
//# This library is free software; you can redistribute it and/or modify it
//# under the terms of the GNU Library General Public License as published by
//# the Free Software Foundation; either version 2 of the License, or (at your
//# option) any later version.
//#
//# This library is distributed in the hope that it will be useful, but WITHOUT
//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
//# License for more details.
//#
//# You should have received a copy of the GNU Library General Public License
//# along with this library; if not, write to the Free Software Foundation,
//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
//#
//# Correspondence concerning AIPS++ should be addressed as follows:
//#        Internet email: aips2-request@nrao.edu.
//#        Postal address: AIPS++ Project Office
//#                        National Radio Astronomy Observatory
//#                        520 Edgemont Road
//#                        Charlottesville, VA 22903-2475 USA
//#
//# $Id$

#ifndef CASA_LECANONICALCONVERSION_H
#define CASA_LECANONICALCONVERSION_H

//# Includes
#include <casacore/casa/aips.h>
#include <casacore/casa/OS/Conversion.h>
#include <cstring>


namespace casacore { //# NAMESPACE CASACORE - BEGIN

// Define the little endian canonical sizes of the built-in data types.
// These are the same for all machine architectures.

#define SIZE_LECAN_CHAR     1
#define SIZE_LECAN_UCHAR    1
#define SIZE_LECAN_SHORT    2
#define SIZE_LECAN_USHORT   2
#define SIZE_LECAN_INT      4
#define SIZE_LECAN_UINT     4
#define SIZE_LECAN_INT64    8
#define SIZE_LECAN_UINT64   8
#define SIZE_LECAN_FLOAT    4
#define SIZE_LECAN_DOUBLE   8
//#//define SIZE_LECAN_LDOUBLE 16


// Define for each data format if a conversion is needed from the
// local format to the little endian canonical format (or vice-versa).
// This allows for optimizations in, for example, AipsIO.
// The canonical format is ASCII for strings, IEEE for floating point
// and 2-complement for integers (all most significant bit last)
// with the lengths as shown above.
// The function checkConvert() can be used to check if the flags are
// set correctly.

// Conversion is needed for big endian architectures (like SUN),
// because the bytes have to be swapped (thus not for data with length 1).
#define CONVERT_LECAN_CHAR     0
#define CONVERT_LECAN_UCHAR    0

#if !defined(AIPS_LITTLE_ENDIAN)
#  define CONVERT_LECAN_SHORT    1
#  define CONVERT_LECAN_USHORT   1
#  define CONVERT_LECAN_INT      1
#  define CONVERT_LECAN_UINT     1
#  define CONVERT_LECAN_INT64    1
#  define CONVERT_LECAN_UINT64   1
#  define CONVERT_LECAN_FLOAT    1
#  define CONVERT_LECAN_DOUBLE   1
//#//#  define CONVERT_LECAN_LDOUBLE  1
#else

// Conversion is not needed for IEEE data.
// Change the definitions below if new architectures are being used.
#  define CONVERT_LECAN_SHORT    0
#  define CONVERT_LECAN_USHORT   0
#  define CONVERT_LECAN_INT      0
#  define CONVERT_LECAN_UINT     0
#  define CONVERT_LECAN_INT64    0
#  define CONVERT_LECAN_UINT64   0
#  define CONVERT_LECAN_FLOAT    0
#  define CONVERT_LECAN_DOUBLE   0
// LDOUBLE is 8 bytes on SUN, but 16 bytes canonical.
//#//#  define CONVERT_LECAN_LDOUBLE  1
#endif



// <summary>
// A class with static functions to convert little endian canonical format
// </summary>

// <use visibility=export>

// <reviewed reviewer="Friso Olnon" date="1996/11/06" tests="tLECanonicalConversion" demos="">
// </reviewed>

// <synopsis>
// This class consists of several static functions to convert
// data from local (=native) format to a little endian canonical format.
// The canonical length of each data type is:
// <br>- Bool: 1 bit
// <br>- char: 1 byte
// <br>- short: 2 bytes
// <br>- int: 4 bytes
// <br>- Int64: 8 bytes
// <br>- float: 4 bytes
// <br>- double: 8 bytes
// <br> This canonical format is little-endian IEEE format, so on PCs
// the conversion is only a copy operation. On e.g. SUNs
// however, it involves a byte swap to convert from little
// endian to big endian.
// <p>
// The class also contains conversion functions making it possible to
// specify the number of bytes (in local format) instead of the number
// of values. These functions are included to make it possible to have
// the same signature as memcpy.
// <p>
// The current implementation of this class works on big- and little-endian
// machines using IEEE format. When using on other machines (e.g. VAX)
// the toLocal and fromLocal functions have to be changed.
// <p>
// Note that no functions are provided to handle Bools. Instead class
// <linkto class=Conversion>Conversion</linkto> provides functions to
// convert Bools to/from bits.
// </synopsis>

// <example>
// <srcblock>
// void someFunction (const uInt* data, uInt nrval)
// {
//     char* buffer = new char[nrval*LECanonicalConversion::canonicalSize(data)];
//     LECanonicalConversion::fromLocal (buffer, data, nrval);
//     ....
//     delete [] buffer;
// }
// </srcblock>
// </example>

// <motivation>
// Casacore data will often be stored in a canonical format.
// To read these data conversion functions are needed.
// However, these functions do not use any other Casacore classes,
// so they can easily be used in any other software system.
// </motivation>

// <todo asof="$DATE$">
//  <li> Support data type long double.
// </todo>


class LECanonicalConversion
{
public:
    // Convert one value from canonical format to local format.
    // The from and to buffer should not overlap.
    // <group>
    static size_t toLocal (char&           to, const void* from);
    static size_t toLocal (unsigned char&  to, const void* from);
    static size_t toLocal (short&          to, const void* from);
    static size_t toLocal (unsigned short& to, const void* from);
    static size_t toLocal (int&            to, const void* from);
    static size_t toLocal (unsigned int&   to, const void* from);
    static size_t toLocal (Int64&          to, const void* from);
    static size_t toLocal (uInt64&         to, const void* from);
    static size_t toLocal (float&          to, const void* from);
    static size_t toLocal (double&         to, const void* from);
    // </group>
    
    // Convert one value from local format to canonical format.
    // The from and to buffer should not overlap.
    // <group>
    static size_t fromLocal (void* to, const char&           from);
    static size_t fromLocal (void* to, const unsigned char&  from);
    static size_t fromLocal (void* to, const short&          from);
    static size_t fromLocal (void* to, const unsigned short& from);
    static size_t fromLocal (void* to, const int&            from);
    static size_t fromLocal (void* to, const unsigned int&   from);
    static size_t fromLocal (void* to, const Int64&          from);
    static size_t fromLocal (void* to, const uInt64&         from);
    static size_t fromLocal (void* to, const float&          from);
    static size_t fromLocal (void* to, const double&         from);
    // </group>
    
    // Convert nr values from canonical format to local format.
    // The from and to buffer should not overlap.
    // <group>
    static size_t toLocal (char*           to, const void* from,
                           size_t nr);
    static size_t toLocal (unsigned char*  to, const void* from,
                           size_t nr);
    static size_t toLocal (short*          to, const void* from,
                           size_t nr);
    static size_t toLocal (unsigned short* to, const void* from,
                           size_t nr);
    static size_t toLocal (int*            to, const void* from,
                           size_t nr);
    static size_t toLocal (unsigned int*   to, const void* from,
                           size_t nr);
    static size_t toLocal (Int64*          to, const void* from,
                           size_t nr);
    static size_t toLocal (uInt64*         to, const void* from,
                           size_t nr);
    static size_t toLocal (float*          to, const void* from,
                           size_t nr);
    static size_t toLocal (double*         to, const void* from,
                           size_t nr);
    // </group>

    // Convert nr values from local format to canonical format.
    // The from and to buffer should not overlap.
    // <group>
    static size_t fromLocal (void* to, const char*           from,
                             size_t nr);
    static size_t fromLocal (void* to, const unsigned char*  from,
                             size_t nr);
    static size_t fromLocal (void* to, const short*          from,
                             size_t nr);
    static size_t fromLocal (void* to, const unsigned short* from,
                             size_t nr);
    static size_t fromLocal (void* to, const int*            from,
                             size_t nr);
    static size_t fromLocal (void* to, const unsigned int*   from,
                             size_t nr);
    static size_t fromLocal (void* to, const Int64*          from,
                             size_t nr);
    static size_t fromLocal (void* to, const uInt64*         from,
                             size_t nr);
    static size_t fromLocal (void* to, const float*          from,
                             size_t nr);
    static size_t fromLocal (void* to, const double*         from,
                             size_t nr);
    // </group>

    // Convert nr values from canonical format to local format.
    // The from and to buffer should not overlap.
    // <group>
    static size_t toLocalChar     (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalUChar    (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalShort    (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalUShort   (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalInt      (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalUInt     (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalInt64    (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalUInt64   (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalFloat    (void* to, const void* from,
                                   size_t nr);
    static size_t toLocalDouble   (void* to, const void* from,
                                   size_t nr);
    // </group>

    // Convert nr values from local format to canonical format.
    // The from and to buffer should not overlap.
    // <group>
    static size_t fromLocalChar     (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalUChar    (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalShort    (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalUShort   (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalInt      (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalUInt     (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalInt64    (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalUInt64   (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalFloat    (void* to, const void* from,
                                     size_t nr);
    static size_t fromLocalDouble   (void* to, const void* from,
                                     size_t nr);
    // </group>
    
    // Convert values from canonical format to local format.
    // The from and to buffer should not overlap.
    // The number of values involved is determined from the argument
    // <src>nrbytes</src>, which gives the number of bytes in local format.
    // The signature of this function is the same as <src>memcpy</src>, so
    // that memcpy can directly be used if no conversion is needed.
    // <group>
    static void* byteToLocalChar     (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalUChar    (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalShort    (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalUShort   (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalInt      (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalUInt     (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalInt64    (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalUInt64   (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalFloat    (void* to, const void* from,
				      size_t nrbytes);
    static void* byteToLocalDouble   (void* to, const void* from,
				      size_t nrbytes);
    // </group>
    
    // Convert values from local format to canonical format.
    // The from and to buffer should not overlap.
    // The number of values involved is determined from the argument
    // <src>nrbytes</src>, which gives the number of bytes in local format.
    // The signature of this function is the same as <src>memcpy</src>, so
    // that memcpy can directly be used if no conversion is needed.
    // <group>
    static void* byteFromLocalChar     (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalUChar    (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalShort    (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalUShort   (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalInt      (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalUInt     (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalInt64    (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalUInt64   (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalFloat    (void* to, const void* from,
					size_t nrbytes);
    static void* byteFromLocalDouble   (void* to, const void* from,
					size_t nrbytes);
    // </group>
    
    // Get the value conversion function for the given type.
    // <group>
    static Conversion::ValueFunction* getToLocal (const char*);
    static Conversion::ValueFunction* getToLocal (const unsigned char*);
    static Conversion::ValueFunction* getToLocal (const short*);
    static Conversion::ValueFunction* getToLocal (const unsigned short*);
    static Conversion::ValueFunction* getToLocal (const int*);
    static Conversion::ValueFunction* getToLocal (const unsigned int*);
    static Conversion::ValueFunction* getToLocal (const Int64*);
    static Conversion::ValueFunction* getToLocal (const uInt64*);
    static Conversion::ValueFunction* getToLocal (const float*);
    static Conversion::ValueFunction* getToLocal (const double*);
    static Conversion::ValueFunction* getFromLocal (const char*);
    static Conversion::ValueFunction* getFromLocal (const unsigned char*);
    static Conversion::ValueFunction* getFromLocal (const short*);
    static Conversion::ValueFunction* getFromLocal (const unsigned short*);
    static Conversion::ValueFunction* getFromLocal (const int*);
    static Conversion::ValueFunction* getFromLocal (const unsigned int*);
    static Conversion::ValueFunction* getFromLocal (const Int64*);
    static Conversion::ValueFunction* getFromLocal (const uInt64*);
    static Conversion::ValueFunction* getFromLocal (const float*);
    static Conversion::ValueFunction* getFromLocal (const double*);
    // </group>

    // Get the byte conversion function for the given type.
    // The function <src>memcpy</src> is returned when a conversion
    // is not needed.
    // <group>
    static Conversion::ByteFunction* getByteToLocal (const char*);
    static Conversion::ByteFunction* getByteToLocal (const unsigned char*);
    static Conversion::ByteFunction* getByteToLocal (const short*);
    static Conversion::ByteFunction* getByteToLocal (const unsigned short*);
    static Conversion::ByteFunction* getByteToLocal (const int*);
    static Conversion::ByteFunction* getByteToLocal (const unsigned int*);
    static Conversion::ByteFunction* getByteToLocal (const Int64*);
    static Conversion::ByteFunction* getByteToLocal (const uInt64*);
    static Conversion::ByteFunction* getByteToLocal (const float*);
    static Conversion::ByteFunction* getByteToLocal (const double*);
    static Conversion::ByteFunction* getByteFromLocal (const char*);
    static Conversion::ByteFunction* getByteFromLocal (const unsigned char*);
    static Conversion::ByteFunction* getByteFromLocal (const short*);
    static Conversion::ByteFunction* getByteFromLocal (const unsigned short*);
    static Conversion::ByteFunction* getByteFromLocal (const int*);
    static Conversion::ByteFunction* getByteFromLocal (const unsigned int*);
    static Conversion::ByteFunction* getByteFromLocal (const Int64*);
    static Conversion::ByteFunction* getByteFromLocal (const uInt64*);
    static Conversion::ByteFunction* getByteFromLocal (const float*);
    static Conversion::ByteFunction* getByteFromLocal (const double*);
    // </group>

    // Return the canonical length for the various data types.
    // <group>
    static unsigned int canonicalSize (const char*);
    static unsigned int canonicalSize (const unsigned char*);
    static unsigned int canonicalSize (const short*);
    static unsigned int canonicalSize (const unsigned short*);
    static unsigned int canonicalSize (const int*);
    static unsigned int canonicalSize (const unsigned int*);
    static unsigned int canonicalSize (const Int64*);
    static unsigned int canonicalSize (const uInt64*);
    static unsigned int canonicalSize (const float*);
    static unsigned int canonicalSize (const double*);
    //#//static unsigned int canonicalSize (const long double*);
    // </group>

    // Reverse 2 bytes.
    static void reverse2 (void* to, const void* from);

    // Reverse 4 bytes.
    static void reverse4 (void* to, const void* from);

    // Reverse 8 bytes.
    static void reverse8 (void* to, const void* from);

    // Move 2 bytes.
    static void move2 (void* to, const void* from);

    // Move 4 bytes.
    static void move4 (void* to, const void* from);

    // Move 8 bytes.
    static void move8 (void* to, const void* from);

private:
    // This class should not be constructed
    // (so declare the constructor private).
    LECanonicalConversion();
};


inline void LECanonicalConversion::reverse2 (void* to, const void* from)
{
    unsigned short x, xsw;
    memcpy(&x, from, 2);
    xsw = ((x & 0xffu) << 8u) | (x >> 8u);
    memcpy(to, &xsw, 2);
}

inline void LECanonicalConversion::reverse4 (void* to, const void* from)
{
    unsigned int x, xsw;
    memcpy(&x, from, 4);
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
    xsw = __builtin_bswap32(x);
#else
    xsw = ((x & 0xffu) << 24u) | ((x & 0xff00u) << 8u) |
          ((x & 0xff0000u) >> 8u) | (x >> 24u);
#endif
    memcpy(to, &xsw, 4);
}

inline void LECanonicalConversion::reverse8 (void* to, const void* from)
{
    uInt64 x, xsw;
    memcpy(&x, from, 8);
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
    xsw = __builtin_bswap64(x);
#else
    xsw = ((x & 0xffULL) << 56ULL) |
          ((x & 0xff00ULL) << 40ULL) |
          ((x & 0xff0000ULL) << 24ULL) |
          ((x & 0xff000000ULL) << 8ULL) |
          ((x & 0xff00000000ULL) >> 8ULL) |
          ((x & 0xff0000000000ULL) >> 24ULL) |
          ((x & 0xff000000000000ULL) >> 40ULL) |
          ( x >> 56ULL);
#endif
    memcpy(to, &xsw, 8);
}

inline void LECanonicalConversion::move2 (void* to, const void* from)
{
    memcpy(to, from, 2);
}

inline void LECanonicalConversion::move4 (void* to, const void* from)
{
    memcpy(to, from, 4);
}

inline void LECanonicalConversion::move8 (void* to, const void* from)
{
    /* memcpy is overlap save if size fits into a register */
    if (sizeof(to) < 8) {
        memmove(to, from, 8);
    }
    else {
        memcpy(to, from, 8);
    }
}



inline size_t LECanonicalConversion::toLocal (char& to,
                                              const void* from)
{
    to = *(char*)from;
    return SIZE_LECAN_CHAR;
}

inline size_t LECanonicalConversion::toLocal (unsigned char& to,
                                              const void* from)
{
    to = *(unsigned char*)from;
    return SIZE_LECAN_UCHAR;
}

inline size_t LECanonicalConversion::toLocal (short& to,
                                              const void* from)
{
    if (sizeof(short) != 2) {
	if (((signed char*)from)[0] < 0) {
	    to = -1;
	}else{
	    to = 0;
	}
    }
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse2 (&to, from);
#else
    move2 (((char*)&to)+sizeof(short)-2, from);
#endif
    return SIZE_LECAN_SHORT;
}

inline size_t LECanonicalConversion::toLocal (unsigned short& to,
                                              const void* from)
{
    if (sizeof(unsigned short) != 2) {
	to = 0;
    }
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse2 (&to, from);
#else
    move2 (((char*)&to)+sizeof(unsigned short)-2, from);
#endif
    return SIZE_LECAN_USHORT;
}

inline size_t LECanonicalConversion::toLocal (int& to,
                                              const void* from)
{
    if (sizeof(int) != 4) {
	if (((signed char*)from)[0] < 0) {
	    to = -1;
	}else{
	    to = 0;
	}
    }
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse4 (&to, from);
#else
    move4 (((char*)&to)+sizeof(int)-4, from);
#endif
    return SIZE_LECAN_INT;
}

inline size_t LECanonicalConversion::toLocal (unsigned int& to,
                                              const void* from)
{
    if (sizeof(unsigned int) != 4) {
	to = 0;
    }
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse4 (&to, from);
#else
    move4 (((char*)&to)+sizeof(unsigned int)-4, from);
#endif
    return SIZE_LECAN_UINT;
}

inline size_t LECanonicalConversion::toLocal (Int64& to,
                                              const void* from)
{
    if (sizeof(Int64) != 8) {
	if (((signed char*)from)[0] < 0) {
	    to = -1;
	}else{
	    to = 0;
	}
    }
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse8 (&to, from);
#else
    move8 (((char*)&to)+sizeof(Int64)-8, from);
#endif
    return SIZE_LECAN_INT64;
}

inline size_t LECanonicalConversion::toLocal (uInt64& to,
                                              const void* from)
{
    if (sizeof(uInt64) != 8) {
	to = 0;
    }
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse8 (&to, from);
#else
    move8 (((char*)&to)+sizeof(uInt64)-8, from);
#endif
    return SIZE_LECAN_UINT64;
}

inline size_t LECanonicalConversion::toLocal (float& to,
                                              const void* from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse4 (((char*)&to)+sizeof(float)-4, from);
#else
    move4 (&to, from);
#endif
    return SIZE_LECAN_FLOAT;
}

inline size_t LECanonicalConversion::toLocal (double& to,
                                              const void* from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse8 (((char*)&to)+sizeof(double)-8, from);
#else
    move8 (&to, from);
#endif
    return SIZE_LECAN_DOUBLE;
}


inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const char& from)
{
    *(char*)to = from;
    return SIZE_LECAN_CHAR;
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const unsigned char& from)
{
    *(unsigned char*)to = from;
    return SIZE_LECAN_UCHAR;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const short& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse2 (to, &from);
#else
    move2 (to, ((char*)&from)+sizeof(short)-2);
#endif
    return SIZE_LECAN_SHORT;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const unsigned short& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse2 (to, &from);
#else
    move2 (to, ((char*)&from)+sizeof(unsigned short)-2);
#endif
    return SIZE_LECAN_USHORT;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const int& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse4 (to, &from);
#else
    move4 (to, ((char*)&from)+sizeof(int)-4);
#endif
    return SIZE_LECAN_INT;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const unsigned int& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse4 (to, &from);
#else
    move4 (to, ((char*)&from)+sizeof(unsigned int)-4);
#endif
    return SIZE_LECAN_UINT;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const Int64& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse8 (to, &from);
#else
    move8 (to, ((char*)&from)+sizeof(Int64)-8);
#endif
    return SIZE_LECAN_INT64;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const uInt64& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse8 (to, &from);
#else
    move8 (to, ((char*)&from)+sizeof(uInt64)-8);
#endif
    return SIZE_LECAN_UINT64;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const float& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse4 (to, &from);
#else
    move4 (to, &from);
#endif
    return SIZE_LECAN_FLOAT;
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const double& from)
{
#if !defined(AIPS_LITTLE_ENDIAN)
    reverse8 (to, &from);
#else
    move8 (to, &from);
#endif
    return SIZE_LECAN_FLOAT;
}


inline size_t LECanonicalConversion::toLocal (char*           to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalChar (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (unsigned char*  to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalUChar (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (short*          to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalShort (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (unsigned short* to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalUShort (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (int*            to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalInt (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (unsigned int*   to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalUInt (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (Int64*          to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalInt64 (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (uInt64*         to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalUInt64 (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (float*          to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalFloat (to, from, nr);
}
inline size_t LECanonicalConversion::toLocal (double*         to,
                                              const void* from,
                                              size_t nr)
{
    return toLocalDouble (to, from, nr);
}

inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const char*           from,
                                                size_t nr)
{
    return fromLocalChar (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const unsigned char*  from,
                                                size_t nr)
{
    return fromLocalUChar (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const short*          from,
                                                size_t nr)
{
    return fromLocalShort (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const unsigned short* from,
                                                size_t nr)
{
    return fromLocalUShort (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const int*            from,
                                                size_t nr)
{
    return fromLocalInt (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const unsigned int*   from,
                                                size_t nr)
{
    return fromLocalUInt (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const Int64*          from,
                                                size_t nr)
{
    return fromLocalInt64 (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const uInt64*         from,
                                                size_t nr)
{
    return fromLocalUInt64 (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const float*          from,
                                                size_t nr)
{
    return fromLocalFloat (to, from, nr);
}
inline size_t LECanonicalConversion::fromLocal (void* to,
                                                const double*         from,
                                                size_t nr)
{
    return fromLocalDouble (to, from, nr);
}


inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const char*)
{
    return toLocalChar;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const unsigned char*)
{
    return toLocalUChar;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const short*)
{
    return toLocalShort;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const unsigned short*)
{
    return toLocalUShort;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const int*)
{
    return toLocalInt;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const unsigned int*)
{
    return toLocalUInt;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const Int64*)
{
    return toLocalInt64;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const uInt64*)
{
    return toLocalUInt64;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const float*)
{
    return toLocalFloat;
}
inline Conversion::ValueFunction* LECanonicalConversion::getToLocal
                                                      (const double*)
{
    return toLocalDouble;
}

inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const char*)
{
    return fromLocalChar;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const unsigned char*)
{
    return fromLocalUChar;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const short*)
{
    return fromLocalShort;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const unsigned short*)
{
    return fromLocalUShort;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const int*)
{
    return fromLocalInt;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const unsigned int*)
{
    return fromLocalUInt;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const Int64*)
{
    return fromLocalInt64;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const uInt64*)
{
    return fromLocalUInt64;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const float*)
{
    return fromLocalFloat;
}
inline Conversion::ValueFunction* LECanonicalConversion::getFromLocal
                                                      (const double*)
{
    return fromLocalDouble;
}


inline unsigned int LECanonicalConversion::canonicalSize (const char*)
    {return SIZE_LECAN_CHAR;}
inline unsigned int LECanonicalConversion::canonicalSize (const unsigned char*)
    {return SIZE_LECAN_UCHAR;} 
inline unsigned int LECanonicalConversion::canonicalSize (const short*)
    {return SIZE_LECAN_SHORT;}
inline unsigned int LECanonicalConversion::canonicalSize (const unsigned short*)
    {return SIZE_LECAN_USHORT;}
inline unsigned int LECanonicalConversion::canonicalSize (const int*)
    {return SIZE_LECAN_INT;}
inline unsigned int LECanonicalConversion::canonicalSize (const unsigned int*)
    {return SIZE_LECAN_UINT;}
inline unsigned int LECanonicalConversion::canonicalSize (const Int64*)
    {return SIZE_LECAN_INT64;}
inline unsigned int LECanonicalConversion::canonicalSize (const uInt64*)
    {return SIZE_LECAN_UINT64;}
inline unsigned int LECanonicalConversion::canonicalSize (const float*)
    {return SIZE_LECAN_FLOAT;}
inline unsigned int LECanonicalConversion::canonicalSize (const double*)
    {return SIZE_LECAN_DOUBLE;}
//#//inline unsigned int LECanonicalConversion::canonicalSize (const long double*)
//#//    {return SIZE_LECAN_LDOUBLE;}




} //# NAMESPACE CASACORE - END

#endif