KItinerary

extractorvalidator.h
1/*
2 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "kitinerary_export.h"
10
11#include <memory>
12#include <vector>
13
14struct QMetaObject;
15class QVariant;
16
17namespace KItinerary {
18class ExtractorValidatorPrivate;
19
20/**
21 * Validates extractor results.
22 * Used to discard incomplete or otherwise invalid data.
23 * @since 20.08
24 */
25class KITINERARY_EXPORT ExtractorValidator
26{
27public:
31 ExtractorValidator& operator=(const ExtractorValidator&) = delete;
32
33 /** Checks if the given element is valid.
34 * This will accept both Reservation object and things
35 * that can be reserved as top-level objects.
36 */
37 bool isValidElement(const QVariant &elem) const;
38
39 /** Sets the list of supported top-level types that should be accepted.
40 * Providing an empty set of types will accept all top-level types.
41 * Instances of types inheriting from accepted types are also accepted.
42 * Default is to accept all types.
43 */
44 void setAcceptedTypes(std::vector<const QMetaObject*> &&accptedTypes);
45 /** Convenience overload of setAcceptedTypes(). */
46 template <typename ...Args> inline void setAcceptedTypes()
47 {
48 setAcceptedTypes({&Args::staticMetaObject...});
49 }
50
51 /** Configure whether or not to accept also incomplete elements.
52 * The default is @c true.
53 * Accepting incomplete elements is useful if the output is
54 * further processed, for example to merge minimal cancellation
55 * elements with already existing data. If the output is displayed
56 * directly, set this to @c true.
57 */
58 void setAcceptOnlyCompleteElements(bool completeOnly);
59
60private:
61 std::unique_ptr<ExtractorValidatorPrivate> d;
62};
63
64}
65
Validates extractor results.
void setAcceptedTypes()
Convenience overload of setAcceptedTypes().
Classes for reservation/travel data models, data extraction and data augmentation.
Definition berelement.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:14:49 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.