#ifndef PORYGONLANG_DIAGNOSTICS_HPP #define PORYGONLANG_DIAGNOSTICS_HPP #include #include "DiagnosticSeverity.hpp" #include "DiagnosticCode.hpp" #include "Diagnostic.hpp" using namespace std; class Diagnostics { bool _hasErrors; vector _diagnostics; public: Diagnostics(){ _hasErrors = false; } ~Diagnostics(){ _diagnostics.clear(); } void Log(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length){ _diagnostics.emplace_back(severity, code, start, length); if (severity >= DiagnosticSeverity::Error){ _hasErrors = true; } } void LogError(DiagnosticCode code, unsigned int start, unsigned int length){ Log(DiagnosticSeverity::Error, code, start, length); } void LogWarning(DiagnosticCode code, unsigned int start, unsigned int length){ Log(DiagnosticSeverity::Warning, code, start, length); } void LogInfo(DiagnosticCode code, unsigned int start, unsigned int length){ Log(DiagnosticSeverity::Info, code, start, length); } bool HasErrors(){ return _hasErrors; } vector GetDiagnostics(){ return _diagnostics; } }; #endif //PORYGONLANG_DIAGNOSTICS_HPP