blob: bd4462d2cadc84b97d5d12a4af7f8f48253d2389 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#ifndef PARSERERROR_H
#define PARSERERROR_H
#include "coreSQLiteStudio_global.h"
#include "parser/token.h"
#include <QString>
/**
* @brief Class representing error during SQL parsing.
*
* It provides error message and position at which the error occurred.
*/
class API_EXPORT ParserError
{
public:
/**
* @brief Creates error for given token and message.
* @param token Token that the error occurred at.
* @param text Error message.
*/
ParserError(TokenPtr token, const QString& text);
/**
* @brief Creates error with given range and message.
* @param start Position where the error starts.
* @param end Position where the error ends.
* @param text Error message.
*/
ParserError(qint64 start, qint64 end, const QString& text);
/**
* @brief Creates global error with given message.
* @param text Error message.
*
* Global errors are not related to any token or position.
*/
explicit ParserError(const QString& text);
/**
* @brief Provides error message.
* @return Error message.
*/
QString& getMessage();
/**
* @brief Provides start position of the error.
* @return Character position, or -1 if the error is not related to any position (global error).
*/
qint64 getFrom();
/**
* @brief Provides end position of the error.
* @return Character position, or -1 if the error is not related to any position (global error).
*/
qint64 getTo();
/**
* @brief Serializes error to readable string.
* @return Start position and error message in form: <tt>"position: message"</tt>.
*/
QString toString();
private:
/**
* @brief Error message.
*/
QString message = QString();
/**
* @brief Error start position.
*/
qint64 start = -1;
/**
* @brief Error end position.
*/
qint64 end = -1;
};
#endif // PARSERERROR_H
|