Changeset 17274 for trunk/Mars/mcore


Ignore:
Timestamp:
10/20/13 17:28:37 (11 years ago)
Author:
tbretz
Message:
Added more missing std::
Location:
trunk/Mars/mcore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mcore/DrsCalib.h

    r17265 r17274  
    12341234    std::string ReadFitsImp(const std::string &str, std::vector<float> &vec)
    12351235    {
    1236 #ifndef __MARS__
    1237         std::fits file(str);
    1238 #else
    12391236        fits file(str);
    1240 #endif
    12411237        if (!file)
    12421238        {
  • trunk/Mars/mcore/factfits.h

    r17264 r17274  
    135135        if (calib.bad())
    136136        {
    137             clear(rdstate()|ios::badbit);
     137            clear(rdstate()|std::ios::badbit);
    138138            return;
    139139        }
     
    145145        if (calib.GetNumRows() != 1)
    146146        {
    147             clear(rdstate()|ios::badbit);
    148 #ifdef __EXCEPTIONS
    149             throw runtime_error("Table 'ZDrsCellOffsets' found, but not with one row as expected");
     147            clear(rdstate()|std::ios::badbit);
     148#ifdef __EXCEPTIONS
     149            throw std::runtime_error("Table 'ZDrsCellOffsets' found, but not with one row as expected");
    150150#else
    151151            gLog << ___err___ << "ERROR - Table 'ZDrsCellOffsets' found, but not with one row as expected" << endl;
     
    155155        if (calib.GetStr("TTYPE1") != "OffsetCalibration")
    156156        {
    157             clear(rdstate()|ios::badbit);
    158 #ifdef __EXCEPTIONS
    159             throw runtime_error("Table 'DrsCalib' found, but first column is not the one expected");
     157            clear(rdstate()|std::ios::badbit);
     158#ifdef __EXCEPTIONS
     159            throw std::runtime_error("Table 'DrsCalib' found, but first column is not the one expected");
    160160#else
    161161            gLog << ___err___ << "ERROR - Table 'DrsCalib' found, but first column is not the one expected" << endl;
     
    165165        if (calib.GetStr("TFORM1") != "1474560I")  // 1024*1440
    166166        {
    167             clear(rdstate()|ios::badbit);
    168 #ifdef __EXCEPTIONS
    169             throw runtime_error("Table 'DrsCalib' has wrong column format (TFROM1)");
     167            clear(rdstate()|std::ios::badbit);
     168#ifdef __EXCEPTIONS
     169            throw std::runtime_error("Table 'DrsCalib' has wrong column format (TFROM1)");
    170170#else
    171171            gLog << ___err___ << "ERROR - Table 'DrsCalib' has wrong column format (TFORM1)" << endl;
     
    180180            return;
    181181
    182         clear(rdstate()|ios::badbit);
    183 
    184 #ifdef __EXCEPTIONS
    185         throw runtime_error("Reading column 'OffsetCalibration' failed.");
     182        clear(rdstate()|std::ios::badbit);
     183
     184#ifdef __EXCEPTIONS
     185        throw std::runtime_error("Reading column 'OffsetCalibration' failed.");
    186186#else
    187187        gLog << ___err___ << "ERROR - Reading column 'OffsetCalibration' failed." << endl;
     
    190190    }
    191191
    192     vector<int16_t> fOffsetCalibration; ///< integer values of the drs calibration used for compression
     192    std::vector<int16_t> fOffsetCalibration; ///< integer values of the drs calibration used for compression
    193193
    194194    size_t fOffsetStartCellData;
  • trunk/Mars/mcore/fits.h

    r17260 r17274  
    2323#include <iomanip>
    2424#include <iostream>
    25 #define gLog cerr
     25#ifndef gLog
     26#define gLog std::cerr
    2627#define ___err___   ""
    2728#define ___warn___  ""
    2829#define ___all___   ""
     30#endif
    2931#else
    3032#include "MLog.h"
     
    4446
    4547#include "checksum.h"
    46 
    47 #ifndef __MARS__
    48 namespace std
    49 {
    50 #endif
    5148
    5249class fits : public izstream
     
    136133                throw std::runtime_error(str.str());
    137134#else
    138                 gLog << ___err___ << "ERROR - " << str.str() << endl;
     135                gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    139136                return false;
    140137#endif
     
    148145                throw std::runtime_error(str.str());
    149146#else
    150                 gLog << ___err___ << "ERROR - " << str.str() << endl;
     147                gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    151148                return false;
    152149#endif
     
    160157                throw std::runtime_error(str.str());
    161158#else
    162                 gLog << ___err___ << "ERROR - " << str.str() << endl;
     159                gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    163160                return false;
    164161#endif
     
    319316                        throw std::runtime_error(str.str());
    320317#else
    321                         gLog << ___err___ << "ERROR - " << str.str() << endl;
     318                        gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    322319                        return;
    323320#endif
     
    337334                throw std::runtime_error("Column size mismatch");
    338335#else
    339                 gLog << ___err___ << "ERROR - Column size mismatch" << endl;
     336                gLog << ___err___ << "ERROR - Column size mismatch" << std::endl;
    340337                return;
    341338#endif
     
    362359                    continue;
    363360
    364                 gLog << ___all___ << setw(2) << it->second.type << '|' << it->first << '=' << it->second.value << '/' << it->second.comment << '|' << endl;
     361                gLog << ___all___ << std::setw(2) << it->second.type << '|' << it->first << '=' << it->second.value << '/' << it->second.comment << '|' << std::endl;
    365362            }}
    366363
     
    376373            for (Sorted::const_iterator it=sorted.cbegin(); it!=sorted.cend(); it++)
    377374            {
    378                 gLog << ___all___ << setw(6) << it->second.offset << "| ";
     375                gLog << ___all___ << std::setw(6) << it->second.offset << "| ";
    379376                gLog << it->second.num << 'x';
    380377                switch (it->second.type)
     
    389386                case 'D': gLog << "double(64)"; break;
    390387                }
    391                 gLog << ": " << it->first.second << " [" << it->second.unit << "]" << endl;
     388                gLog << ": " << it->first.second << " [" << it->second.unit << "]" << std::endl;
    392389            }
    393390        }
     
    427424                throw std::runtime_error(str.str());
    428425#else
    429                 gLog << ___err___ << "ERROR - " << str.str() << endl;
     426                gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    430427                return T();
    431428#endif
     
    557554    }
    558555
    559     void Constructor(const string &fname, string fout, const string& tableName, bool force, int tableNumber=-1)
     556    void Constructor(const std::string &fname, std::string fout, const std::string& tableName, bool force, int tableNumber=-1)
    560557    {
    561558        char simple[10];
     
    568565        if (memcmp(simple, "SIMPLE  = ", 10))
    569566        {
    570             clear(rdstate()|ios::badbit);
     567            clear(rdstate()|std::ios::badbit);
    571568#ifdef __EXCEPTIONS
    572569            throw std::runtime_error("File is not a FITS file.");
    573570#else
    574             gLog << ___err___ << "ERROR - File is not a FITS file." << endl;
     571            gLog << ___err___ << "ERROR - File is not a FITS file." << std::endl;
    575572            return;
    576573#endif
     
    596593                if (!good())
    597594                {
    598                     clear(rdstate()|ios::badbit);
     595                    clear(rdstate()|std::ios::badbit);
    599596#ifdef __EXCEPTIONS
    600597                    throw std::runtime_error("FITS file corrupted.");
    601598#else
    602                     gLog << ___err___ << "ERROR - FITS file corrupted." << endl;
     599                    gLog << ___err___ << "ERROR - FITS file corrupted." << std::endl;
    603600                    return;
    604601#endif
     
    609606                    if (!rc && !force)
    610607                    {
    611                         clear(rdstate()|ios::badbit);
     608                        clear(rdstate()|std::ios::badbit);
    612609#ifdef __EXCEPTIONS
    613610                        throw std::runtime_error("END keyword missing in FITS header.");
    614611#else
    615                         gLog << ___err___ << "ERROR - END keyword missing in FITS file... file might be corrupted." << endl;
     612                        gLog << ___err___ << "ERROR - END keyword missing in FITS file... file might be corrupted." << std::endl;
    616613                        return;
    617614#endif
     
    637634                if (!fTable)
    638635                {
    639                     clear(rdstate()|ios::badbit);
     636                    clear(rdstate()|std::ios::badbit);
    640637                    return;
    641638                }
     
    643640                // Check for table name. Skip until eof or requested table are found.
    644641                // skip the current table?
    645                 if ((!tableName.empty() &&         tableName!=fTable.Get<string>("EXTNAME")) ||
    646                     ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<string>("EXTNAME")) ||
     642                if ((!tableName.empty() &&         tableName!=fTable.Get<std::string>("EXTNAME")) ||
     643                    ( tableName.empty() && "ZDrsCellOffsets"==fTable.Get<std::string>("EXTNAME")) ||
    647644                    (tableNumber != -1))
    648645                {
     
    655652                    }
    656653                    const streamoff skip = fTable.GetTotalBytes();
    657                     seekg(skip, ios_base::cur);
     654                    seekg(skip, std::ios_base::cur);
    658655
    659656                    fChkHeader.reset();
     
    682679        if (!fCopy)
    683680        {
    684             clear(rdstate()|ios::badbit);
     681            clear(rdstate()|std::ios::badbit);
    685682#ifdef __EXCEPTIONS
    686683            throw std::runtime_error("Could not open output file.");
    687684#else
    688             gLog << ___err___ << "ERROR - Failed to open output file." << endl;
     685            gLog << ___err___ << "ERROR - Failed to open output file." << std::endl;
    689686#endif
    690687        }
     
    698695        fCopy.write(buf.data(), p);
    699696        if (!fCopy)
    700             clear(rdstate()|ios::badbit);
     697            clear(rdstate()|std::ios::badbit);
    701698    }
    702699
     
    711708            throw std::runtime_error("You are trying to read a compressed fits with the base fits class. Please use factfits instead.");
    712709#else
    713             gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << endl;
    714 #endif
    715             clear(rdstate()|ios::badbit);
     710            gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << std::endl;
     711#endif
     712            clear(rdstate()|std::ios::badbit);
    716713        }
    717714    }
     
    726723            throw std::runtime_error("You are trying to read a compressed fits with the base fits class. Please use factfits instead.");
    727724#else
    728             gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << endl;
    729 #endif
    730             clear(rdstate()|ios::badbit);
     725            gLog << ___err___ << "ERROR - You are trying to read a compressed fits with the base fits class. Please use factfits instead." << std::endl;
     726#endif
     727            clear(rdstate()|std::ios::badbit);
    731728        }
    732729    }
     
    762759                fCopy.write(fBufferRow.data()+offset, fTable.bytes_per_row);
    763760            if (!fCopy)
    764                 clear(rdstate()|ios::badbit);
     761                clear(rdstate()|std::ios::badbit);
    765762        }
    766763        else
    767764            if (fCopy.is_open())
    768                 clear(rdstate()|ios::badbit);
     765                clear(rdstate()|std::ios::badbit);
    769766    }
    770767
     
    804801        const char *pend = src + num*N;
    805802        for (const char *ptr = src; ptr<pend; ptr+=N, dest+=N)
    806             reverse_copy(ptr, ptr+N, dest);
     803            std::reverse_copy(ptr, ptr+N, dest);
    807804    }
    808805
     
    883880            throw std::runtime_error(str.str());
    884881#else
    885             gLog << ___err___ << "ERROR - " << str.str() << endl;
     882            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    886883            return NULL;
    887884#endif
     
    912909            throw std::runtime_error(str.str());
    913910#else
    914             gLog << ___err___ << "ERROR - " << str.str() << endl;
     911            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    915912            return false;
    916913#endif
     
    925922            throw std::runtime_error(str.str());
    926923#else
    927             gLog << ___err___ << "ERROR - " << str.str() << endl;
     924            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    928925            return false;
    929926#endif
     
    938935            throw std::runtime_error(str.str());
    939936#else
    940             gLog << ___err___ << "ERROR - " << str.str() << endl;
     937            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    941938            return false;
    942939#endif
     
    986983            throw std::runtime_error(str.str());
    987984#else
    988             gLog << ___err___ << "ERROR - " << str.str() << endl;
     985            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    989986            return false;
    990987#endif
     
    999996            throw std::runtime_error(str.str());
    1000997#else
    1001             gLog << ___err___ << "ERROR - " << str.str() << endl;
     998            gLog << ___err___ << "ERROR - " << str.str() << std::endl;
    1002999            return false;
    10031000#endif
     
    10541051};
    10551052
    1056 #ifndef __MARS__
    1057 };
    1058 #endif
    1059 #endif
     1053#endif
  • trunk/Mars/mcore/ofits.h

    r17264 r17274  
    1818
    1919#ifndef __MARS__
    20 #define gLog cerr
     20#ifndef gLog
     21#define gLog std::cerr
    2122#define ___err___   ""
    2223#define ___warn___  ""
    2324#define ___all___   ""
     25#endif
    2426#else
    2527#include "MLog.h"
  • trunk/Mars/mcore/zfits.h

    r17261 r17274  
    1414#include "FITS.h"
    1515
    16 #ifndef __MARS__
    17 namespace std
    18 {
    19 #endif
    20 
    2116class zfits : public fits
    2217{
     
    2419
    2520    // Basic constructor
    26     zfits(const string& fname, const string& tableName="", bool force=false)
     21    zfits(const std::string& fname, const std::string& tableName="", bool force=false)
    2722        : fNumTiles(0), fNumRowsPerTile(0), fCurrentRow(-1), fHeapOff(0), fTileSize(0)
    2823    {
     
    3328
    3429    // Alternative contstructor
    35     zfits(const string& fname, const string& fout, const string& tableName, bool force=false)
     30    zfits(const std::string& fname, const std::string& fout, const std::string& tableName, bool force=false)
    3631        : fNumTiles(0), fNumRowsPerTile(0), fCurrentRow(-1), fHeapOff(0), fTileSize(0)
    3732    {
     
    112107                    continue;
    113108
    114                 clear(rdstate()|ios::badbit);
     109                clear(rdstate()|std::ios::badbit);
    115110#ifdef __EXCEPTIONS
    116                 throw runtime_error("Only the FACT compression scheme is handled by this reader.");
     111                throw std::runtime_error("Only the FACT compression scheme is handled by this reader.");
    117112#else
    118113                gLog << ___err___ << "ERROR - Only the FACT compression scheme is handled by this reader." << endl;
     
    161156    streamoff fHeapFromDataStart; ///< offset from the beginning of the data table
    162157
    163     std::vector<std::vector<pair<int64_t, int64_t>>> fCatalog;     ///< Catalog, i.e. the main table that points to the compressed data.
    164     std::vector<size_t>                              fTileSize;    ///< size in bytes of each compressed tile
    165     std::vector<std::vector<size_t>>                 fTileOffsets; ///< offset from start of tile of a given compressed column
     158    std::vector<std::vector<std::pair<int64_t, int64_t>>> fCatalog;     ///< Catalog, i.e. the main table that points to the compressed data.
     159    std::vector<size_t>                                   fTileSize;    ///< size in bytes of each compressed tile
     160    std::vector<std::vector<size_t>>                      fTileOffsets; ///< offset from start of tile of a given compressed column
    166161
    167162    Checksum fRawsum;   ///< Checksum of the uncompressed, raw data
     
    212207                if (tempValues[0] < 0 || tempValues[1] < 0)
    213208                {
    214                     clear(rdstate()|ios::badbit);
     209                    clear(rdstate()|std::ios::badbit);
    215210#ifdef __EXCEPTIONS
    216                     throw runtime_error("Negative value in the catalog");
     211                    throw std::runtime_error("Negative value in the catalog");
    217212#else
    218213                    gLog << ___err___ << "ERROR - negative value in the catalog" << endl;
     
    266261        fCopy.write(buf.data(), catSize);
    267262        if (!fCopy)
    268             clear(rdstate()|ios::badbit);
     263            clear(rdstate()|std::ios::badbit);
    269264    }
    270265
     
    321316                fCopy.write(fCompressedBuffer.data()+offset, sizeToRead);
    322317                if (!fCopy)
    323                     clear(rdstate()|ios::badbit);
     318                    clear(rdstate()|std::ios::badbit);
    324319            }
    325320            else
    326321                if (fCopy.is_open())
    327                     clear(rdstate()|ios::badbit);
     322                    clear(rdstate()|std::ios::badbit);
    328323
    329324            const uint32_t thisRoundNumRows = (GetNumRows()<fCurrentRow + fNumRowsPerTile) ? GetNumRows()%fNumRowsPerTile : fNumRowsPerTile;
     
    364359
    365360                default:
    366                     clear(rdstate()|ios::badbit);
     361                    clear(rdstate()|std::ios::badbit);
    367362#ifdef __EXCEPTIONS
    368                     throw runtime_error("Unkown column ordering scheme found");
     363                    throw std::runtime_error("Unkown column ordering scheme found");
    369364#else
    370365                    gLog << ___err___ << "ERROR - unkown column ordering scheme" << endl;
     
    473468
    474469                default:
    475                     clear(rdstate()|ios::badbit);
     470                    clear(rdstate()|std::ios::badbit);
    476471
    477472                    std::ostringstream str;
    478473                    str << "Unkown processing applied to data. Col " << i << " proc " << j << " out of " << (int)head->numProcs;
    479474#ifdef __EXCEPTIONS
    480                     throw runtime_error(str.str());
     475                    throw std::runtime_error(str.str());
    481476#else
    482477                    gLog << ___err___ << "ERROR - Unknown processing applied to data. Aborting" << endl;
     
    520515            if (memcmp(tileHead.id, "TILE", 4))
    521516            {
    522                 clear(rdstate()|ios::badbit);
     517                clear(rdstate()|std::ios::badbit);
    523518                break;
    524519            }
     
    562557        if (numRows != fTable.num_rows)
    563558        {
    564             clear(rdstate()|ios::badbit);
     559            clear(rdstate()|std::ios::badbit);
    565560            std::ostringstream str;
    566561            str << "Heap data does not agree with header: " << numRows << " calculated vs " << fTable.num_rows << " from header.";
    567562#ifdef __EXCEPTIONS
    568                     throw runtime_error(str.str());
     563                    throw std::runtime_error(str.str());
    569564#else
    570565                    gLog << ___err___ << "ERROR - " << str.str() << endl;
     
    584579        if (catalog.size() != fCatalog.size())
    585580        {
    586                     clear(rdstate()|ios::badbit);
     581                    clear(rdstate()|std::ios::badbit);
    587582#ifdef __EXCEPTIONS
    588                     throw runtime_error("Heap data does not agree with header.");
     583                    throw std::runtime_error("Heap data does not agree with header.");
    589584#else
    590585                    gLog << ___err___ << "ERROR - Heap data does not agree with header." << endl;
     
    599594                    catalog[i][j].second != fCatalog[i][j].second)
    600595                {
    601                     clear(rdstate()|ios::badbit);
     596                    clear(rdstate()|std::ios::badbit);
    602597#ifdef __EXCEPTIONS
    603                     throw runtime_error("Heap data does not agree with header.");
     598                    throw std::runtime_error("Heap data does not agree with header.");
    604599#else
    605600                    gLog << ___err___ << "ERROR - Heap data does not agree with header." << endl;
     
    616611};//class zfits
    617612
    618 #ifndef __MARS__
    619 }; //namespace std
    620 #endif
    621 
    622613#endif
Note: See TracChangeset for help on using the changeset viewer.