void RbSettings::setOption(const std::string &key, const std::string &value, bool write) { if ( key == "moduledir" ) { moduleDir = value; } else if ( key == "printNodeIndex" ) { printNodeIndex = value == "TRUE"; } else if ( key == "tolerance" ) { //std::string::size_type sz; // alias of size_t //tolerance = std::stod (value,&sz); tolerance = (double)atof(value.c_str()); } else if ( key == "linewidth" ) { //std::string::size_type sz; // alias of size_t //lineWidth = std::stoi (value,&sz); lineWidth = atoi(value.c_str()); } else if ( key == "useScaling" ) { useScaling = value == "TRUE"; } else if ( key == "scalingDensity" ) { size_t w = atoi(value.c_str()); if(w < 1) throw(RbException("scalingDensity must be an integer greater than 0")); scalingDensity = atoi(value.c_str()); } else if ( key == "collapseSampledAncestors" ) { collapseSampledAncestors = value == "TRUE"; } else { std::cout << "Unknown user setting with key '" << key << "'." << std::endl; } if ( write == true ) { writeUserSettings(); } }
void RbSettings::setWorkingDirectory(const std::string &wd) { RevBayesCore::RbFileManager fm = RevBayesCore::RbFileManager( wd ); if ( !fm.isDirectory() ) { throw RbException("Cannot set the current directory to '" + wd + "'."); } workingDirectory = fm.getFullFilePath(); // save the current settings for the future. writeUserSettings(); }
void RbSettings::setModuleDir(const std::string &md) { RevBayesCore::RbFileManager fm = RevBayesCore::RbFileManager(md); if ( !fm.isDirectory() ) { throw RbException("Cannot set the help directory to '" + md + "'."); } moduleDir = fm.getFullFilePath(); // save the current settings for the future. writeUserSettings(); }
std::vector<double> RevBayesCore::operator/(const std::vector<double>& x, const std::vector<double>& y) { size_t n = x.size(); if ( n != y.size() ) { throw RbException("Can only divide vectors of same size!"); } std::vector<double> z(n,0); for (size_t i = 0; i < n; ++i) { z[i] = x[i] / y[i]; } return z; }
std::vector<int> RevBayesCore::operator*(const std::vector<int>& x, const std::vector<int>& y) { size_t n = x.size(); if ( n != y.size() ) { throw RbException("Can only multiply vectors of same size!"); } std::vector<int> z(n,0); for (size_t i = 0; i < n; ++i) { z[i] = x[i] * y[i]; } return z; }
void TraceTree::constructInternalObject( void ) { throw RbException("We do not support a constructor function for TraceTree."); }
RevLanguage::ParserInfo RevLanguage::Parser::breakIntoLines(const std::string& cmd, std::list<std::string>& lines, bool validate) const { bool inComment, inQuote; // Initialize lines.clear(); // just in case inComment = inQuote = false; std::stringstream buf(cmd); // a stream is convenient for reading // Process command buffer while (buf.good()) { std::stringstream temp; while (buf.good()) { char c = char( buf.get()); if (c == EOF && inQuote == true) { if (validate) { throw RbException("End of line while in quote"); } continue; } else if (c == '"') { /* switch quote on or off if not in comment */ if (inQuote == true) inQuote = false; else if (inComment == false) inQuote = true; } else if (c == '#' && inQuote == false) { /* we are now in comment */ inComment = true; } else if (c == ';' && inQuote == false && inComment == false) { /* break line here */ break; } else if (c == EOF && inQuote == false) { /* break line here */ break; } else if (c == '\n' && inQuote == false) { /* break line here */ break; } else if (c == '\377' && inQuote == false) { /* break line here */ // c = '\n'; continue; } else if (c == '\r' && inQuote == false) { /* break line here but first swallow any extra newline in DOS line ending */ char d = char( buf.peek()); if (d == '\n') c = char( buf.get()); break; } temp.put(c); } if (temp.str().size() > 0) { lines.push_back(temp.str() + "\n"); } } ParserInfo pi; pi.inComment = inComment; pi.inQuote = inQuote; pi.lines = lines; return pi; }