// Constructor Input(int argc, char **argv) : ec_(false), shortestOnly_(false), distances_(false), suppressRef_(false), overlaps_(true), delim_("|"), refFile_(""), nonRefFile_(""), chr_("all") { typedef Ext::UserError UE; if ( 1 == argc ) throw(NoInput()); int argcntr = 1; bool outoption = false; // may choose up to one type of non-default output option // [Process-Flags] std::string next = ""; while ( argcntr < argc ) { next = argv[argcntr]; if ( next == "--help" ) throw(HelpException()); else if ( next == "--version" ) throw(VersionException()); else if ( next == "--ec" || next == "--header" ) ec_ = true; else if ( next == "--no-overlaps" ) overlaps_ = false; else if ( next == "--delim" ) { Ext::Assert<UE>(++argcntr < argc, "No value given for --delim."); delim_ = argv[argcntr]; } else if ( next == "--chrom" ) { Ext::Assert<UE>(++argcntr < argc, "No value given for --chrome."); chr_ = argv[argcntr]; } else if ( next == "--closest" ) { Ext::Assert<UE>(!outoption, "Multiple output options not allowed."); shortestOnly_ = true; outoption = true; } else if ( next == "--dist" ) distances_ = true; else if ( next == "--no-ref" ) suppressRef_ = true; else if ( next == "--help" ) throw(HelpException()); else if ( next == "--shortest" ) { // silently supported for bckwd compatibility Ext::Assert<UE>(!outoption, "Multiple output options not allowed."); shortestOnly_ = true; outoption = true; } else { // the rest are two input files? Ext::Assert<UE>(argcntr + 2 == argc, "Unknown option: " + next + "."); break; } ++argcntr; } // while Ext::Assert<UE>(argcntr + 2 == argc, "Not enough input files given."); refFile_ = argv[argcntr++]; nonRefFile_ = argv[argcntr]; Ext::Assert<UE>(refFile_.find("--") != 0, "Option given where file expected: " + refFile_ + "."); Ext::Assert<UE>(nonRefFile_.find("--") != 0, "Option given where file expected: " + nonRefFile_ + "."); }
/*! * Throws VersionException, SpecificationPathsNotValid, SpecificationTextNotValid * exception. */ Specification::Specification(const std::string & pathSpecification) : pathSpecification(pathSpecification) { std::ifstream _ifstream(pathSpecification.c_str()); if (_ifstream) { // Is true if file exists hasChanges = false; int totalQuestions; _ifstream.ignore(256, ' '); // ignore until space _ifstream >> version; if (!(version == 1 || version == 2 || version == 3)) { throw VersionException(version); } version = 3; _ifstream.ignore(256, ' '); // ignore until space _ifstream >> iD; _ifstream.ignore(256, ' '); // ignore until space _ifstream >> totalQuestions; questions = new std::vector<Question*>(totalQuestions, nullptr); try { for (int i = 1; i <= totalQuestions; i++) { std::string questionPath_; _ifstream >> questionPath_; (*questions)[i - 1] = Question::Initializer(questionPath_, _ifstream); } } catch (const SpecificationTextNotValid & ex) { _ifstream.close(); clear(); throw; // Rethrow for further handling in upper layers. } _ifstream.close(); hasChanges = false; validateQuestionPaths(); // Throws exception if not valid } else {