Changeset 10356


Ignore:
Timestamp:
Apr 12, 2011, 4:24:34 PM (9 years ago)
Author:
lyard
Message:
Added ToFits method
Location:
trunk/FACT++/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/Converter.cc

    r10354 r10356  
    848848    return ret;
    849849}
     850
     851void Converter::ToFits(void* dest, const void* src, size_t size)
     852{
     853        //crawl through the src buffer and copy the data appropriately to the destination buffer
     854        //Assumption: the string is always last. This way we use the provided size to determine the number
     855        //of character to copy
     856        char * charDest = static_cast<char*>(dest);
     857        const char* charSrc = static_cast<const char*>(src);
     858        size_t cOffset = 0;
     859        int elemSize = 0;
     860
     861        for (unsigned int i=0;i<fList.size()-1;i++)
     862        {
     863                if (fList[i].first.first->name()[0] == 'S') //string
     864                {
     865                        for (size_t j=cOffset;j<size;j++)
     866                                charDest[j] = charSrc[j];                       
     867                        continue;
     868                }
     869               
     870                elemSize = fList[i].first.second;
     871                for (int j=0;j<fList[i].second.first;j++)//for all elements of this column
     872                {
     873                        for (int k=0;k<elemSize;k++)//swap the element bytes
     874                                charDest[cOffset+k] = charSrc[cOffset + elemSize - (k+1)];
     875                        cOffset += elemSize;
     876                }
     877        }
     878}
     879
     880
     881
     882
     883
     884
     885
     886
  • trunk/FACT++/src/Converter.h

    r10326 r10356  
    9090
    9191    static std::string GetHex(const void *d, size_t size, size_t chunk=1);
     92   
     93    void ToFits(void* dest, const void* src, size_t size);
    9294
    9395/*
Note: See TracChangeset for help on using the changeset viewer.