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:
32 ExtractorValidator& operator=(const ExtractorValidator&) = delete;
33 ExtractorValidator& operator=(ExtractorValidator&&) noexcept;
34
35 /** Checks if the given element is valid.
36 * This will accept both Reservation object and things
37 * that can be reserved as top-level objects.
38 */
39 [[nodiscard]] bool isValidElement(const QVariant &elem) const;
40
41 /** Sets the list of supported top-level types that should be accepted.
42 * Providing an empty set of types will accept all top-level types.
43 * Instances of types inheriting from accepted types are also accepted.
44 * Default is to accept all types.
45 */
46 void setAcceptedTypes(std::vector<const QMetaObject*> &&accptedTypes);
47 /** Convenience overload of setAcceptedTypes(). */
48 template <typename ...Args> inline void setAcceptedTypes()
49 {
50 setAcceptedTypes({&Args::staticMetaObject...});
51 }
52
53 /** Configure whether or not to accept also incomplete elements.
54 * The default is @c true.
55 * Accepting incomplete elements is useful if the output is
56 * further processed, for example to merge minimal cancellation
57 * elements with already existing data. If the output is displayed
58 * directly, set this to @c true.
59 */
60 void setAcceptOnlyCompleteElements(bool completeOnly);
61
62private:
63 std::unique_ptr<ExtractorValidatorPrivate> d;
64};
65
66}
67
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 Fri Oct 4 2024 12:00:24 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.