Libksieve

parsingutil.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "parsingutil.h"
8#include "parser.h"
9#include "xmlprintingscriptbuilder.h"
10using KSieve::Parser;
11
12#include "scriptbuilder.h"
13
14#include "libksievecore_debug.h"
15
16using namespace KSieveCore;
17
18QString ParsingUtil::parseScript(const QString &scriptStr, bool &result)
19{
20 const QByteArray script = scriptStr.toUtf8();
21
22 KSieve::Parser parser(script.begin(), script.begin() + script.length());
23 KSieveCore::XMLPrintingScriptBuilder psb;
24 parser.setScriptBuilder(&psb);
25 if (parser.parse()) {
26 result = true;
27 return psb.result();
28 } else {
29 qCDebug(LIBKSIEVECORE_LOG) << "Impossible to parse file";
30 result = false;
31 }
32 return {};
33}
Parser for the Sieve grammar.
Definition parser.h:24
iterator begin()
qsizetype length() const const
QByteArray toUtf8() const const
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.