BinaryFileDatumReader.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 CSIRO ICT Centre
00003  *
00004  * $Id: BinaryFileDatumReader.cpp 587 2004-12-03 15:06:33Z nch $
00005  */
00006 
00007 #include "Datum.h"
00008 #include "FileHeader.h"
00009 #include "FileObjectReader.h"
00010 #include "BinaryFileDatumReader.h"
00011 
00012 class Object;
00013 
00014 
00015 BinaryFileDatumReader::BinaryFileDatumReader()
00016     : FileObjectReader()
00017 {
00018 }
00019 
00020 Object * BinaryFileDatumReader::read(FILE * fp)
00021 {
00022   static const unsigned int BUF_SIZE = 40;
00023   static char buf[BUF_SIZE];
00024 
00025   Object * result = 0;
00026 
00027   if (fread(buf, sizeof(char), BUF_SIZE, fp) == BUF_SIZE)
00028   {
00029     unsigned long long id = *((unsigned long long *) (&buf[0]));
00030     double ra =             *((double *)             (&buf[8]));
00031     double orthoSD =        *((double *)             (&buf[16]));
00032     double dec =            *((double *)             (&buf[24]));
00033     double decSD =          *((double *)             (&buf[32]));
00034 
00035     result = new Datum(id, ra, orthoSD, dec, decSD);
00036   }
00037 
00038   return result;
00039 }
Generated on Mon Oct 4 10:39:55 2010 for Matching.kdevelop by  doxygen 1.6.3