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  Copyright (c) 2002-2003 Marc Mutz <[email protected]>
7 
8  KSieve is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License, version 2, as
10  published by the Free Software Foundation.
11 
12  KSieve is distributed in the hope that it will be useful, but
13  WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  In addition, as a special exception, the copyright holders give
22  permission to link the code of this program with any edition of
23  the Qt library by Trolltech AS, Norway (or with modified versions
24  of Qt that use the same license as Qt), and distribute linked
25  combinations including the two. You must obey the GNU General
26  Public License in all respects for all of the code used other than
27  Qt. If you modify this file, you may extend this exception to
28  your version of the file, but you are not obligated to do so. If
29  you do not wish to do so, delete this exception statement from
30  your version.
31 */
32 
33 #ifndef KSIEVE_KSIEVE_ERROR_H
34 #define KSIEVE_KSIEVE_ERROR_H
35 
36 #include "ksieve_export.h"
37 
38 #include <QString>
39 
40 #ifdef None // X headers
41 # undef None
42 #endif
43 
44 namespace KSieve {
45 class KSIEVE_EXPORT Error
46 {
47 public:
48  enum Type {
49  None = 0,
50  Custom,
51  // parse (well-formedness in XML speak) errors:
52  FirstParseError,
53 
54  CRWithoutLF = FirstParseError,
55  SlashWithoutAsterisk,
56  IllegalCharacter,
57  UnexpectedCharacter,
58  NoLeadingDigits,
59  NonCWSAfterTextColon,
60 
61  NumberOutOfRange,
62  InvalidUTF8,
63 
64  UnfinishedBracketComment,
65  PrematureEndOfMultiLine,
66  PrematureEndOfQuotedString,
67  PrematureEndOfStringList,
68  PrematureEndOfTestList,
69  PrematureEndOfBlock,
70  MissingWhitespace,
71  MissingSemicolonOrBlock,
72 
73  ExpectedBlockOrSemicolon,
74  ExpectedCommand,
75  ConsecutiveCommasInStringList,
76  ConsecutiveCommasInTestList,
77  MissingCommaInTestList,
78  MissingCommaInStringList,
79  NonStringInStringList,
80  NonCommandInCommandList,
81  NonTestInTestList,
82  LastParseError = NonTestInTestList,
83  // validity errors:
84  FirstValidityError,
85  RequireNotFirst = FirstValidityError, // rfc3028, 3.2
86  RequireMissingForCommand,
87  RequireMissingForTest,
88  RequireMissingForComparator,
89  UnsupportedCommand,
90  UnsupportedTest,
91  UnsupportedComparator,
92  TestNestingTooDeep, // site policy
93  BlockNestingTooDeep, // site policy
94  InvalidArgument,
95  ConflictingArguments, // e.g. rfc3028, 2.7.{1,3}
96  ArgumentsRepeated, // similar to ConflictingArguments, e.g. :is :is
97  CommandOrderingConstraintViolation, // e.g. else w/o if, rfc3028, 3.1
98  LastValidityError = CommandOrderingConstraintViolation,
99  // runtime errors:
100  FirstRuntimeError,
101  IncompatibleActionsRequested = FirstRuntimeError,
102  MailLoopDetected,
103  TooManyActions,
104  LastRuntimeError = TooManyActions
105  };
106 
107  static const char *typeToString(Type type);
108 
109  Error(Type type = None, const QString &s1 = QString(), const QString &s2 = QString(), int line = -1, int col = -1)
110  : mType(type)
111  , mLine(line)
112  , mCol(col)
113  , mStringOne(s1)
114  , mStringTwo(s2)
115  {
116  }
117 
118  Error(Type type, int line, int col)
119  : mType(type)
120  , mLine(line)
121  , mCol(col)
122  {
123  }
124 
125  QString asString() const;
126 
128  operator bool() const
129  {
130  return type() != None;
131  }
132 
133  Type type() const
134  {
135  return mType;
136  }
137 
138  int line() const
139  {
140  return mLine;
141  }
142 
143  int column() const
144  {
145  return mCol;
146  }
147 
148  QString firstString() const
149  {
150  return mStringOne;
151  }
152 
153  QString secondString() const
154  {
155  return mStringTwo;
156  }
157 
158 protected:
159  Type mType;
160  int mLine;
161  int mCol;
162  QString mStringOne, mStringTwo;
163 };
164 } // namespace KSieve
165 
166 #endif
Type type(const QSqlDatabase &db)
QString typeToString(Type type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:09:19 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.