digiKam
parser.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2009-08-11
7  * Description : the main parser object for the AdvancedRename utility
8  *
9  * Copyright (C) 2009-2012 by Andi Clemens <andi dot clemens at gmail dot com>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_PARSER_H
25 #define DIGIKAM_PARSER_H
26 
27 // Qt includes
28 
29 #include <QList>
30 #include <QMap>
31 #include <QString>
32 
33 // Local includes
34 
35 #include "modifier.h"
36 #include "option.h"
37 
38 namespace Digikam
39 {
40 
41 class Modifier;
42 class Option;
43 
44 class Parser
45 {
46 
47 public:
48 
49  explicit Parser();
50  virtual ~Parser();
51 
52  void reset();
53 
54  QString parse(ParseSettings& settings);
55 
56  RulesList options() const;
57  RulesList modifiers() const;
58 
59  bool tokenAtPosition(ParseSettings& settings, int pos);
60  bool tokenAtPosition(ParseSettings& settings, int pos, int& start, int& length);
61 
63 
69  static bool parseStringIsValid(const QString& str);
70 
71 protected:
72 
73  void registerOption(Rule* option);
74  void unregisterOption(Rule* option);
75 
76  void registerModifier(Rule* modifier);
77  void unregisterModifier(Rule* modifier);
78 
79 private:
80 
81  ParseResults results(ParseSettings& settings);
82 
89  ParseResults applyModifiers(const ParseSettings& _settings, ParseResults& results);
90 
91 private:
92 
93  // Disable
94  Parser(const Parser&) = delete;
95  Parser& operator=(const Parser&) = delete;
96 
97 private:
98 
99  class Private;
100  Private* const d;
101 };
102 
103 } // namespace Digikam
104 
105 #endif // DIGIKAM_PARSER_H
Definition: parseresults.h:37
Definition: parsesettings.h:43
Definition: parser.h:45
virtual ~Parser()
Definition: parser.cpp:87
void reset()
Definition: parser.cpp:98
RulesList modifiers() const
Definition: parser.cpp:122
void unregisterOption(Rule *option)
Definition: parser.cpp:137
void registerModifier(Rule *modifier)
Definition: parser.cpp:159
bool tokenAtPosition(ParseSettings &settings, int pos)
Definition: parser.cpp:258
void unregisterModifier(Rule *modifier)
Definition: parser.cpp:169
static bool parseStringIsValid(const QString &str)
Definition: parser.cpp:111
ParseResults invalidModifiers(ParseSettings &settings)
Definition: parser.cpp:210
void registerOption(Rule *option)
Definition: parser.cpp:127
Parser()
Definition: parser.cpp:65
RulesList options() const
Definition: parser.cpp:117
QString parse(ParseSettings &settings)
Definition: parser.cpp:217
Definition: rule.h:42
Definition: datefolderview.cpp:43