Warning, file /pim/kitinerary/src/lib/extractorvalidator.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kitinerary_export.h"
0010 
0011 #include <memory>
0012 #include <vector>
0013 
0014 struct QMetaObject;
0015 class QVariant;
0016 
0017 namespace KItinerary {
0018 class ExtractorValidatorPrivate;
0019 
0020 /**
0021  * Validates extractor results.
0022  * Used to discard incomplete or otherwise invalid data.
0023  * @since 20.08
0024  */
0025 class KITINERARY_EXPORT ExtractorValidator
0026 {
0027 public:
0028     ExtractorValidator();
0029     ~ExtractorValidator();
0030     ExtractorValidator(const ExtractorValidator&) = delete;
0031     ExtractorValidator& operator=(const ExtractorValidator&) = delete;
0032 
0033     /** Checks if the given element is valid.
0034      *  This will accept both Reservation object and things
0035      *  that can be reserved as top-level objects.
0036      */
0037     bool isValidElement(const QVariant &elem) const;
0038 
0039     /** Sets the list of supported top-level types that should be accepted.
0040      *  Providing an empty set of types will accept all top-level types.
0041      *  Instances of types inheriting from accepted types are also accepted.
0042      *  Default is to accept all types.
0043      */
0044     void setAcceptedTypes(std::vector<const QMetaObject*> &&accptedTypes);
0045     /** Convenience overload of setAcceptedTypes(). */
0046     template <typename ...Args> inline void setAcceptedTypes()
0047     {
0048         setAcceptedTypes({&Args::staticMetaObject...});
0049     }
0050 
0051     /** Configure whether or not to accept also incomplete elements.
0052      *  The default is @c true.
0053      *  Accepting incomplete elements is useful if the output is
0054      *  further processed, for example to merge minimal cancellation
0055      *  elements with already existing data. If the output is displayed
0056      *  directly, set this to @c true.
0057      */
0058     void setAcceptOnlyCompleteElements(bool completeOnly);
0059 
0060 private:
0061     std::unique_ptr<ExtractorValidatorPrivate> d;
0062 };
0063 
0064 }
0065