KItinerary

jsapi/extractorengine.h
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef KITINERARY_JSAPI_EXTRACTORENGINE_H
7#define KITINERARY_JSAPI_EXTRACTORENGINE_H
8
9#include <KItinerary/ExtractorDocumentNode>
10#include <KItinerary/ExtractorEngine>
11
12namespace KItinerary {
13
14/** JavaScript API available to extractor scripts. */
15namespace JsApi {
16
17/** API to access the extractor engine for JS extractor scripts. */
19{
21public:
22 ///@cond internal
23 explicit ExtractorEngine(QObject *parent = nullptr);
25
26 void setEngine(KItinerary::ExtractorEngine *engine);
27 void setCurrentNode(const ExtractorDocumentNode &node);
28 void clear();
29 ///@endcond
30
31 /** Run the extractor on @p data.
32 * Use this if the data to extract needs to be decoded by an extractor script first
33 * and is available as raw byte array.
34 * You do not need to call this for document parts that the extractor recognizes itself.
35 *
36 * A new document node for @p data is added below the node currently processed,
37 * and that node is returned.
38 *
39 * @see KItinerary::ExtractorEngine
40 */
42 /** Run the extractor on @p content of type @p mimeType.
43 * Use this if the data to extract needs to be decoded by an extractor script first
44 * and is available already in decoded form in a suitable data type.
45 * You do not need to call this for document parts that the extractor recognizes itself.
46 *
47 * A new document node for @p data is added below the node currently processed,
48 * and that node is returned.
49 *
50 * @see KItinerary::ExtractorEngine
51 */
53
54 /** Run the generic price information extractor to @p text and apply the found
55 * price value and currency to @p result, if any.
56 * @param result Can be a single object or and array.
57 */
58 Q_INVOKABLE void extractPrice(const QString &text, QJSValue result) const;
59
60private:
61 KItinerary::ExtractorEngine *m_engine = nullptr;
63 int m_recursionDepth = 0;
64};
65
66}
67}
68
69#endif // KITINERARY_JSAPI_EXTRACTORENGINE_H
A node in the extracted document object tree.
Semantic data extraction engine.
API to access the extractor engine for JS extractor scripts.
Q_INVOKABLE void extractPrice(const QString &text, QJSValue result) const
Run the generic price information extractor to text and apply the found price value and currency to r...
Q_INVOKABLE KItinerary::ExtractorDocumentNode extract(const QByteArray &data)
Run the extractor on data.
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:00:25 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.