void saveAsText(EcgStream_four & input)
{
//	EcgStream_four& input=*inputStream;
	QFile outFileHeader(SettingsSingleton::instance().getFileName()+"_header.txt");

	    if (!outFileHeader.open(QIODevice::WriteOnly | QIODevice::Text)) {
//	        emit updateStatus("Failed to open data file for write!");
	    	std::cerr << "Failed to open header-data file for write!!" << endl;
	    } else {
	        QTextStream outHeader(&outFileHeader);

	        outHeader   << "[ECG CAPTURE SETTINGS]\n"
	                    << "Filename: " <<      SettingsSingleton::instance().getFileName() << ".txt \n"
	        //            << "Samples: " <<       QString::number(sampleData->length()) << "\n"
	        //            << "Duration: " <<      QString::number(sampleData->last().at(0)) << "ms \n"
	                    << "Sample rate: " <<   QString::number(SettingsSingleton::instance().getSampleRate()) << " Hz\n"
	                    << "Source: "  <<       SettingsSingleton::instance().getSource() << "\n"
	                    << "\n[RECORDING INFORMATION]\n"
	                    << "Recording name: " <<    SettingsSingleton::instance().getRecordingName() << "\n"
	                    << "Patient code: " <<      SettingsSingleton::instance().getPatientCode() << "\n"
	                    << "Name: " <<              SettingsSingleton::instance().getName() << "\n"
	                    << "Gender: " <<            SettingsSingleton::instance().getGender() << "\n"
	                    << "Birthdate: " <<         SettingsSingleton::instance().getBirthDate() << "\n"
	                    << "Notes: " <<             SettingsSingleton::instance().getNotes() << "\n";

	        outFileHeader.close();

	    }

	    QFile outFile(SettingsSingleton::instance().getFileName() + ".txt");

	    if (!outFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
//	        emit updateStatus("Failed to open data file for write!");
	        std::cerr << "Failed to open data file for write" << std::endl;
	    } else {
	        QTextStream out(&outFile);

//	        emit updateStatus(QString("Writing " + QString::number(sampleData->length()) + " samples to " + fileName + "..."));
	        qDebug() << "Writing " << input.getSize() << " samples to " << SettingsSingleton::instance().getFileName() << "..." << endl;
	        while (!input.empty()){
	        	EcgStruct4 tmp=input.getDataD();
	        			out << QString::number(tmp.time)
	        				<< QString::number(tmp.frame1)
	        			<< QString::number(tmp.frame2)
	        			<< QString::number(tmp.frame3)
	        			<< QString::number(tmp.frame4) << "\n";

//	            out << QString::number(sampleData->at(ii).at(0)) << "\t"
//	                << QString::number(sampleData->at(ii).at(1)) << "\t"
//	                << QString::number(sampleData->at(ii).at(2)) << "\t"
//	                << QString::number(sampleData->at(ii).at(3)) << "\t"
	        //    out << QString::number(inputStream.getData()) << "\n";
	        }

//	        emit updateStatus(QString("Samples saved in text format"));
	        std::cerr << "Samples saved in text format" << std::endl;

	        outFile.close();
	    }
}
示例#2
0
void LongLong() {
    // at least 64 bits guaranteed
    long long longLongInteger = 9223372036854775807LL;
    outHeader("long long - a longer integer");
    outIdent();
    std::cout
        << "value: " << ++longLongInteger
        << std::endl;
}
void UserDefinedLiterals() {
    auto c = "42"_cul;
    outHeader("User defined literals");
    outIdent();
    std::cout
        << "member of class, constructed from user defined string: "
        << c.getA()
        << std::endl;
}
void UnorderedContainers() {
    std::unordered_map<std::string, int> um =
            { {"1 Vinny", 1}, {"2 Pooh", 2}, {"3 Pyatachok", 2} };
    // result is hashed sort order
    // fast search for very lardge containers
    outHeader("unordered containers");
    outIdent();
    for (auto i : um) std::cout << "{" << i.first << "," << i.second << "}";
    std::cout << std::endl;
}
示例#5
0
void Array() {
    std::array<int, 10> a;
    for (auto& i : a) i = 42;
    for (auto i = a.begin(); i != a.end(); ++i) *i = 24;
    int size = a.size();
    outHeader("std::array");
    outIdent();
    std::cout
        << "size = "
        << size;
    outTail();
}
void UniformInitialization() {
    UniformInitStruct uis{5, 3.2};
    uis.x++;
    UniformInitClass uic = {2, 4.3};
    UniformInitStruct uis2(uic.toUniformInitStruct());
    outHeader("uniform initialization syntax and semantics");
    outIdent();
    std::cout
        << "UniformInitStruct.x = " << uis2.x
        << "UniformInitStruct.y = " << uis2.y
        << std::endl;
    std::vector<int> uivec{4}; // one element with value 4
}
示例#7
0
void SharedPtr() {
    struct Object {
        Object() { std::cout << "(Object ctor)  " << std::flush; }
        ~Object() { std::cout << "(Object dtor)  " << std::flush; }
    };
    outHeader("shared_ptr");
    outIdent();
    std::cout << "(Creating Object)  " << std::flush;
    std::shared_ptr<Object> sp(new Object);
    {
        std::cout << "(1st Sharing Object ownership)  " << std::flush;
        std::shared_ptr<Object> sp2(sp);
        {
            std::cout << "(2nd Sharing Object ownership)  " << std::flush;
            std::shared_ptr<Object> sp3(sp);
        }
    }
    std::cout << std::endl;
}
示例#8
0
// All the work is done here
int joinEXRs( int tilesX, int tilesY, const char* baseName, bool deleteTiles, bool Verbose )
{
   int exitCode = 0;

   // Expand names
   if( Verbose ) printf("Image file name = '%s', tilesX=%d, tilesY=%d\n", baseName, tilesX, tilesY);
   int numTiles = tilesX * tilesY;

   // Allocate memory:
   char ** tileNames = new char * [numTiles];
   Imf::InputFile ** iFiles = new Imf::InputFile * [numTiles];
   for( int i = 0; i < numTiles; i++)
   {
      tileNames[i] = new char[FILENAME_MAXLEN];
      iFiles[i] = 0;
   }

   // Insert tile info and check if files exist
   int nonEmptyTile = -1;
   struct stat stFileInfo;

   for( int i = 0; i < numTiles; i++)
   {
      sprintf( tileNames[i], "%s.tile_%d.exr", baseName, i);
      if( Verbose ) printf("Tile name  %d = '%s'\n", i, tileNames[i]);

      if( stat( tileNames[i], &stFileInfo ) == 0 )
      {
         // File exists - so open it and check for validness
         iFiles[i] = new Imf::InputFile( tileNames[i]);
         if( false == iFiles[i]->isComplete())
         {
            fprintf( stderr, "Error: File '%s' is incomplete or is not an OpenEXR file.\n", tileNames[i]); fflush( stderr);
            delete iFiles[i];
            iFiles[i] = 0;
            exitCode = 1;
         }
         else if( nonEmptyTile == -1 )
         {
            nonEmptyTile = i;
         }
      }
      else
      {
         fprintf( stderr, "Error: File '%s' not founded.\n", tileNames[i]); fflush( stderr);
         exitCode = 1;
      }
   }

   if( nonEmptyTile < 0) // All tiles were empty
   {
      fprintf( stderr, "Error: No tile files founded.\n"); fflush( stderr);
   }
   else
   {
   // Gather info from a non-empty tile file
   Imf::Header inHeader = iFiles[nonEmptyTile]->header();
   Imath::Box2i imageBox = inHeader.displayWindow(); // size of the resulting image
   int imageWidth = imageBox.max.x - imageBox.min.x + 1;
   int imageHeight = imageBox.max.y - imageBox.min.y + 1;

   // Iterate through all the channels and reserve mem for the whole display window
   // also add channels to the header of the output file
   Imf::Header outHeader( imageWidth, imageHeight);
   std::map< Imf::Name, ChannelInfo* > chInfos; // this will hold pixel data and stride for each channel in input files
   Imf::ChannelList channels = inHeader.channels();
   Imf::ChannelList::ConstIterator itCh;
   for( itCh = channels.begin(); itCh != channels.end(); itCh++ )
   {
      chInfos[itCh.name()] = new ChannelInfo( typeSize( itCh.channel().type), imageHeight, imageWidth );
      outHeader.channels().insert( itCh.name(), Imf::Channel( itCh.channel().type));
      if( Verbose) printf("Channel: '%s' | stride: %d\n", itCh.name(), typeSize( itCh.channel().type));
   }

   // Collect data from files
   Imath::Box2i tileBox;      // each tile's data window
   Imath::Box2i resultBox;    // resulting data window (should be sum of all tiles' data windows)
   Imf::FrameBuffer fb;
   for( int i = 0; i < numTiles; i++)
   {
      if( iFiles[i] == 0) // no file for this tile
         continue;

      tileBox = iFiles[i]->header().dataWindow();
      resultBox.extendBy( tileBox );

      if( Verbose) printf("Data win: xmin=%d xmax=%d ymin=%d ymax=%d\n", tileBox.min.x, tileBox.max.x, tileBox.min.y, tileBox.max.y);

      channels = iFiles[i]->header().channels();
      for( itCh = channels.begin(); itCh != channels.end(); itCh++ )
         fb.insert( itCh.name(),
                    Imf::Slice( itCh.channel().type,                // pixel type
                    (char*)&chInfos[itCh.name()]->array2d[0][0],    // base
                    chInfos[itCh.name()]->stride,                   // x stride
                    chInfos[itCh.name()]->stride * imageWidth,      // y stride
                    1, 1, 0.0 ) );                                  // x,y sampling, fill value

      iFiles[i]->setFrameBuffer(fb);
      iFiles[i]->readPixels( tileBox.min.y, tileBox.max.y);
   }

   // Write out everything:
   outHeader.dataWindow() = resultBox;
   Imf::OutputFile imageFile( baseName, outHeader );
   imageFile.setFrameBuffer(fb);
   imageFile.writePixels( resultBox.max.y-resultBox.min.y+1 );

   printf("Joined EXR image successfully written.\n");

   // Free files:
   for( int i = 0; i < numTiles; i++)
      if( iFiles[i] != 0 ) delete iFiles[i];
   delete [] iFiles;

   if( deleteTiles )
   {
      for( int i = 0; i < numTiles; i++)
         if( unlink( tileNames[i]) != 0)
         {
            perror("Remove");
            printf("Can't remove file '%s'\n", tileNames[i]);
         }
   }
   }

   // Free names:
   for( int i = 0; i < numTiles; i++)
      delete [] tileNames[i];
   delete [] tileNames;

   return exitCode;
}
示例#9
0
/**
 * Reads and merges sfd (wfd) files together.
 */
