/** * @file dbc_parser.cpp * @brief * * Created: 2026-03-13 * Author: Deeaitch (Dim. Himro) * * Licensed under the MIT License. * See LICENSE file in the project root for full license text. */ #include "dbc_parser.h" #include "dbc_statement_handler.h" #include "text_utils.h" #include #include DbcDatabase DbcParser::ParseFile(const std::string &filePath) const { std::ifstream input(filePath.c_str()); if (!input.is_open()) throw std::runtime_error("Failed to open DBC file: " + filePath); DbcDatabase database; DbcParseContext context{database, nullptr}; const DbcStatementDispatcher dispatcher; std::size_t lineNumber = 0U; std::string line; while (std::getline(input, line)) { ++lineNumber; line = dbc_detail::TrimText(line); if (line.empty()) continue; try { context.lineNumber = lineNumber; dispatcher.Dispatch(line, context); } catch (const std::exception &error) { throw std::runtime_error(filePath + ":" + std::to_string(lineNumber) + ": " + error.what()); } } context.ResolveValueDescriptions(filePath); context.ValidateMultiplexing(filePath); return database; }