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_TYPE_INFO_H_
0008 #define _KIS_META_DATA_TYPE_INFO_H_
0009 
0010 #include <QList>
0011 #include <QString>
0012 #include <kritametadata_export.h>
0013 
0014 namespace KisMetaData
0015 {
0016 class Parser;
0017 class Schema;
0018 class Value;
0019 class KRITAMETADATA_EXPORT TypeInfo
0020 {
0021 public:
0022     enum PropertyType {
0023         BooleanType,
0024         IntegerType,
0025         DateType,
0026         TextType,
0027         OrderedArrayType,
0028         UnorderedArrayType,
0029         AlternativeArrayType,
0030         LangArrayType,
0031         StructureType,
0032         RationalType,
0033         GPSCoordinateType,
0034         OpenedChoice,
0035         ClosedChoice
0036     };
0037     class KRITAMETADATA_EXPORT Choice
0038     {
0039     public:
0040         Choice(const Value&, const QString& hint);
0041         Choice(const Choice&);
0042         Choice& operator=(const Choice&);
0043         ~Choice();
0044     public:
0045         const Value& value() const;
0046         const QString& hint() const;
0047     private:
0048         struct Private;
0049         Private* const d;
0050     };
0051 private:
0052     TypeInfo(PropertyType _propertiesType);
0053     /**
0054      * Create a \ref TypeInfo for a
0055      */
0056     TypeInfo(PropertyType _propertiesType, const TypeInfo* _embedded);
0057     /**
0058      * Create a \ref TypeInfo for a choice (either open or closed).
0059      * @param _propertiesType either OpenedChoice or ClosedChoice
0060      */
0061     TypeInfo(PropertyType _propertiesType, const TypeInfo* _embedded, const QList< Choice >&);
0062     /**
0063      * Create a \ref TypeInfo for a structure.
0064      */
0065     TypeInfo(Schema* _structureSchema, const QString& name);
0066     ~TypeInfo();
0067 public:
0068     PropertyType propertyType() const;
0069     const TypeInfo* embeddedPropertyType() const;
0070     const QList< Choice >& choices() const;
0071     Schema* structureSchema() const;
0072     const QString& structureName() const;
0073     const Parser* parser() const;
0074     /**
0075      * @return true if @p value has a type that is correct for this \ref TypeInfo
0076      */
0077     bool hasCorrectType(const Value& value) const;
0078     /**
0079      * @return true if @p value has a value acceptable for this \ref TypeInfo
0080      */
0081     bool hasCorrectValue(const Value& value) const;
0082 public:
0083     struct Private;
0084 private:
0085     Private* const d;
0086 };
0087 }
0088 
0089 #endif