File: Column.h

package info (click to toggle)
ccfits 2.4%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,436 kB
  • ctags: 1,132
  • sloc: cpp: 14,287; sh: 8,322; makefile: 91
file content (1513 lines) | stat: -rw-r--r-- 47,244 bytes parent folder | download | duplicates (2)
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
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
//	Astrophysics Science Division,
//	NASA/ Goddard Space Flight Center
//	HEASARC
//	http://heasarc.gsfc.nasa.gov
//	e-mail: ccfits@legacy.gsfc.nasa.gov
//
//	Original author: Ben Dorman

#ifndef COLUMN_H
#define COLUMN_H 1
#include <iostream>

// CCfitsHeader
#include "CCfits.h"
// Table
#include "Table.h"
// FitsError
#include "FitsError.h"
// FITSUtil
#include "FITSUtil.h"

#include <complex>


namespace CCfits {



/*! \class Column

    \brief Abstract base class for Column objects. 

   Columns are the data containers used in FITS tables. Columns of scalar type
   (one entry per cell) are implemented by the template subclass ColumnData<T>.
   Columns of vector type (vector and variable rows) are implemented with the 
   template subclass ColumnVectorData<T>. AsciiTables may only contain Columns
   of type ColumnData<T>,  where T is an implemented FITS data type (see the
   CCfits.h header for a complete list. This requirement is enforced by ensuring
   that AsciiTable's addColumn method may only create an AsciiTable compatible
   column. The ColumnData<T> class stores its data in a std::vector<T> object.


   BinTables may contain either ColumnData<T> or ColumnVectorData<T>. 
   For ColumnVectorData, T must be a numeric type: string vectors are 
   handled by ColumnData<T>; string arrays are not supported. The internal
   representation of the data is a std::vector<std::valarray<T> > object.
   The std::valarray class is designed for efficient numeric processing and
   has many vectorized numeric and transcendental functions defined on it.

   Member template functions for read/write operations are provided in multiple
   overloads as the interface to data operations. Implicit data type conversions
   are supported but where they are required make the operations less efficient.
   Reading numeric column data as character arrays, supported by cfitsio, is
   not supported by CCfits.

   As a base class, Column provides protected accessor/mutator inline functions to 
   allow only its subclasses to access data members.

*/

/*! \class Column::RangeError
    @ingroup FITSexcept
    @brief exception to be thrown for inputs that cause range errors in column read operations.

    Range errors here mean  (last < first) in a request to read a range of rows.
*/



/*! \fn Column::RangeError::RangeError (const String& msg, bool silent);

        \brief Exception ctor, prefixes the string "FitsError: Range error in operation " before the specific message.

        \param msg A specific diagnostic message
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/ 

/*! \class Column::InvalidDataType

        @ingroup FITSExcept
        @brief Exception thrown for invalid data type inputs

        This exception is thrown if the user requests an implicit data type conversion
        to a datatype that is not one of the supported types (see fitsio.h for details).
*/




/*! \fn Column::InvalidDataType::InvalidDataType (const String& str, bool silent);

        \brief Exception ctor, prefixes the string "FitsError: Incorrect data type:  " before the specific message.

        \param str A specific diagnostic message
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/        


/*! \class Column::InvalidRowParameter

        @ingroup FITSExcept
        @brief Exception thrown on incorrect row writing request

        This exception is thrown if the user requests writing more data than a 
        fixed width row can accommodate. An exception is thrown rather than
        a truncation because it is likely that the user will not otherwise
        realize that data loss is happening.
*/


/*! \fn Column::InvalidRowParameter::InvalidRowParameter (const String& diag, bool silent);

        \brief Exception ctor, prefixes the string "FitsError: row offset or length incompatible with column declaration  " before the specific message.

        \param diag A specific diagnostic message, usually the column name
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/        


/*! \class Column::WrongColumnType

        @ingroup FITSExcept
        @brief Exception thrown on attempting to access a scalar column as vector data.

        This exception will be thrown if the user tries to call a read/write operation
        with a signature appropriate for a vector column on a scalar column, or vice versa.
        For example in the case of write operations, 
        the vector versions require the specification of (a) a number of rows to write
        over, (b) a vector of lengths to write to each row or (c) a subset specification.
        The scalar versions only require a number of rows if the input array is a plain
        C-array, otherwise the range to be written is the size of the input vector.



*/

/*! \fn  Column::WrongColumnType::WrongColumnType (const String& diag, bool silent);

        \brief Exception ctor, prefixes the string "FitsError: Attempt to return scalar data from vector column, or vice versa - Column: " before the specific message.

        \param diag A specific diagnostic message, usually the column name.
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/        


/*! \class Column::InvalidRowNumber

        @ingroup FITSExcept
        @brief Exception thrown on attempting to read a row number beyond the end of a table.

*/

/*! \fn Column::InvalidRowNumber::InvalidRowNumber (const String& diag, bool silent);

        \brief Exception ctor, prefixes the string "FitsError: Invalid Row Number - Column: " before the specific message.

        \param diag A specific diagnostic message, usually the column name.
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/        



/*! \class Column::InsufficientElements

        @ingroup FITSExcept
        @brief Exception thrown if the data supplied for a write operation is less than declared.

        This circumstance generates an exception to avoid unexpected behaviour after
        the write operation is completed. It  can be avoided by resizing the input
        array appropriately.

*/

/*! \fn Column::InsufficientElements::InsufficientElements (const String& msg, bool silent);

        \brief Exception ctor, prefixes the string "FitsError: not enough elements supplied for write operation:  " before the specific message.

        \param msg A specific diagnostic message, usually the column name
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/        


/*! \class Column::NoNullValue

        @ingroup FITSExcept
        @brief Exception thrown  if a null value is specified without support from existing column header.

        This exception is analogous to the fact that cfitsio returns a non-zero status code if
        TNULLn doesn't exist an a null value (convert all input data with the null value to the TNULLn keyword) is
        specified. It is only relevant for integer type data (see cfitsio manual for details).
*/

/*! \fn Column::NoNullValue::NoNullValue (const String& diag, bool silent);

        \brief Exception ctor, prefixes the string "Fits Error: No null value specified for column: " before the specific message.

        \param diag A specific diagnostic message
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/        


/*! \class Column::InvalidNumberOfRows

        @ingroup FITSExcept
        @brief Exception thrown  if user enters a non-positive number for the number of rows to write.

*/


/*! \fn Column::InvalidNumberOfRows::InvalidNumberOfRows (size_t number, bool silent);

        \brief Exception ctor, prefixes the string "Fits Error: number of rows to write must be positive " before the specific message.

        \param number The number of rows entered.
        \param silent if true, print message whether FITS::verboseMode is set or not.

*/        

/*!  \fn Column::Column(const Column& right);

      \brief copy constructor, used in copying Columns to standard library containers.

      The copy constructor is for internal use only: it does not affect the disk
      fits file associated with the object.


*/


/*!  \fn virtual Column::~Column();

      \brief destructor.


*/

/*!   \fn  template <typename S> void Column::read(std::vector<S>& vals, long first, long last);

        \brief Retrieve data from a scalar column into a std::vector

        This and the following functions perform implicit data conversions. An
        exception will be thrown if no conversion exists.

        \param vals The output container. The function will resize this as necessary
        \param first,last the span of row numbers to read.

*/

/*!   \fn  template <typename S> void Column::read(std::vector<S>& vals, long first, long last, S* nullValue) ;

        \brief Retrieve data from a scalar column into a std::vector>, applying nullValue when relevant.

        If both <i>nullValue</i> and <i>*nullValue</i> are not 0, then any undefined 
        values in the file will be converted to <i>*nullValue</i> when copied into the
        <i>vals</i> vector.  See cfitsio documentation for further details

        \param vals The output container. The function will resize this as necessary
        \param first,last the span of row numbers to read.
        \param nullValue pointer to value to be applied to undefined elements.

*/
         /*!  \fn   template <typename S> void Column::read(std::valarray<S>& vals, long first, long last) ;

        \brief Retrieve data from a scalar column into a std::valarray

        \param vals The output container. The function will resize this as necessary
        \param first,last the span of row numbers to read.


*/    

/*!  \fn   template <typename S> void Column::read(std::valarray<S>& vals, long first, long last, S* nullValue) ;

        \brief Retrieve data from a scalar column into a std::valarray, applying nullValue when relevant.

        If both <i>nullValue</i> and <i>*nullValue</i> are not 0, then any undefined 
        values in the file will be converted to <i>*nullValue</i> when copied into the
        <i>vals</i> valarray.  See cfitsio documentation for further details

        \param vals The output container. The function will resize this as necessary
        \param first,last the span of row numbers to read.
        \param nullValue pointer to value to be applied to undefined elements.

*/

/*!  \fn template <typename S> void Column::read(std::valarray<S>& vals, long rows) ;

        \brief return a single row of a vector column into a std::valarray

        \param vals The output valarray object
        \param rows The row number to be retrieved (starting at 1).
*/

/*!  \fn  template <typename S> void Column::read(std::valarray<S>& vals, long rows, S* nullValue) ;

        \brief return a single row of a vector column into a std::valarray, setting undefined values

*/

/*!  \fn    template <typename S> void Column::readArrays(std::vector<std::valarray<S> >& vals, long first,long last);

        \brief return a set of rows of a vector column into a vector of valarrays

        \param vals The output container. The function will resize this as necessary
        \param first,last the span of row numbers to read.
*/

/*!  \fn  template <typename S>  void Column::readArrays(std::vector<std::valarray<S> >& vals, long first, long last, S* nullValue);
        \brief return a set of rows of a vector column into a container, setting undefined values

        \param vals The output container. The function will resize this as necessary
        \param first,last the span of row numbers to read.
        \param nullValue pointer to integer value regarded as undefined

*/  


/*!   \fn  template <typename S> void Column::write(const std::vector<S>& indata, long firstRow);

      \brief write a vector of values into a scalar column starting with firstRow

      \param indata   The data to be written.
      \param firstRow The first row to be written
*/  

/*!   \fn  template <typename S> void Column::write(const std::valarray<S>& indata, long firstRow);

      \brief write a valarray of values into a scalar column starting with firstRow

      \param indata   The data to be written.
      \param firstRow The first row to be written
*/   

