47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
// SPDX-License-Identifier: MIT
|
|
#ifndef DBC_DIAGNOSTIC_H
|
|
#define DBC_DIAGNOSTIC_H
|
|
|
|
#include "dbc_database.h"
|
|
#include <cstddef>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
enum class DbcDiagnosticSeverity {
|
|
Warning,
|
|
Error
|
|
};
|
|
|
|
/** Stable categories; messages provide the details. */
|
|
enum class DbcDiagnosticCode {
|
|
FileOpenError,
|
|
FileReadError,
|
|
InvalidStatement,
|
|
InvalidValueDescription,
|
|
InvalidMultiplexing,
|
|
UnsupportedStatement
|
|
};
|
|
|
|
struct DbcDiagnostic {
|
|
DbcDiagnosticSeverity severity;
|
|
DbcDiagnosticCode code;
|
|
std::string filePath;
|
|
std::size_t lineNumber; // One-based physical line; zero for file-level errors.
|
|
std::string message;
|
|
};
|
|
|
|
struct DbcParseResult {
|
|
DbcDatabase database;
|
|
std::vector<DbcDiagnostic> diagnostics;
|
|
|
|
bool HasErrors() const {
|
|
for (const DbcDiagnostic &diagnostic : diagnostics) {
|
|
if (diagnostic.severity == DbcDiagnosticSeverity::Error)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
#endif /* DBC_DIAGNOSTIC_H */
|