PorygonLang/src/Diagnostics/Diagnostic.hpp

65 lines
1.6 KiB
C++

#ifndef PORYGONLANG_DIAGNOSTIC_HPP
#define PORYGONLANG_DIAGNOSTIC_HPP
#include <utility>
#include <vector>
#include <string>
#include "DiagnosticSeverity.hpp"
#include "DiagnosticCode.hpp"
namespace Porygon::Diagnostics {
class Diagnostic {
DiagnosticSeverity _severity;
DiagnosticCode _code;
unsigned int _start;
unsigned int _length;
std::vector<std::string> _arguments;
std::string* _message;
public:
Diagnostic(DiagnosticSeverity severity, DiagnosticCode code, unsigned int start, unsigned int length, std::vector<std::string> arguments)
: _severity(severity), _code(code), _start(start), _length(length), _arguments(std::move(arguments)), _message(
nullptr)
{
}
~Diagnostic(){
delete _message;
}
[[nodiscard]]
inline DiagnosticSeverity GetSeverity() {
return _severity;
}
[[nodiscard]]
inline DiagnosticCode GetCode() {
return _code;
}
[[nodiscard]]
inline unsigned int GetStartPosition() {
return _start;
}
[[nodiscard]]
inline unsigned int GetLength() {
return _length;
}
[[nodiscard]]
inline std::vector<std::string> GetArguments(){
return _arguments;
}
inline void SetMessage(std::string* s){
this -> _message = s;
}
[[nodiscard]]
inline std::string* GetMessage(){
return _message;
}
};
}
#endif //PORYGONLANG_DIAGNOSTIC_HPP