 /*!   \fn  template <typename S> void Column::write(const std::vector<S>& indata, long firstRow,  S* nullValue);

      \brief write a vector of values into a scalar column starting with firstRow, replacing elements equal to 
             *nullValue with the FITS null value.

      If <i>nullValue</i> is not 0, the appropriate FITS null value will be
      substituted for all elements of <i>indata</i> equal to <i>*nullValue</i>.
      For integer type columns there must be a pre-existing TNULLn keyword to
      define the FITS null value, otherwise a FitsError exception is thrown.
      For floating point columns, the FITS null is the IEEE NaN (Not-a-Number) value.
      See the cfitsio fits_write_colnull function documentation for more details.

      \param indata   The data to be written.
      \param firstRow The first row to be written
      \param nullValue Pointer to the value for which equivalent <i>indata</i> elements
                       will be replaced in the file with the appropriate FITS null value.
*/




 /*!   \fn  template <typename S> void Column::write(const std::valarray<S>& indata, long firstRow,  S* nullValue);

      \brief write a valarray of values into a scalar column starting with firstRow, replacing elements equal to
             *nullValue with the FITS null value.

      If <i>nullValue</i> is not 0, the appropriate FITS null value will be
      substituted for all elements of <i>indata</i> equal to <i>*nullValue</i>.
      For integer type columns there must be a pre-existing TNULLn keyword to
      define the FITS null value, otherwise a FitsError exception is thrown.
      For floating point columns, the FITS null is the IEEE NaN (Not-a-Number) value.
      See the cfitsio fits_write_colnull function documentation for more details.

      \param indata   The data to be written.
      \param firstRow The first row to be written
      \param nullValue Pointer to the value for which equivalent <i>indata</i> elements
                       will be replaced in the file with the appropriate FITS null value.
*/





/*!   \fn  template <typename S> void Column::write(S* indata, long nRows, long firstRow);

      \brief write a C array of size nRows into a scalar Column starting with row firstRow.

      \param indata   The data to be written.
      \param nRows    The size of the data array to be written
      \param firstRow The first row to be written


*/



/*!   \fn  template <typename S> void Column::write(S* indata, long nRows, long firstRow,  S* nullValue);

      \brief write a C array into a scalar Column, processing undefined values.

      \param indata   The data to be written.
      \param nRows    The size of the data array to be written
      \param firstRow The first row to be written
      \param nullValue Pointer to the value in the input array to be set to undefined values


*/

/*!   \fn   template <typename S>  void Column::write (const std::valarray<S>& indata, long nRows, long firstRow);

        \brief write a valarray of values into a range of rows of a vector column.

        The primary use of this is for fixed width columns, in which case Column's repeat attribute is 
        used to determine how many elements are written to each row; if indata.size() is too small an 
        exception will be thrown. If the column is variable width, the call will write indata.size()/nRows 
        elements to each row.

      \param indata   The data to be written.
      \param nRows    the number of rows to which to write the data.
      \param firstRow The first row to be written

*/


/*!   \fn   template <typename S>  void Column::write (const std::valarray<S>& indata, long nRows, long firstRow, S* nullValue);

        \brief write a valarray of values into a range of rows of a vector column.

        see version without undefined processing for details.

*/


/*!   \fn   template <typename S>  void Column::write (const std::vector<S>& indata, long nRows, long firstRow);

        \brief write a vector of values into a range of rows of a vector column

        The primary use of this is for fixed width columns, in which case Column's repeat attribute is 
        used to determine how many elements are written to each row; if indata.size() is too small an 
        exception will be thrown. If the column is variable width, the call will write indata.size()/nRows 
        elements to each row.

      \param indata   The data to be written.
      \param nRows    the number of rows to which to write the data.
      \param firstRow The first row to be written



*/

/*!   \fn   template <typename S>  void Column<S>::write (const std::vector<S>& indata, long nRows, long firstRow, S* nullValue);

        \brief write a vector of values into a range of rows of a vector column, processing undefined values 

         see version without undefined processing for details.

*/

/*!   \fn   template <typename S>  void Column::write (S* indata, long nElements, long nRows, long firstRow);

        \brief write a C array of values into a range of rows of a vector column

        Details are as for vector input; only difference is the need to supply the size of the C-array. 

      \param indata    The data to be written.
      \param nElements The size of indata
      \param nRows     the number of rows to which to write the data.
      \param firstRow  The first row to be written

*/

/*!   \fn   template <typename S> void Column::write (S* indata, long nElements, long nRows, long firstRow, S* nullValue);

        \brief write a C array of values into a range of rows of a vector column, processing undefined values.

         see version without undefined processing for details.

*/        

/*!   \fn   template <typename S>   void Column::write (const std::valarray<S>& indata,  
                        const std::vector<long>& vectorLengths, 
                        long firstRow);        

        \brief write a valarray of values into a column with specified number of entries written per row.

        Data are written into vectorLengths.size() rows, with vectorLength[n] elements written to
        row n+firstRow -1. Although primarily intended for wrapping calls to multiple variable-width
        vector column rows, it may also be used to write a variable number of elements to fixed-width
        column rows. 

        When writing to fixed-width column rows, if the number of elements sent to a particular row
        are fewer than the column's repeat value, the remaining elements in the row will not be modified.

        Since cfitsio does not support null value processing for variable width columns
        this function and its variants do not have version which process undefined values

        \param indata The data to be written
        \param vectorLengths the number of elements to write to each successive row.
        \param firstRow the first row to be written.        

*/

/*!   \fn   template <typename S> void Column::write (const std::vector<S>& indata, 
                        const std::vector<long>& vectorLengths, 
                        long firstRow);

        \brief write a vector of values into a column with specified number of entries written per row.

        Intended for writing a varying number of elements to multiple rows in a vector column, this
        may be used for either variable or fixed-width columns.  See the indata valarray version 
        of this function for a complete description.

*/

/*!   \fn   template <typename S>  void Column::write (S* indata, long nElements,  
                        const std::vector<long>& vectorLengths, 
                        long firstRow);

        \brief write a C-array of values of size nElements into a vector column with specified number of entries written per row.

        Intended for writing a varying number of elements to multiple rows in a vector column, this
        may be used for either variable or fixed-width columns.  See the indata valarray version 
        of this function for a complete description.

*/

/*!   \fn   template <typename S> void Column::writeArrays (const std::vector<std::valarray<S> >& indata, long firstRow); 

        \brief write a vector of valarray objects to the column, starting at row firstRow >= 1

        Intended for writing a varying number of elements to multiple rows in a vector column, this
        may be used for either variable or fixed-width columns.  When writing to fixed-width column rows, 
        if the number of elements sent to a particular row are fewer than the column's repeat value, the 
        remaining elements in the row will not be modified.

        \param indata The data to be written
        \param firstRow the first row to be written.        

*/

/*!   \fn   template <typename S>  void Column::writeArrays (const std::vector<std::valarray<S> >& indata, long firstRow, S* nullValue);  

        \brief write a vector of valarray objects to the column, starting at row firstRow >= 1, processing undefined values

         see version without undefined processing for details.

*/              


/*! \fn   template <typename T>   void Column::addNullValue(T nullVal);

          \brief Set the TNULLn keyword for the column

          Only relevant for integer valued columns, TNULLn is the value
          used by cfitsio in undefined processing. All entries in the
          table equal to an input "null value" are set equal to the value
          of TNULLn. (For floating point columns a system NaN value is used). 


*/

/*!  \fn  template <typename T>  bool Column::getNullValue(T* nullVal) const;

           \brief Get the value of the TNULLn keyword for the column

           Only relevant for integer valued columns.  If the TNULLn keyword
           is present, its value will be written to <i>*nullVal</i> and the
           function returns <i>true</i>.  If the keyword is not found or 
           its value is undefined, the function returns <i>false</i> and 
           <i>*nullVal</i> is not modified.

           \param nullVal  A pointer to the variable for storing the TNULLn value.
*/

/*!        \fn virtual void Column::readData (long firstRow = 1,  long nelements = 1, long firstElem = 1) = 0;

      \brief Read (or reread) data from the disk into the Column object's internal arrays.

      This function normally does not need to be called.  See the <b>resetRead</b>
      function for an alternative way of performing a reread from disk.  
      \param firstRow The first row to be read
      \param nelements The number of elements to read
      \param firstElem The number of the element on the first row to start at 
              (ignored for scalar columns)


*/



/*!        \fn void Column::setDisplay ();

      \brief set the TDISPn keyword


*/

/*!        \fn void Column::rows() const;

      \brief return the number of rows in the table.

*/


/*!   \fn virtual void Column::setDimen ();

      \brief set the TDIMn keyword.


*/

/*!   \fn std::ostream& operator <<(std::ostream& s, const Column& right);

      \brief output operator for Column objects. 
*/


/*!        \fn int Column::index () const;

      \brief get the Column index (the n in TTYPEn etc).



*/


/*!         \fn size_t Column::repeat () const;

      \brief get the repeat count for the rows



*/

/*!         \fn const bool Column::varLength () const;

      \brief boolean, set to true if Column has variable length vector rows.



*/


/*!        \fn const double Column::scale () const;

      \brief get TSCALn value

      TSCALn is  used to convert a data array represented
      on disk in integer format as floating. Useful for compact storage of digitized
      data.


*/


/*!        \fn const double Column::zero () const;

      \brief get TZEROn value

      TZEROn is an integer offset used in the implementation of unsigned data



*/



/*!        \fn const String& Column::name () const;

      \brief  return  name of Column (TTYPEn keyword)



*/


/*!        \fn const String& Column::unit () const;

      \brief get units of data in Column (TUNITn keyword)
*/


/*!        \fn Column::Column (int columnIndex, const String &columnName,const ValueType type, 
                const String &format,
                const String &unit,
                Table* p,
                int  rpt = 1, 
                long w = 1, 
                const String &comment = "");

      \brief new column creation constructor

      This constructor allows the specification of:

      \param columnIndex The column number
      \param columnName The column name, keyword TTYPEn
      \param type     used for determining class of T in  ColumnData<T>, ColumnVectorData<T>
      \param format   the column data format, TFORMn keyword
      \param unit   the column data unit, TUNITn keyword
      \param p      the Table pointer
      \param rpt    (optional) repeat count for the row ( == 1 for AsciiTables)
      \param w      the row width
      \param comment comment to be added to the header.

*/

/*!        \fn Column::Column (Table* p = 0);

      \brief Simple constructor to be called by subclass reading ctors.

*/



/*!        \fn fitsfile* Column::fitsPointer ();

      \brief fits pointer corresponding to fits file containing column data.



*/

/*!        \fn void Column::makeHDUCurrent ();

      \brief make HDU containing this the current HDU of the fits file.



*/

/*!        \fn int Column::rows () const;

      \brief return number of rows in the Column




*/

/*!        \fn virtual std::ostream& Column::put (std::ostream& s) const;

      \brief internal implementation of << operator.



*/

/*!        \fn const ValueType  Column::type () const;

      \brief returns the data type of the column



*/


/*!        \fn  const bool Column::isRead () const;

      \brief flag set to true if the entire column data has been read from disk

*/

/*!    \fn void Column::resetRead();

      \brief reset the Column's isRead flag to false

      This forces the data to be reread from the disk the next time a
      read command is called on the Column, rather than simply retrieving the
      data already stored in the Column object's internal arrays.  This
      may be useful for example if trying to reread a Column using a 
      different nullValue argument than for an earlier read.
*/

/*!        \fn long Column::width () const;

      \brief return column data width



*/      


/*!        \fn String& Column::display () const;

      \brief return TDISPn keyword

      TDISPn  is suggested format for output of column data.



*/

/*!        \fn String& Column::dimen () const;

      \brief return TDIMn keyword

      represents dimensions of data arrays in vector columns.
      for scalar columns, returns a default value.



*/

/*!        \fn const String& Column::format () const;

      \brief return TFORMn keyword

      TFORMn specifies data format stored in disk file.


*/


/*!        \fn const String& Column::comment () const;

      \brief retrieve comment for Column

*/

/*!   \fn Table* Column::parent() const;
     \brief return a pointer to the Table which owns this Column

*/



