Libksieve

parsingutil.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #include "parsingutil.h"
8 #include "xmlprintingscriptbuilder.h"
9 #include <ksieve/parser.h>
10 using KSieve::Parser;
11 
12 #include <ksieve/error.h>
13 #include <ksieve/scriptbuilder.h>
14 
15 #include "libksieve_debug.h"
16 
17 using namespace KSieveUi;
18 
19 QString ParsingUtil::parseScript(const QString &scriptStr, bool &result)
20 {
21  const QByteArray script = scriptStr.toUtf8();
22 
23  KSieve::Parser parser(script.begin(), script.begin() + script.length());
24  KSieveUi::XMLPrintingScriptBuilder psb;
25  parser.setScriptBuilder(&psb);
26  if (parser.parse()) {
27  result = true;
28  return psb.result();
29  } else {
30  qCDebug(LIBKSIEVE_LOG) << "Impossible to parse file";
31  result = false;
32  }
33  return {};
34 }
int length() const const
QByteArray::iterator begin()
Parser for the Sieve grammar.
Definition: ksieve/parser.h:23
QByteArray toUtf8() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:09:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.