void OpenSMOKE_CHEMKINInterpreter_UnitsData::Parse_Units(const std::string units_string) { int i; bool success = false; for(i=1;i<=int(energy_units.size())-1;i++) if (caseInsCompare(units_string, energy_units[i]) == true) { if (iCurrentEnergy == true) ErrorMessage("Activation energy UNITS for all the reactions are assigned more than once"); iCurrentEnergy = true; current_energy = energy_units[i]; success = true; break; } for(i=1;i<=int(frequency_factor_units.size())-1;i++) if (caseInsCompare(units_string, frequency_factor_units[i]) == true) { if (iCurrentFrequencyFactor == true) ErrorMessage("Frequency factor UNITS for all the reactions are assigned more than once"); iCurrentFrequencyFactor = true; current_frequency_factor = frequency_factor_units[i]; success = true; break; } if (success == false) { std::string units_modified = units_string; StringSubstitutionAll(units_modified, "#", "-"); ErrorMessage("The " + units_modified + " units are not allowed"); } }
void OpenSMOKE_CHEMKINInterpreter_ThermoData::GiveMeMolecularWeights(BzzVectorInt &indices, OpenSMOKE_CHEMKINInterpreter_ElementsData &elements) { int i; BzzVector mw_elements(elements.elements_in_list_indices.size()-1); for(i=1;i<=int(elements.elements_in_list.size())-1;i++) mw_elements[i] = elements.elements_mw[elements.elements_in_list_indices[i]]; BzzVector mw_isotope(elements.isotope_in_list.size()-1); for(i=1;i<=int(elements.isotope_in_list.size())-1;i++) mw_isotope[i] = elements.isotope_mw_in_list[i]; for(int j=1;j<=indices.Size();j++) { int h = indices[j]; ChangeDimensions(elements.elements_in_list.size()-1, &species[h].element_indices); ChangeDimensions(elements.isotope_in_list.size()-1, &species[h].isotope_indices); for(int k=1;k<=int(species[h].element_names.size())-1;k++) { int i; bool jFound = false; for(i=1;i<=int(elements.elements_in_list.size())-1;i++) if (caseInsCompare(species[h].element_names[k], elements.elements_in_list[i])==true) { jFound = true; species[h].element_indices[i] = species[h].element_numbers[k]; break; } if (jFound == false) { for(i=1;i<=int(elements.isotope_in_list.size())-1;i++) if (caseInsCompare(species[h].element_names[k], elements.isotope_in_list[i])==true) { jFound = true; species[h].isotope_indices[i] = species[h].element_numbers[k]; break; } } if (jFound == false) { for (int kk=0;kk<=species[h].element_names.size()-1;kk++) cout << kk << species[h].element_names[k] << endl; cout << species[h].name << endl; ErrorMessage("The " + species[h].element_names[k] + " element is not available in the database"); } } species[h].mw = Dot(species[h].element_indices, mw_elements); species[h].mw += Dot(species[h].isotope_indices, mw_isotope); } }
Cookie::Cookie(const std::string& name, const std::string& value, const std::vector<std::string>& options) : Cookie{name, value} { // Check that the vector has an even number of elements (key, value) if(options.size() % 2 not_eq 0) throw CookieException{"Invalid number of elements in cookie's options vector!"}; // for-loop on vector - set input values from vector: for(size_t i = 0; i < options.size(); i += 2) { std::string nm = options[i]; if(not valid_option_name(nm)) throw CookieException{"Invalid name (" + nm + ") of cookie option!"}; std::string val = options[i+1]; if(caseInsCompare(nm, C_EXPIRES)) { set_expires(val); } else if(caseInsCompare(nm, C_MAX_AGE)) { try { int age = std::stoi(val); if(age < 0) throw CookieException{"Invalid max-age attribute (" + val + ") of cookie! Negative number of seconds not allowed."}; set_max_age(age); } catch(std::exception& e){ throw CookieException{"Invalid max-age attribute (" + val + ") of cookie! Invalid integer value."}; } } else if(caseInsCompare(nm, C_DOMAIN)) { set_domain(val); } else if(caseInsCompare(nm, C_PATH)) { set_path(val); } else if(caseInsCompare(nm, C_SECURE)) { bool s = (caseInsCompare(val, "true")) ? true : false; set_secure(s); } else if(caseInsCompare(nm, C_HTTP_ONLY)) { bool s = (caseInsCompare(val, "true")) ? true : false; set_http_only(s); } } }
BzzVectorInt OpenSMOKE_CHEMKINInterpreter_ThermoData::GiveMeSpeciesIndices(vector<string> &list) { BzzVectorInt indices(list.size()-1); for(int j=1;j<=int(list.size())-1;j++) { bool jFound = false; for(int i=1;i<=total_number_of_species;i++) if ( caseInsCompare(species[i].name, list[j]) == true) { jFound = true; indices[j] = i; break; } if (jFound == false) { // indices[j] = 1;//TODO // break; ErrorMessage("The " + list[j] + " species is not available in the thermodynamics database"); } } return indices; }
std::string filesStore(const char* filename, const char *path, char *env) { std::string dirname; std::string rootDir; vector<std::string> files = vector<std::string > (); string inventory[3] = {"", "/usr", "/opt/glite"}; std::string xmlfile; size_t found; try { if (env == NULL) { for (int i = 0; i < 3; ++i) { dirname = inventory[i]; dirname = dirname + path; rootDir = std::string(dirname); getdir(rootDir, files); const std::string fname = filename; if(true == caseInsCompare(fname, CFG_FILE_NAME)){ std::string fullPath = CFG_FILE_PATH + CFG_FILE_NAME; if(0 == fexists(fullPath.c_str())){ return fullPath; } else{ logger::writeMsgNoConfig("/etc/fts3/fts-msg-monitoring.conf configuration file cannot be found"); } } else{ for (unsigned int i = 0; i < files.size(); i++) { xmlfile = files[i]; found = xmlfile.find(filename); if (found != std::string::npos) { return dirname + xmlfile; } } } } } else { dirname = env; dirname = dirname + path; rootDir = std::string(dirname); getdir(rootDir, files); for (unsigned int i = 0; i < files.size(); i++) { xmlfile = files[i]; found = xmlfile.find(filename); if (found != std::string::npos) { return dirname + xmlfile; } } for (int i = 0; i < 3; ++i) { dirname = inventory[i]; dirname = dirname + path; rootDir = std::string(dirname); getdir(rootDir, files); for (unsigned int i = 0; i < files.size(); i++) { xmlfile = files[i]; found = xmlfile.find(filename); if (found!=string::npos) { return dirname + xmlfile; } } } } return ""; } catch (...) { logger::writeLog("Configuration file cannot be found", true); return ""; } }
bool Cookie::valid_option_name(const std::string& option_name) const { return caseInsCompare(option_name, C_EXPIRES) || caseInsCompare(option_name, C_MAX_AGE) || caseInsCompare(option_name, C_DOMAIN) || caseInsCompare(option_name, C_PATH) || caseInsCompare(option_name, C_SECURE) || caseInsCompare(option_name, C_HTTP_ONLY); }