  class Column 
  {

    public:



      class RangeError : public FitsException  //## Inherits: <unnamed>%3946526D031A
      {
        public:
            RangeError (const String& msg, bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class InvalidDataType : public FitsException  //## Inherits: <unnamed>%3947CF30033E
      {
        public:
            InvalidDataType (const String& str = string(), bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class InvalidRowParameter : public FitsException  //## Inherits: <unnamed>%39B5310F01A0
      {
        public:
            InvalidRowParameter (const String& diag, bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class WrongColumnType : public FitsException  //## Inherits: <unnamed>%39B545780082
      {
        public:
            WrongColumnType (const String& diag, bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class UnspecifiedLengths : public FitsException  //## Inherits: <unnamed>%3A018C9D007D
      {
        public:
            UnspecifiedLengths (const String& diag, bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class InvalidRowNumber : public FitsException  //## Inherits: <unnamed>%3B0A850F0307
      {
        public:
            InvalidRowNumber (const String& diag, bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class InsufficientElements : public FitsException  //## Inherits: <unnamed>%3B0BE611010A
      {
        public:
            InsufficientElements (const String& msg, bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class NoNullValue : public FitsException  //## Inherits: <unnamed>%3B0D589A0092
      {
        public:
            NoNullValue (const String& diag, bool silent = true);

        protected:
        private:
        private: //## implementation
      };



      class InvalidNumberOfRows : public FitsException  //## Inherits: <unnamed>%3B20EB8B0205
      {
        public:
            InvalidNumberOfRows (size_t number, bool silent = true);

        protected:
        private:
        private: //## implementation
      };
        Column(const Column &right);
        virtual ~Column();
        bool operator==(const Column &right) const;

        bool operator!=(const Column &right) const;

        virtual void readData (long firstRow, long nelements, long firstElem = 1) = 0;
        //	Virtual copy constructor.
        virtual Column * clone () const = 0;
        int rows () const;
        void setDisplay ();
        virtual void setDimen ();
        friend std::ostream& operator << (std::ostream& s, const Column& right);
        Table* parent () const;
        //	Inequality operators for imposing sort order on columns.
        friend bool operator < (const Column& left, const Column& right);
        //	Inequality operators for imposing sort order on columns.
        friend bool operator > (const Column& left, const Column& right);
        void setLimits (ValueType type);
        void unit (const String& value);
        void resetRead ();
        int index () const;
        void index (int value);
        bool isRead () const;
        void isRead (bool value);
        long width () const;
        void width (long value);
        size_t repeat () const;
        bool varLength () const;
        double scale () const;
        void scale (double value);
        double zero () const;
        void zero (double value);
        const String& display () const;
        const String& dimen () const;
        void dimen (const String& value);
        ValueType type () const;
        void type (ValueType value);
        static const String& TFORM ();
        static const String& TDISP ();
        static const String& TSCAL ();
        static const String& TZERO ();
        static const String& TDIM ();
        const String& format () const;
        const String& unit () const;
        const String& name () const;

    public:
      // Additional Public Declarations

        // scalar column interface. Column's Data Member is a std::vector<T>,
        // input data is std::vector<S>, std::valarray<S> or S* where S is not
        // in general the same as T.

        template <typename S>                   
        void write (const std::vector<S>& indata, long firstRow);

        void write (const std::vector<std::complex<float> >& indata, long firstRow);

        void write (const std::vector<std::complex<double> >& indata, long firstRow);

        template <typename S>                   
        void write (const std::valarray<S>& indata, long firstRow);

        void write (const std::valarray<std::complex<float> >& indata, long firstRow);

        void write (const std::valarray<std::complex<double> >& indata, long firstRow);

        template <typename S>                   
        void write (S* indata, long nRows, long firstRow);


        template <typename S>                   
        void write (const std::vector<S>& indata, long firstRow, S* nullValue);

        template <typename S>                   
        void write (const std::valarray<S>& indata, long firstRow, S* nullValue);

        template <typename S>                   
        void write (S* indata, long nRows, long firstRow, S* nullValue);        
        // vector column interface. We provide an interface that allows input of a vector, valarray and C-array.
	// there are versions that write variable numbers of elements per row as specified
        // in the vectorLengths argument. The user also can directly write a vector<valarray<T> >
        // object which is how the data are stored in the ColumnVectorData object. 
        // this last one is also used internally to implement the variable lengths versions.

        // fixed length write to binary table from valarray.


        template <typename S>
        void write (const std::valarray<S>& indata, long nRows, long firstRow);

        void write (const std::valarray<std::complex<float> >& indata, long nRows, long firstRow);

        void write (const std::valarray<std::complex<double> >& indata, long nRows, long firstRow);


        template <typename S>
        void write (const std::vector<S>& indata, long nRows, long firstRow);

        void write (const std::vector<std::complex<float> >& indata, long nRows, long firstRow);

        void write (const std::vector<std::complex<double> >& indata, long nRows, long firstRow);



        template <typename S>
        void write (S* indata, long nElements, long nRows, long firstRow);


        template <typename S>
        void write (const std::valarray<S>& indata, long nRows, long firstRow, S* nullValue);


        template <typename S>
        void write (const std::vector<S>& indata, long nRows, long firstRow, S* nullValue);

        template <typename S>
        void write (S* indata, long nElements, long nRows, long firstRow, S* nullValue);

        // variable-length write to vector column from valarray or vector.

        template <typename S>
        void write (const std::valarray<S>& indata,  
                        const std::vector<long>& vectorLengths, 
                        long firstRow);        

        void write (const std::valarray<std::complex<float> >& indata,  
                        const std::vector<long>& vectorLengths, 
                        long firstRow);        

        void write (const std::valarray<std::complex<double> >& indata,  
                        const std::vector<long>& vectorLengths, 
                        long firstRow);      

        template <typename S>
        void write (const std::vector<S>& indata, 
                        const std::vector<long>& vectorLengths, 
                        long firstRow);



        void write (const std::vector<std::complex<float> >& indata, 
                        const std::vector<long>& vectorLengths, 
                        long firstRow);

        void write (const std::vector<std::complex<double> >& indata, 
                        const std::vector<long>& vectorLengths, 
                        long firstRow);

        template <typename S>
        void write (S* indata, long nElements,  
                        const std::vector<long>& vectorLengths, 
                        long firstRow);

        template <typename S>
        void writeArrays (const std::vector<std::valarray<S> >& indata, long firstRow); 

        void writeArrays (const std::vector<std::valarray<std::complex<float> > >& indata, long firstRow); 

        void writeArrays (const std::vector<std::valarray<std::complex<double> > >& indata, long firstRow); 

	template <typename S>
        void writeArrays (const std::vector<std::valarray<S> >& indata, long firstRow, S* nullValue);  

        // get specified elements of a scalar column, returned as a std::vector
        // S is NOT the type of the column data itself, it is the type of the returned
        // data.

        template <typename S>
        void read(std::vector<S>& vals, long first, long last) ;

        // VC++, at least, won't compile these as template covering std::complex instances.
        void read(std::vector< std::complex<float> >& , long first, long last);

        void read(std::vector< std::complex<double> >& , long first, long last);

        void read(std::vector<String>& vals, long first, long last);

        // return a set of rows from a scalar column as a valarray.
        template <typename S>
        void read(std::valarray<S>& vals, long first, long last) ;

        void read(std::valarray<std::complex<float> >& vals, long first, long last) ;

        void read(std::valarray<std::complex<double> >& vals, long first, long last) ;

        // return a single  row of a vector column.
        template <typename S>
        void read(std::valarray<S>& vals, long rows) ;

        void read(std::valarray<std::complex<float> >& vals, long rows) ;

        void read(std::valarray<std::complex<double> >& vals, long rows) ;

        // get a set of rows from a vector column.
        template <typename S>
        void readArrays(std::vector<std::valarray<S> >& vals, long first, long last) ;

        void readArrays(std::vector<std::valarray<std::complex<float> > >& vals, long first, long last) ;

        void readArrays(std::vector<std::valarray<std::complex<double> > >& vals, long first, long last) ;

        // nullValue has no meaning when the target column has floating point/std::complex
        // type. Also, implict conversion of std::complex to pure real is not supported
        // by cfitsio.

        template <typename S>
        void read(std::vector<S>& vals, long first, long last, S* nullValue) ;

        // return a set of rows from a scalar column as a valarray.
        template <typename S>
        void read(std::valarray<S>& vals, long first, long last, S* nullValue);

        // return a single  row of a vector column.
        template <typename S>
        void read(std::valarray<S>& vals, long rows, S* nullValue) ;

        // get a set of rows from a vector column.
        template <typename S>
        void readArrays(std::vector<std::valarray<S> >& vals, long first, long last, S* nullValue);

        // add a null value to the column 
        template <typename T>
        void addNullValue(T nullVal);

        // get the TNULL setting
        template <typename T>
        bool getNullValue(T* nullVal) const;

        void write (const std::vector<String>& indata, long firstRow);

        friend void Table::insertRows(long first, long number);

        friend void Table::deleteRows(long first, long number);

        friend void Table::deleteRows(const std::vector<long>& rowList);

        friend void Table::initRead();

        friend void Table::reindex();

        friend void Table::copyData(const Table& right);
    protected:
        Column (int columnIndex, 	// The column index, i.e. the integer n in the keyword TCOLn
        const String &columnName, 	// The column name, curiously TTYPEn
        ValueType type, const String &format, 	// The TFORMn keyword.
        const String &unit, 	// The TUNITn keyword
        Table* p, 	// ! The Table containing the Column object
        int rpt = 1, long w = 1, const String &comment = "");
        Column (Table* p = 0);

        virtual bool compare (const Column &right) const;
        fitsfile* fitsPointer ();
        //	Protected method to set the current HDU to be the one containing this Column object. For use in
        //	public read/write methods to ensure that data regarding numbers of rows and width relate to the
        //	right HDU
        void makeHDUCurrent ();
        virtual std::ostream& put (std::ostream& s) const;
        void varLength (bool value);
        static const String& TBCOL ();
        static const String& TTYPE ();
        static const String& TUNIT ();
        static const String& TNULL ();
        static const String& TLMIN ();
        static const String& TLMAX ();
        static const String& TDMAX ();
        static const String& TDMIN ();
        static const std::vector<String>& columnKeys ();
        const String& comment () const;

      // Additional Protected Declarations

    private:
        Column & operator=(const Column &right);

        //	Insert one or more blank rows into a FITS column.
        virtual void insertRows (long first, long number = 1) = 0;
        virtual void deleteRows (long first, long number = 1) = 0;
        static void loadColumnKeys ();
        void name (const String& value);
        void format (const String& value);
        long numberOfElements (long& first, long& last);

      // Data Members for Class Attributes
        static const String s_TBCOL;
        static const String s_TTYPE;
        static const String s_TFORM;
        static const String s_TDISP;
        static const String s_TUNIT;
        static const String s_TSCAL;
        static const String s_TZERO;
        static const String s_TDIM;
        static const String s_TNULL;
        static const String s_TLMIN;
        static const String s_TLMAX;
        static const String s_TDMAX;
        static const String s_TDMIN;

      // Additional Private Declarations

    private: //## implementation
      // Data Members for Class Attributes
        int m_index;
        bool m_isRead;
        long m_width;
        size_t m_repeat;
        bool m_varLength;
        double m_scale;
        double m_zero;
        String m_display;
        String m_dimen;
        ValueType m_type;
        static const short LLIMITSHORT;
        static const long LLIMITLONG;
        static const unsigned short LLIMITUSHORT;
        static const unsigned long LLIMITULONG;
        static const unsigned char LLIMITUCHAR;
        static const float LLIMITFLOAT;
        static const double LLIMITDOUBLE;
        static const short ULIMITSHORT;
        static const long ULIMITLONG;
        static const unsigned short ULIMITUSHORT;
        static const unsigned long ULIMITULONG;
        static const unsigned char ULIMITUCHAR;
        static const float ULIMITFLOAT;
        static const double ULIMITDOUBLE;
        static const int LLIMITINT;
        static const int ULIMITINT;
        static const unsigned int LLIMITUINT;
        static const unsigned int ULIMITUINT;
        static const LONGLONG LLIMITLONGLONG;
        static const LONGLONG ULIMITLONGLONG;

      // Data Members for Associations
        Table* m_parent;
        static std::vector<String> s_columnKeys;
        String m_comment;
        String m_format;
        String m_unit;
        String m_name;

      // Additional Implementation Declarations

  };

  // Class CCfits::Column::RangeError 

  // Class CCfits::Column::InvalidDataType 

  // Class CCfits::Column::InvalidRowParameter 

  // Class CCfits::Column::WrongColumnType 

  // Class CCfits::Column::UnspecifiedLengths 

  // Class CCfits::Column::InvalidRowNumber 

  // Class CCfits::Column::InsufficientElements 

  // Class CCfits::Column::NoNullValue 

  // Class CCfits::Column::InvalidNumberOfRows 

  // Class CCfits::Column 

  inline void Column::setDimen ()
  {
  // default implementation: do nothing. Overridden by ColumnVectorData.
  }

  inline std::ostream& operator << (std::ostream& s, const Column& right)
  {

    return right.put(s);
  }

  inline bool operator < (const Column& left, const Column& right)
  {

    return left.m_index < right.m_index;
  }

  inline bool operator > (const Column& left, const Column& right)
  {

    return left.m_index > right.m_index;
  }

  inline void Column::resetRead ()
  {
     m_isRead = false;
  }

  inline int Column::index () const
  {
    return m_index;
  }

  inline void Column::index (int value)
  {
    m_index = value;
  }

  inline bool Column::isRead () const
  {
    return m_isRead;
  }

  inline void Column::isRead (bool value)
  {
    m_isRead = value;
  }

  inline long Column::width () const
  {
    return m_width;
  }

  inline void Column::width (long value)
  {
    m_width = value;
  }

  inline size_t Column::repeat () const
  {
    return m_repeat;
  }

  inline bool Column::varLength () const
  {
    return m_varLength;
  }

  inline double Column::scale () const
  {
    return m_scale;
  }

  inline void Column::scale (double value)
  {
    m_scale = value;
    int status(0);
    if (fits_set_tscale(fitsPointer(),m_index,value,m_zero,&status)) throw FitsError(status);
  }

  inline double Column::zero () const
  {
    return m_zero;
  }

  inline void Column::zero (double value)
  {
    m_zero = value;
  }

  inline const String& Column::display () const
  {
    return m_display;
  }

  inline const String& Column::dimen () const
  {
    return m_dimen;
  }

  inline void Column::dimen (const String& value)
  {
    m_dimen = value;
  }

  inline ValueType Column::type () const
  {
    return m_type;
  }

  inline void Column::type (ValueType value)
  {
    m_type = value;
  }

  inline const String& Column::TBCOL ()
  {
    return s_TBCOL;
  }

  inline const String& Column::TTYPE ()
  {
    return s_TTYPE;
  }

  inline const String& Column::TFORM ()
  {
    return s_TFORM;
  }

  inline const String& Column::TDISP ()
  {
    return s_TDISP;
  }

  inline const String& Column::TUNIT ()
  {
    return s_TUNIT;
  }

  inline const String& Column::TSCAL ()
  {
    return s_TSCAL;
  }

  inline const String& Column::TZERO ()
  {
    return s_TZERO;
  }

  inline const String& Column::TDIM ()
  {
    return s_TDIM;
  }

  inline const String& Column::TNULL ()
  {
    return s_TNULL;
  }

  inline const String& Column::TLMIN ()
  {
    return s_TLMIN;
  }

  inline const String& Column::TLMAX ()
  {
    return s_TLMAX;
  }

  inline const String& Column::TDMAX ()
  {
    return s_TDMAX;
  }

  inline const String& Column::TDMIN ()
  {
    return s_TDMIN;
  }

  inline const std::vector<String>& Column::columnKeys ()
  {
    return s_columnKeys;
  }

  inline const String& Column::comment () const
  {
    return m_comment;
  }

  inline const String& Column::format () const
  {
    return m_format;
  }

  inline const String& Column::unit () const
  {
    return m_unit;
  }

  inline const String& Column::name () const
  {
    return m_name;
  }

} // namespace CCfits


#endif