Changeset 11496 for trunk/FACT++
- Timestamp:
- 07/20/11 18:49:32 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Converter.cc
r11482 r11496 875 875 const char *charSrc = static_cast<const char*>(src); 876 876 877 for (Converter::FormatList::const_iterator i=fList.begin(); i!=fList.end(); i++) 877 // We skip the last element 'v' 878 for (Converter::FormatList::const_iterator i=fList.begin(); i!=fList.end()-1; i++) 878 879 { 879 if (charDest-size>dest/* || charSrc-size>src*/) 880 /* 881 // For speed reasons we don't do a check in the loop 882 if (charDest-size>dest || charSrc-size>src) 880 883 { 881 884 ostringstream err; … … 883 886 throw runtime_error(err.str()); 884 887 } 885 888 */ 889 890 // Skip strings (must be the last, so we could just skip it) 886 891 const char type = i->first.first->name()[0]; 887 if (type=='v')888 break;889 890 892 if (type=='S') 891 893 { 892 894 charSrc += strlen(charSrc)+1; 893 895 continue; 894 895 // copy string until termination896 // while (*charSrc)897 // *charDest++ = *charSrc++;898 //899 // *charDest++ = *charSrc++;900 896 } 901 902 // string types903 if (string("bsilfdxc").find_first_of(type)==string::npos)904 throw runtime_error(string("Type '")+type+"' not supported converting to FITS.");905 897 906 898 const int s = i->first.second; // size of element 907 899 const int n = i->second.first; // number of elements 908 900 909 // for all elements of this column 910 for (int j=0; j<n; j++) 901 // Check if there are types with unknown sizes 902 if (s==0 || n==0) 903 throw runtime_error(string("Type '")+type+"' not supported converting to FITS."); 904 905 // Let the compiler do some optimization 906 switch (s) 911 907 { 912 reverse_copy(charSrc, charSrc+s, charDest);913 914 charSrc += s;915 charDest += s;908 case 1: memcpy(charDest, charSrc, s*n); charSrc+=s*n; charDest+=s*n; break; 909 case 2: for (int j=0; j<n; j++) { reverse_copy(charSrc, charSrc+2, charDest); charSrc+=2; charDest+=2; } break; 910 case 4: for (int j=0; j<n; j++) { reverse_copy(charSrc, charSrc+4, charDest); charSrc+=4; charDest+=4; } break; 911 case 8: for (int j=0; j<n; j++) { reverse_copy(charSrc, charSrc+8, charDest); charSrc+=8; charDest+=8; } break; 916 912 } 917 913 } … … 920 916 { 921 917 ostringstream err; 922 err << " Data block size (" << size << ") doesn't fit format description [fmt=" << fFormat << "]";918 err << "ToFits - Data block size (" << size << ") doesn't fit format description [fmt=" << fFormat << "]"; 923 919 throw runtime_error(err.str()); 924 920 }
Note:
See TracChangeset
for help on using the changeset viewer.