Libksieve

error.h
1/* -*- c++ -*-
2 ksieve/error.h
3
4 This file is part of KSieve,
5 the KDE internet mail/usenet news message filtering library.
6 SPDX-FileCopyrightText: 2002-2003 Marc Mutz <mutz@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-only
9*/
10
11#pragma once
12
13#include "ksieve_export.h"
14
15#include <QString>
16
17#ifdef None // X headers
18#undef None
19#endif
20
21namespace KSieve
22{
23class KSIEVE_EXPORT Error
24{
25public:
26 enum Type {
27 None = 0,
28 Custom,
29 // parse (well-formedness in XML speak) errors:
30 FirstParseError,
31
32 CRWithoutLF = FirstParseError,
33 SlashWithoutAsterisk,
34 IllegalCharacter,
35 UnexpectedCharacter,
36 NoLeadingDigits,
37 NonCWSAfterTextColon,
38
39 NumberOutOfRange,
40 InvalidUTF8,
41
42 UnfinishedBracketComment,
43 PrematureEndOfMultiLine,
44 PrematureEndOfQuotedString,
45 PrematureEndOfStringList,
46 PrematureEndOfTestList,
47 PrematureEndOfBlock,
48 MissingWhitespace,
49 MissingSemicolonOrBlock,
50
51 ExpectedBlockOrSemicolon,
52 ExpectedCommand,
53 ConsecutiveCommasInStringList,
54 ConsecutiveCommasInTestList,
55 MissingCommaInTestList,
56 MissingCommaInStringList,
57 NonStringInStringList,
58 NonCommandInCommandList,
59 NonTestInTestList,
60 LastParseError = NonTestInTestList,
61 // validity errors:
62 FirstValidityError,
63 RequireNotFirst = FirstValidityError, // rfc3028, 3.2
64 RequireMissingForCommand,
65 RequireMissingForTest,
66 RequireMissingForComparator,
67 UnsupportedCommand,
68 UnsupportedTest,
69 UnsupportedComparator,
70 TestNestingTooDeep, // site policy
71 BlockNestingTooDeep, // site policy
72 InvalidArgument,
73 ConflictingArguments, // e.g. rfc3028, 2.7.{1,3}
74 ArgumentsRepeated, // similar to ConflictingArguments, e.g. :is :is
75 CommandOrderingConstraintViolation, // e.g. else w/o if, rfc3028, 3.1
76 LastValidityError = CommandOrderingConstraintViolation,
77 // runtime errors:
78 FirstRuntimeError,
79 IncompatibleActionsRequested = FirstRuntimeError,
80 MailLoopDetected,
81 TooManyActions,
82 LastRuntimeError = TooManyActions
83 };
84
85 static const char *typeToString(Type type);
86
87 Error(Type type = None, const QString &s1 = QString(), const QString &s2 = QString(), int line = -1, int col = -1)
88 : mType(type)
89 , mLine(line)
90 , mCol(col)
91 , mStringOne(s1)
92 , mStringTwo(s2)
93 {
94 }
95
96 Error(Type type, int line, int col)
97 : mType(type)
98 , mLine(line)
99 , mCol(col)
100 {
101 }
102
103 QString asString() const;
104
105 /** So you can write <pre>if ( error() )</pre> with e.g. @ref Lexer */
106 operator bool() const
107 {
108 return type() != None;
109 }
110
111 Type type() const
112 {
113 return mType;
114 }
115
116 int line() const
117 {
118 return mLine;
119 }
120
121 int column() const
122 {
123 return mCol;
124 }
125
126 QString firstString() const
127 {
128 return mStringOne;
129 }
130
131 QString secondString() const
132 {
133 return mStringTwo;
134 }
135
136protected:
137 Type mType;
138 int mLine;
139 int mCol;
140 QString mStringOne, mStringTwo;
141};
142} // namespace KSieve
Type type(const QSqlDatabase &db)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:19 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.