int
sfdmerger( int argc, char* argv[] ) {
   if ( argc < 3 ) {
      mc2log << error << "Usage: sfdmerger outSFDfile inSFDfile+" << endl;
      return 1;
   }
   // COH to get BT
   CommandlineOptionHandler coh( argc, argv );

   SFDSavableHeader outHeader( argv[ 1 ], false/*debug*/ );
   SFDMultiBufferWriter out( 0/*startOffset*/ );
   int res = 0;

   // TODO: First go thou all files and read headers and merge them
   // TODO: Check for buffers with same crc and reuse the old if so

   for ( int i = 2/*0 is program name, 1 is out file name*/; 
         i < argc && res == 0 ; ++i ) {
      // Read and add to out
      mc2dbg << "Attempting to read " << argv[ i ] << endl;
      vector<byte> buff;
      int fres = File::readFile( argv[ i ], buff );
      if ( fres < 0 ) {
         res = 2;
      } else {
         mc2dbg << "Attempting to load " << argv[ i ] << endl;
         BitBuffer* bitBuff = new BitBuffer( &buff.front(), buff.size() );
         mc2dbg << "file size " << bitBuff->getBufferSize() << endl;
         // Header
         SFDLoadableHeader header( argv[ i ], false/*debug*/ );
         mc2dbg << "pos before header " << bitBuff->getCurrentOffset() << endl;
         header.load( *bitBuff );
         mc2dbg << "pos after header " << bitBuff->getCurrentOffset() << endl;

         mc2dbg << "header.m_stringsAreNullTerminated " << header.stringsAreNullTerminated() << endl;
         mc2dbg << "header.m_strIdxEntrySizeBits " << header.getStrIdxEntrySizeBits() << endl;
         mc2dbg << "header.m_strIdxStartOffset " <<  header.getStrIdxStartOffset() << endl;
         mc2dbg << "header.m_nbrStrings " << header.getNbrStrings() << endl;
         mc2dbg << "header.m_strDataStartOffset " << header.getStrDataStartOffset() << endl;
         mc2dbg << "header.m_bufferIdxStartOffset " << header.getBufferIdxStartOffset() << endl;
         mc2dbg << "header.m_bufferDataStartOffset " << header.getBufferDataStartOffset() << endl;
         mc2dbg << "header.m_maxStringSize " << header.maxStringSize() << endl;
         // str_offset_buf
         mc2dbg << "pos before str_offset_buf " << bitBuff->getCurrentOffset() << endl;
         for ( uint32 i = 0 ; i < header.getNbrStrings() + 1 ; ++i ) {
            bitBuff->readNextBALong();
         }
         // strBuf
         mc2dbg << "pos before strBuf " << bitBuff->getCurrentOffset() << endl;
         for ( uint32 i = 0 ; i < header.getNbrStrings() ; ++i ) {
            bitBuff->readNextString();
         }
         // buf_offset_buf
         mc2dbg << "pos before buf_offset_buf " << bitBuff->getCurrentOffset() << endl;
         uint32 buffOffset = 0;
         for ( uint32 i = 0 ; i < header.getNbrStrings() + 1 ; ++i ) {
            buffOffset = bitBuff->readNextBALong();
            mc2dbg << "buffOffset " << buffOffset << endl;
         }
         // mapBuf
         mc2dbg << "pos before mapBuff " << bitBuff->getCurrentOffset() << endl;
         for ( uint32 i = 0 ; i < header.getNbrStrings() ; ++i ) {
            // TileMap
         }
         // Skipp to buffOffset
         bitBuff->readPastBytes( buffOffset -
                                 bitBuff->getCurrentOffset() );
         mc2dbg << "pos after mapBuff " << bitBuff->getCurrentOffset() 
                << " buffOffset " << buffOffset << endl;
         // offsetBuf
         //  offset for each tile in the tile collection
         //  Get min, max from TileCollectionNotice...
         const vector<TileCollectionNotice>& tileCollection =
            header.getTileCollection();
         uint32 nbrOffsets = 0;
         int aLatIdx = MAX_INT32;
         int aLonIdx = MAX_INT32;
         for ( uint32 i = 0 ; i < tileCollection.size() ; ++i ) {
            const vector<TilesForAllDetailsNotice>& tileDetail =
               tileCollection[ i ].getTilesForAllDetails();
            for ( uint32 j = 0 ; j < tileDetail.size() ; ++j ) {
               const vector<TilesNotice>& tileNotices = 
                  tileDetail[ j ].getTilesNotices();
               for ( uint32 k = 0 ; k < tileNotices.size() ; ++k ) {
                  int startLatIdx = tileNotices[ k ].getStartLatIdx();
                  if ( aLatIdx == MAX_INT32 ) {
                     aLatIdx = startLatIdx;
                  }
                  int endLatIdx = tileNotices[ k ].getEndLatIdx();
                  int startLonIdx = tileNotices[ k ].getStartLonIdx();
                  if ( aLonIdx == MAX_INT32 ) {
                     aLonIdx = startLonIdx;
                  }
                  int endLonIdx = tileNotices[ k ].getEndLonIdx();
                  int nbrLayers = tileNotices[ k ].getNbrLayers();
                  nbrOffsets += 
                     (endLatIdx - startLatIdx + 1) * (endLonIdx-startLonIdx + 1);
                  mc2dbg << "startLatIdx " << startLatIdx << endl;
                  mc2dbg << "endLatIdx " << endLatIdx << endl;
                  mc2dbg << "startLonIdx " << startLonIdx << endl;
                  mc2dbg << "endLonIdx " << endLonIdx << endl;
                  mc2dbg << "nbrLayers " << nbrLayers << endl;
                  //mc2dbg << "nbrOffsets += " << ((endLatIdx - startLatIdx + 1) * (endLonIdx-startLonIdx + 1))  << endl;
               } // End for all TilesNotice

            } // End for all TilesForAllDetailsNotice

         } // End for all TileCollectionNotice

         mc2dbg << "Nbr offsets = " << (nbrOffsets+1) << endl;
         
         bitBuff->readPastBytes( (nbrOffsets+1) * 4 );

         uint32 nbrMultiBuffers = 0;
         for ( uint32 i = 0 ; i < tileCollection.size() ; ++i ) {
            const vector<TilesForAllDetailsNotice>& tileDetail =
               tileCollection[ i ].getTilesForAllDetails();
            for ( uint32 j = 0 ; j < tileDetail.size() ; ++j ) {
               const vector<TilesNotice>& tileNotices = 
                  tileDetail[ j ].getTilesNotices();
               for ( uint32 det = 0 ; det < tileNotices.size() ; ++det ) {

                  int startLatIdx = tileNotices[ det ].getStartLatIdx();
                  int endLatIdx = tileNotices[ det ].getEndLatIdx();
                  int startLonIdx = tileNotices[ det ].getStartLonIdx();
                  int endLonIdx = tileNotices[ det ].getEndLonIdx();
                  int nbrLayers = tileNotices[ det ].getNbrLayers();
                  mc2dbg << "startLatIdx " << startLatIdx << endl;
                  mc2dbg << "endLatIdx " << endLatIdx << endl;
                  mc2dbg << "startLonIdx " << startLonIdx << endl;
                  mc2dbg << "endLonIdx " << endLonIdx << endl;
                  mc2dbg << "nbrLayers " << nbrLayers << endl;

                        
                  for ( int32 lat = startLatIdx ; lat <= endLatIdx ; ++lat ) {
                     for ( int32 lon = startLonIdx ; lon <= endLonIdx ; ++lon ) {
                              
                        //for ( int imp = tileNotices[ k ].getFirstImportanceNbr( 0/*lay*/ ) ; imp <= tileNotices[ k ].getLastImportanceNbr( 0/*lay*/ ) ; ++imp ) {

                        mc2dbg << "multiBuff  " << nbrMultiBuffers++ << " lat " << lat << "/" << endLatIdx << " lon " << lon << "/" << endLonIdx << " det " << det << "/" << tileNotices.size() /*<< " imp " << imp << "/" << tileNotices[ k ].getLastImportanceNbr( 0*lay* )*/ /*<< " lay " << lay << "/" << nbrLayers*/ << " tileNotice " << det << "/" << tileNotices.size() << " tileDetails " << j << "/" << tileDetail.size() << " " << " tileCollection " << i << endl;
                        mc2dbg << "pos before multiBuff " << bitBuff->getCurrentOffset() << endl;
                        // multiBuf
                        const TileMapParams param( 
                           9/*serverPrefix*/, 1/*gzip*/, 0/*layer*/, 
                           TileMapTypes::tileMapData, 0/*imp*//*importanceNbr*/, LangTypes::english,
                           lat/*tileIndexLat*/, lon, det/*detailLevel*/ ); // FIXME: Less hardcoded values
                        auto_ptr<SFDMultiBufferReader> reader( new SFDMultiBufferReader( bitBuff, param, &header ) );
                        mc2dbg << "reader.hasNext() " << reader->hasNext() << endl;
                        while ( reader->hasNext() ) {
                           LangTypes::language_t lang = LangTypes::english; // FIXME:
                           // Data
                           SFDMultiBufferReader::bufPair_t data = reader->readNext( lang );
                           // TODO: Add more to outHeader
                           outHeader.updateMetaData( data.first.getAsString() );
                           out.addMap( data.first, data.second );
                        }
                        mc2dbg << "pos after multiBuff " << bitBuff->getCurrentOffset() 
                               << " buffer is " << bitBuff->getBufferSize() << endl;

                        //mc2dbg << "Done with importance " << imp << "/" << tileNotices[ k ].getLastImportanceNbr( 0/*lay*/ ) << endl;
                        //} // End for all importances

                     } // End for all lon
                  } // End for all lat
                              
                  mc2dbg << "TileNotice " << det << " done" << endl;
               } // End for all TilesNotice
               
               mc2dbg << "TileDetailNotice " << j << " done" << endl;
            } // End for all TilesForAllDetailsNotice
         } // End for all TileCollectionNotice

         mc2dbg << "pos after all multiBuff " << bitBuff->getCurrentOffset() 
                << " buffer is " << bitBuff->getBufferSize() << endl;
      } // End else could read input file
   } // For all input sfd-files

   if ( res == 0 ) {
      mc2dbg << "Read all sfd files now saving meta sfd" << endl;
      // SharedBuffer& buf;
      // outHeader
      out.writeAdded();
      const SharedBuffer* outData = out.getBuffer();
      mc2dbg << "Writing " << outData->getBufferSize() << " bytes "
             << "to " << outHeader.getName().c_str() << endl;
      int fres = File::writeFile( 
         outHeader.getName().c_str(), 
         outData->getBufferAddress(), outData->getBufferSize() );
      if ( fres <= 0 ) {
         mc2dbg << "Write failed res " << fres << endl;
         res = 2;
      }
   }

   return res;
}
示例#10
0
文件: main.cpp 项目: Baltasarq/cp3mm
int main(int argc, const char * argv[])
{
    std::string inputFileName;
    std::auto_ptr<Cp3mm::Parser::Cp3Parser> parser;
    bool force = false;
    bool help = false;
    bool version = false;
    bool verbose = false;
    unsigned int firstArg = 1;
    Cp3mm::Tds::Entity::Strictness strictness = Cp3mm::Tds::Entity::MediumStrictness;

    try {
        // Welcome
        printf( "%s", Cp3mm::AppInfo::TitleMessage.c_str() );
        printf( " (%s %s)\n\n", Cp3mm::AppInfo::Name.c_str(), Cp3mm::AppInfo::Version.c_str() );

        // Explore and answer command-line options
        processOptions( firstArg, argv, argc, force, help, version, verbose, strictness );

        if ( version ) {
            printf( "%s (%s) by %s - %s\n\n",
                    Cp3mm::AppInfo::Name.c_str(), Cp3mm::AppInfo::Version.c_str(),
                    Cp3mm::AppInfo::Author.c_str(), Cp3mm::AppInfo::Copyright.c_str()
            );
            goto End;
        }

        if ( help ) {
            printf( "%s\n", MsgHelp.c_str() );
            goto End;
        }

        // Report, if needed
        if ( strictness == Cp3mm::Tds::Entity::ErroneousStrictness ) {
            strictness = Cp3mm::Tds::Entity::MediumStrictness;
        }

        if ( verbose ) {
            printf( "Force: %s\tStrict level: %s\n\n",
                    force? "yes" : "no",
                    Cp3mm::Tds::Entity::cnvtStrictnessToString( strictness ).c_str()
            );
        }

        // Process parameter
        if ( argc == 2 ) {
            inputFileName = argv[ firstArg ];

            // Only process it provided it has the correct extension
            if ( Cp3mm::AppInfo::isAcceptedExt( FileMan::getExt( inputFileName ) ) )
            {
                // Open input file
                InputFile inputFile( inputFileName );

                // Prepare output file names
                std::string outputHeaderName = FileMan::replaceExt( inputFileName, Cp3mm::AppInfo::CHeaderFilesExt );
                std::string outputImplName   = FileMan::replaceExt( inputFileName, Cp3mm::AppInfo::CppFilesExt );
                std::string outputDepsName   = FileMan::replaceExt( inputFileName, Cp3mm::AppInfo::DepFilesExt );

                // Chk if anything really needs to be done
                if ( !force
                  && isUpdated( inputFile, outputHeaderName, outputImplName ) )
                {
                    printf( "Skipping '%s' due to '%s' and '%s' being up to date.\n\n",
                                inputFileName.c_str(),
                                outputHeaderName.c_str(),
                                outputImplName.c_str()
                    );
                    goto End;
                }

                // Open output files
                OutputFile outHeader( outputHeaderName );
                OutputFile outImpl( outputImplName );

                // Process file
                parser.reset(
                    new Cp3mm::Parser::Cp3Parser( inputFile, outHeader, outImpl, strictness )
                );
                printf( "Processing( '%s' )...\n", inputFileName.c_str() );
                parser->process();

                // Finishing
                parser->saveDependenciesToFile( outputDepsName );
                printf( "Done( '%s' ).\n", outputImplName.c_str() );
            }
            else printf( "Skipped( '%s' ).\n", inputFileName.c_str() );
        }
        else throw std::runtime_error( "invalid number of arguments" );
    } catch(const Cp3mm::Parser::ParserError &e) {
        std::string statement = parser->getCurrentLine();
        unsigned int pos = 0;

        if ( parser->getCurrentLex() != NULL ) {
            statement = parser->getCurrentLine();
            pos = parser->getCurrentPos();
        }

        std::printf( "\n%s: %s at %d,%d\n\t%s\n\t%s:%d: '%s'\n",
                inputFileName.c_str(),
                e.getType(),
                e.getNumLine(),
                pos,
                statement.c_str(),
                inputFileName.c_str(),
                e.getNumLine(),
                e.what()
        );

        exit( EXIT_FAILURE );
    }
    catch(const Cp3mm::Tds::StrictnessError &e) {
        std::printf( "\nStrictness error: '%s'\n", e.what() );
        exit( EXIT_FAILURE );
    }
    catch(const Cp3mm::Tds::SemanticError &e) {
        std::printf( "\nSemantic error: '%s'\n", e.what() );
        exit( EXIT_FAILURE );
    }
    catch(const std::runtime_error &e) {
        std::printf( "\nError: '%s'\n", e.what() );
        exit( EXIT_FAILURE );
    }
    catch(const std::exception &e) {
        std::printf( "\nCRITICAL: '%s'\n", e.what() );
        exit( EXIT_FAILURE );
    }
    catch(...) {
        std::printf( "\nCRITICAL UNKNOWN ERROR\n" );
        exit( EXIT_FAILURE );
    }

    End:
    return EXIT_SUCCESS;
}