17 namespace particles_txt {
18 #include <particles.txt.h>
20 namespace decaymodes_txt {
21 #include <decaymodes.txt.h>
29 const std::filesystem::path &particles_file,
30 const std::filesystem::path &decaymodes_file) {
31 std::string particle_string, decay_string;
32 if (!particles_file.empty()) {
33 if (!std::filesystem::exists(particles_file)) {
34 std::stringstream err;
35 err <<
"The particles file was expected at '" << particles_file
36 <<
"', but the file does not exist.";
37 throw std::runtime_error(err.str());
39 particle_string =
read_all(std::ifstream{particles_file});
41 std::stringstream err;
42 err <<
"The particles file has CR LF line endings. Please use LF"
44 throw std::runtime_error(err.str());
47 particle_string = particles_txt::data;
50 if (!decaymodes_file.empty()) {
51 if (!std::filesystem::exists(decaymodes_file)) {
52 std::stringstream err;
53 err <<
"The decay modes file was expected at '" << decaymodes_file
54 <<
"', but the file does not exist.";
55 throw std::runtime_error(err.str());
57 decay_string =
read_all(std::ifstream{decaymodes_file});
59 std::stringstream err;
60 err <<
"The decay mode file has CR LF line endings. Please use LF"
62 throw std::runtime_error(err.str());
65 decay_string = decaymodes_txt::data;
67 return std::make_pair(particle_string, decay_string);
static void load_decaymodes(const std::string &input)
Loads the DecayModes map as described in the input string.
static void check_consistency()
static void create_type_list(const std::string &particles)
Initialize the global ParticleType list (list_all) from the given input data.
void initialize_default_particles_and_decaymodes()
Loads default smash particle list and decaymodes.
std::pair< std::string, std::string > load_particles_and_decaymodes(const std::filesystem::path &particles_file, const std::filesystem::path &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.
std::string read_all(std::istream &&input)
Utility function to read a complete input stream (e.g.