Libksieve

ksieve/lexer.h
1 /* -*- c++ -*-
2  ksieve/lexer.h
3 
4  This file is part of KSieve,
5  the KDE internet mail/usenet news message filtering library.
6  Copyright (c) 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_LEXER_H
34 #define KSIEVE_KSIEVE_LEXER_H
35 
36 #include "ksieve_export.h"
37 
38 class QString;
39 
40 namespace KSieve {
41 class Error;
42 
43 class KSIEVE_EXPORT Lexer
44 {
45 public:
46  enum Options {
47  IncludeComments = 0,
48  IgnoreComments = 1,
49  IncludeLineFeeds = 0,
50  IgnoreLineFeeds = 2
51  };
52 
53  Lexer(const char *scursor, const char *send, int options = 0);
54  ~Lexer();
55 
63  bool ignoreComments() const;
64 
71  bool ignoreLineFeeds() const;
72 
73  const Error &error() const;
74 
75  bool atEnd() const;
76  int column() const;
77  int line() const;
78 
79  enum Token {
80  None = 0,
81  Number, // 1, 100, 1M, 10k, 1G, 2g, 3m
82  Identifier, // atom
83  Tag, // :tag
84  Special, // {} [] () ,;
85  QuotedString, // "foo\"bar" -> foo"bar
86  MultiLineString, // text: \nfoo\n. -> foo
87  HashComment, // # foo
88  BracketComment, // /* foo */
89  LineFeeds // the number of line feeds encountered
90  };
91 
94  Token nextToken(QString &result);
95 
96  void save();
97  void restore();
98 
99  class Impl;
100 private:
101  Impl *i = nullptr;
102 
103 private:
104  const Lexer &operator=(const Lexer &);
105  Lexer(const Lexer &);
106 };
107 } // namespace KSieve
108 
109 #endif
QFlags< Option > Options
void error(QWidget *parent, const QString &text, const QString &caption=QString(), Options options=Notify)
const QList< QKeySequence > & save()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Jul 9 2020 23:07:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.