File indexing completed on 2024-05-12 15:59:17

0001 /*
0002  *  SPDX-FileCopyrightText: 2009 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 #ifndef _KIS_META_DATA_VALIDATION_RESULT_H_
0008 #define _KIS_META_DATA_VALIDATION_RESULT_H_
0009 
0010 #include <QMap>
0011 #include <QString>
0012 
0013 #include <kritametadata_export.h>
0014 
0015 namespace KisMetaData
0016 {
0017 class Store;
0018 /**
0019  * This class contains information on the validation results of a \ref KisMetaData::Store .
0020  */
0021 class KRITAMETADATA_EXPORT Validator
0022 {
0023 public:
0024     class KRITAMETADATA_EXPORT Reason
0025     {
0026         friend class Validator;
0027         friend class QMap<QString, Reason>;
0028     public:
0029         enum Type {
0030             UNKNOWN_REASON,
0031             UNKNOWN_ENTRY,
0032             INVALID_TYPE,
0033             INVALID_VALUE
0034         };
0035     public:
0036         Reason(Type type = UNKNOWN_REASON);
0037         Reason(const Reason&);
0038         Reason& operator=(const Reason&);
0039     public:
0040         ~Reason();
0041         Type type() const;
0042     private:
0043         struct Private;
0044         Private* const d;
0045     };
0046 public:
0047     /**
0048      * Validate a store. This constructore will call the \ref revalidate function.
0049      */
0050     Validator(const Store*);
0051     ~Validator();
0052     int countInvalidEntries() const;
0053     int countValidEntries() const;
0054     const QMap<QString, Reason>& invalidEntries() const;
0055     /**
0056      * Call this function to revalidate the store.
0057      */
0058     void revalidate();
0059 private:
0060     struct Private;
0061     Private* const d;
0062 };
0063 }
0064 
0065 #endif