15 #include <boost/filesystem.hpp> 16 #include <boost/filesystem/fstream.hpp> 20 namespace particles_txt {
21 #include <particles.txt.h> 23 namespace decaymodes_txt {
24 #include <decaymodes.txt.h> 32 const char *particles_file,
const char *decaymodes_file) {
33 std::string particle_string, decay_string;
35 if (!boost::filesystem::exists(particles_file)) {
36 std::stringstream err;
37 err <<
"The particles file was expected at '" << particles_file
38 <<
"', but the file does not exist.";
39 throw std::runtime_error(err.str());
41 particle_string =
read_all(boost::filesystem::ifstream{particles_file});
43 std::stringstream err;
44 err <<
"The particles file has CR LF line endings. Please use LF" 46 throw std::runtime_error(err.str());
49 particle_string = particles_txt::data;
52 if (decaymodes_file) {
53 if (!boost::filesystem::exists(decaymodes_file)) {
54 std::stringstream err;
55 err <<
"The decay modes file was expected at '" << decaymodes_file
56 <<
"', but the file does not exist.";
57 throw std::runtime_error(err.str());
59 decay_string =
read_all(boost::filesystem::ifstream{decaymodes_file});
61 std::stringstream err;
62 err <<
"The decay mode file has CR LF line endings. Please use LF" 64 throw std::runtime_error(err.str());
67 decay_string = decaymodes_txt::data;
69 return std::make_pair(particle_string, decay_string);
74 ParticleType::create_type_list(pd.first);
75 DecayModes::load_decaymodes(pd.second);
76 ParticleType::check_consistency();
std::pair< std::string, std::string > load_particles_and_decaymodes(const char *particles_file, const char *decaymodes_file)
Loads particles and decaymodes from provided files particles_file and decaymodes_file.
bool has_crlf_line_ending(const std::string in)
Check if a line in the string ends with \r\n.
void load_default_particles_and_decaymodes()
Loads default smash particle list and decaymodes.
std::string read_all(std::istream &&input)
Utility function to read a complete input stream (e.g.