MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / parse_mod_config

Function parse_mod_config

RecompModTool/main.cpp:431–473  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

429}
430
431ModConfig parse_mod_config(const std::filesystem::path& config_path, bool& good) {
432 ModConfig ret{};
433 good = false;
434
435 toml::table toml_data{};
436
437 try {
438 toml_data = toml::parse_file(config_path.native());
439 std::filesystem::path basedir = config_path.parent_path();
440
441 // Find the manifest section and validate its type.
442 const toml::node* manifest_data_ptr = toml_data.get("manifest");
443 if (manifest_data_ptr == nullptr) {
444 throw toml::parse_error("Mod toml is missing manifest section", toml::source_region{});
445 }
446 if (!manifest_data_ptr->is_table()) {
447 throw toml::parse_error("Incorrect type for mod toml manifest section", manifest_data_ptr->source());
448 }
449 const toml::table& manifest_table = *manifest_data_ptr->as_table();
450
451 // Find the inputs section and validate its type.
452 const toml::node* inputs_data_ptr = toml_data.get("inputs");
453 if (inputs_data_ptr == nullptr) {
454 throw toml::parse_error("Mod toml is missing inputs section", toml::source_region{});
455 }
456 if (!inputs_data_ptr->is_table()) {
457 throw toml::parse_error("Incorrect type for mod toml inputs section", inputs_data_ptr->source());
458 }
459 const toml::table& inputs_table = *inputs_data_ptr->as_table();
460
461 // Parse the manifest.
462 ret.manifest = parse_mod_config_manifest(basedir, manifest_table);
463 // Parse the inputs.
464 ret.inputs = parse_mod_config_inputs(basedir, inputs_table);
465 }
466 catch (const toml::parse_error& err) {
467 std::cerr << "Syntax error parsing toml: " << config_path << " (" << err.source().begin << "):\n" << err.description() << std::endl;
468 return {};
469 }
470
471 good = true;
472 return ret;
473}
474
475static inline uint32_t round_up_16(uint32_t value) {
476 return (value + 15) & (~15);

Callers 1

mainFunction · 0.85

Calls 2

parse_mod_config_inputsFunction · 0.85

Tested by

no test coverage detected