VapourSynth-llvmexpr
Loading...
Searching...
No Matches
AnalysisError.hpp
Go to the documentation of this file.
1
19
20#ifndef LLVMEXPR_ANALYSIS_FRAMEWORK_ANALYSIS_ERROR_HPP
21#define LLVMEXPR_ANALYSIS_FRAMEWORK_ANALYSIS_ERROR_HPP
22
23#include <optional>
24#include <stdexcept>
25#include <string>
26#include <string_view>
27
28namespace analysis {
29
30class AnalysisError : public std::runtime_error {
31 public:
32 explicit AnalysisError(const std::string& message)
33 : std::runtime_error(message) {}
34
35 AnalysisError(const std::string& message, int token_idx)
36 : std::runtime_error(message), token_idx(token_idx) {}
37
38 AnalysisError(const std::string& message, int token_idx,
39 std::string_view token_text)
40 : std::runtime_error(message), token_idx(token_idx),
41 token_text(token_text) {}
42
43 [[nodiscard]] std::optional<int> getTokenIndex() const {
44 return token_idx;
45 }
46
47 [[nodiscard]] std::optional<std::string> getTokenText() const {
48 return token_text;
49 }
50
51 private:
52 std::optional<int> token_idx;
53 std::optional<std::string> token_text;
54};
55
56} // namespace analysis
57
58#endif // LLVMEXPR_ANALYSIS_FRAMEWORK_ANALYSIS_ERROR_HPP
AnalysisError(const std::string &message)
std::optional< std::string > getTokenText() const
AnalysisError(const std::string &message, int token_idx, std::string_view token_text)
AnalysisError(const std::string &message, int token_idx)
std::optional< int > getTokenIndex() const