int processFilepath( const char * filename, // name of the file to be read std::ostream * os, // output stream to use (NULL for no output). Not that cerr is used to report errors. MultiFormatReader::DataFormatType fmt, // enum indicating the file format to expect. INIReader & iniReader) { assert(filename); int rc; try { MultiFormatReader * nexusReader; nexusReader = instantiateReader(); if (!gQuietMode) { cerr << "Executing" << endl; } try { nexusReader->DemoteBlocks(); nexusReader->ReadFilepath(filename, fmt); rc = processContent(*nexusReader, filename, os, iniReader); } catch(...) { nexusReader->DeleteBlocksFromFactories(); delete nexusReader; throw; } nexusReader->DeleteBlocksFromFactories(); delete nexusReader; return rc; } catch (const NxsException &x) { cerr << "Error:\n " << x.msg << endl; if (x.line > 0 || x.pos > 0) { cerr << "at line " << x.line << ", column (approximately) " << x.col << " (and file position "<< x.pos << ")" << endl; } return 2; } }
int processFilepath( const char * filename, // name of the file to be read ostream * , // output stream to use (NULL for no output). Not that cerr is used to report errors. MultiFormatReader::DataFormatType fmt, // enum indicating the file format to expect. ProcessActionsEnum ) // enum that is passed on to processContent to indicate what should be done with the content of the file. #endif { assert(filename); try { MultiFormatReader * nexusReader; # if defined(MULTIFILE_NEXUS_READER) && MULTIFILE_NEXUS_READER nexusReader = gNexusReader; # else nexusReader = instantiateReader(); # endif if (!gQuietMode) cerr << "Executing" << endl; try { nexusReader->DemoteBlocks(); nexusReader->ReadFilepath(filename, fmt); # if !defined(MULTIFILE_NEXUS_READER) || !MULTIFILE_NEXUS_READER processContent(*nexusReader, os, currentAction); # endif } catch(...) { nexusReader->DeleteBlocksFromFactories(); # if ! defined(MULTIFILE_NEXUS_READER) || !MULTIFILE_NEXUS_READER delete nexusReader; # endif throw; } # if !defined(MULTIFILE_NEXUS_READER) || !MULTIFILE_NEXUS_READER nexusReader->DeleteBlocksFromFactories(); delete nexusReader; # endif return 0; } catch (const NxsException &x) { cerr << "Error:\n " << x.msg << endl; if (x.line > 0 || x.pos > 0) cerr << "at line " << x.line << ", column (approximately) " << x.col << " (and file position "<< x.pos << ")" << endl; return 2; } }