KItinerary

extractorvalidator.h
1 /*
2  SPDX-FileCopyrightText: 2019 Volker Krause <[email protected]>
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 
14 struct QMetaObject;
15 class QVariant;
16 
17 namespace KItinerary {
18 class ExtractorValidatorPrivate;
19 
20 /**
21  * Validates extractor results.
22  * Used to discard incomplete or otherwise invalid data.
23  * @since 20.08
24  */
25 class KITINERARY_EXPORT ExtractorValidator
26 {
27 public:
30  ExtractorValidator(const ExtractorValidator&) = delete;
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 
60 private:
61  std::unique_ptr<ExtractorValidatorPrivate> d;
62 };
63 
64 }
65 
Classes for reservation/travel data models, data extraction and data augmentation.
void setAcceptedTypes()
Convenience overload of setAcceptedTypes().
Validates extractor results.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Mon Jan 17 2022 23:06:16 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.