59 lines
1.6 KiB
C++
59 lines
1.6 KiB
C++
/**
|
|
* @file dbc_parser.h
|
|
* @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.
|
|
*/
|
|
|
|
#ifndef DBC_PARSER_H
|
|
#define DBC_PARSER_H
|
|
|
|
#include <string>
|
|
|
|
#include "dbc_diagnostic.h"
|
|
|
|
/**
|
|
* @brief Minimal DBC parser.
|
|
*
|
|
* Supports:
|
|
* - BO_
|
|
* - SG_
|
|
* - CM_ BO_
|
|
* - CM_ SG_
|
|
* - basic M / mN multiplexing
|
|
* - VAL_ signal value descriptions
|
|
*
|
|
* Frame/signal comments support multiline quoted text and deferred references.
|
|
*
|
|
* Reports unsupported statements as warnings, except SG_MUL_VAL_ which is
|
|
* an error. VERSION, NS_, BS_, BU_ and NS_ symbol declarations stay quiet.
|
|
*/
|
|
class DbcParser {
|
|
public:
|
|
/**
|
|
* @brief Parse DBC file.
|
|
* @param filePath Path to input file.
|
|
* @return Parsed database.
|
|
* @throws std::runtime_error on file or parse errors.
|
|
* Line parse errors include the file path and one-based line number.
|
|
* Duplicate normalized CAN IDs of the same frame type and duplicate signal
|
|
* names within a frame are rejected at the repeated definition's line.
|
|
*/
|
|
DbcDatabase ParseFile(const std::string &filePath) const;
|
|
|
|
/**
|
|
* @brief Parse with warnings and a structured first error instead of throwing.
|
|
* @return Valid database with diagnostics; empty database on error.
|
|
* File errors use line zero; statement errors use physical one-based lines.
|
|
* Warnings indicate ignored syntax and possible incomplete decoding.
|
|
*/
|
|
DbcParseResult ParseFileWithDiagnostics(const std::string &filePath) const;
|
|
|
|
};
|
|
|
|
#endif /* DBC_PARSER_H */
|