refactor: extract core domain dof modules
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "fesa/Core/Types.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace fesa {
|
||||
|
||||
enum class Severity { Info, Warning, Error };
|
||||
|
||||
struct SourceLocation {
|
||||
std::string file;
|
||||
LocalIndex line = 0;
|
||||
std::string keyword;
|
||||
};
|
||||
|
||||
struct Diagnostic {
|
||||
Severity severity = Severity::Error;
|
||||
std::string code;
|
||||
std::string message;
|
||||
SourceLocation source;
|
||||
};
|
||||
|
||||
inline bool hasError(const std::vector<Diagnostic>& diagnostics) {
|
||||
return std::any_of(diagnostics.begin(), diagnostics.end(), [](const Diagnostic& diagnostic) {
|
||||
return diagnostic.severity == Severity::Error;
|
||||
});
|
||||
}
|
||||
|
||||
inline bool containsDiagnostic(const std::vector<Diagnostic>& diagnostics, const std::string& code) {
|
||||
return std::any_of(diagnostics.begin(), diagnostics.end(), [&](const Diagnostic& diagnostic) {
|
||||
return diagnostic.code == code;
|
||||
});
|
||||
}
|
||||
|
||||
inline Diagnostic makeDiagnostic(Severity severity, std::string code, std::string message, std::string keyword,
|
||||
std::string file = "<domain>", LocalIndex line = 0) {
|
||||
return {severity, std::move(code), std::move(message), {std::move(file), line, std::move(keyword)}};
|
||||
}
|
||||
|
||||
} // namespace fesa
|
||||
Reference in New Issue
Block a user