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

0001 /*
0002  *  SPDX-FileCopyrightText: 2007 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.1-or-later
0005  */
0006 
0007 
0008 #ifndef _KIS_META_DATA_ENTRY_H_
0009 #define _KIS_META_DATA_ENTRY_H_
0010 
0011 #include <kritametadata_export.h>
0012 #include <kis_debug.h>
0013 
0014 class QString;
0015 
0016 namespace KisMetaData
0017 {
0018 class Value;
0019 class Store;
0020 class Schema;
0021 /**
0022  * Represent a metadata entry, a name and a value (\ref KisMetaData::Value).
0023  */
0024 class KRITAMETADATA_EXPORT Entry
0025 {
0026     struct Private;
0027     friend class Store;
0028 public:
0029     /**
0030      * Create an invalid entry
0031      */
0032     Entry();
0033     /**
0034      * Create a new entry.
0035      * @param name
0036      * @param namespacePrefix
0037      * @param value
0038      */
0039     Entry(const KisMetaData::Schema* schema, QString name, const KisMetaData::Value& value);
0040     Entry(const Entry&);
0041     ~Entry();
0042     /**
0043      * @return the name of this entry
0044      */
0045     QString name() const;
0046     /**
0047      * @return the namespace of this entry
0048      */
0049     const KisMetaData::Schema* schema() const;
0050     /**
0051      * @return the qualified name of this entry, which is the concatenation of the
0052      * namespace and of the name
0053      */
0054     QString qualifiedName() const;
0055     /**
0056      * @return the value of this entry
0057      */
0058     const KisMetaData::Value& value() const;
0059     /**
0060      * @return the value of this entry
0061      */
0062     KisMetaData::Value& value();
0063     /**
0064      * @return true if this entry is valid
0065      */
0066     bool isValid() const;
0067     /**
0068      * @return true if the name in argument is valid entry name.
0069      */
0070     static bool isValidName(const QString& _name);
0071     /**
0072      * Affect the content of entry to this entry if entry is valid
0073      */
0074     Entry& operator=(const Entry& entry);
0075     bool operator==(const Entry&) const;
0076 private:
0077     void setSchema(const KisMetaData::Schema* schema);
0078 private:
0079     Private* const d;
0080 };
0081 }
0082 
0083 KRITAMETADATA_EXPORT QDebug operator<<(QDebug debug, const KisMetaData::Entry &c);
0084 
0085 #endif