Krita Source Code Documentation
Loading...
Searching...
No Matches
KisMetaData::TypeInfo Class Reference

#include <kis_meta_data_type_info.h>

Classes

class  Choice
 

Public Types

enum  PropertyType {
  BooleanType , IntegerType , DateType , TextType ,
  OrderedArrayType , UnorderedArrayType , AlternativeArrayType , LangArrayType ,
  StructureType , RationalType , GPSCoordinateType , OpenedChoice ,
  ClosedChoice
}
 

Public Member Functions

const QList< Choice > & choices () const
 
const TypeInfoembeddedPropertyType () const
 
bool hasCorrectType (const Value &value) const
 
bool hasCorrectValue (const Value &value) const
 
const Parserparser () const
 
PropertyType propertyType () const
 
const QString & structureName () const
 
SchemastructureSchema () const
 

Private Member Functions

 TypeInfo (PropertyType _propertiesType)
 
 TypeInfo (PropertyType _propertiesType, const TypeInfo *_embedded)
 
 TypeInfo (PropertyType _propertiesType, const TypeInfo *_embedded, const QList< Choice > &)
 
 TypeInfo (Schema *_structureSchema, const QString &name)
 
 ~TypeInfo ()
 

Private Attributes

Private *const d
 

Detailed Description

Definition at line 19 of file kis_meta_data_type_info.h.

Member Enumeration Documentation

◆ PropertyType

Enumerator
BooleanType 
IntegerType 
DateType 
TextType 
OrderedArrayType 
UnorderedArrayType 
AlternativeArrayType 
LangArrayType 
StructureType 
RationalType 
GPSCoordinateType 
OpenedChoice 
ClosedChoice 

Definition at line 22 of file kis_meta_data_type_info.h.

Constructor & Destructor Documentation

◆ TypeInfo() [1/4]

KisMetaData::TypeInfo::TypeInfo ( PropertyType _propertiesType)
private

◆ TypeInfo() [2/4]

KisMetaData::TypeInfo::TypeInfo ( PropertyType _propertiesType,
const TypeInfo * _embedded )
private

Create a TypeInfo for a

◆ TypeInfo() [3/4]

KisMetaData::TypeInfo::TypeInfo ( PropertyType _propertiesType,
const TypeInfo * _embedded,
const QList< Choice > &  )
private

Create a TypeInfo for a choice (either open or closed).

Parameters
_propertiesTypeeither OpenedChoice or ClosedChoice

◆ TypeInfo() [4/4]

TypeInfo::TypeInfo ( Schema * _structureSchema,
const QString & name )
private

Create a TypeInfo for a structure.

Definition at line 146 of file kis_meta_data_type_info.cc.

146 : d(new Private)
147{
148 d->propertyType = TypeInfo::StructureType;
149 d->structureSchema = _structureSchema;
150 d->structureName = name;
151}
const char * name(StandardAction id)

References d, and StructureType.

◆ ~TypeInfo()

TypeInfo::~TypeInfo ( )
private

Definition at line 153 of file kis_meta_data_type_info.cc.

154{
155 delete d->parser;
156 delete d;
157}

References d.

Member Function Documentation

◆ choices()

const QList< TypeInfo::Choice > & TypeInfo::choices ( ) const

Definition at line 169 of file kis_meta_data_type_info.cc.

170{
171 return d->choices;
172}

References d.

◆ embeddedPropertyType()

const TypeInfo * TypeInfo::embeddedPropertyType ( ) const

Definition at line 164 of file kis_meta_data_type_info.cc.

165{
166 return d->embeddedTypeInfo;
167}

References d.

◆ hasCorrectType()

bool TypeInfo::hasCorrectType ( const Value & value) const
Returns
true if value has a type that is correct for this TypeInfo

Definition at line 200 of file kis_meta_data_type_info.cc.

201{
202 switch (d->propertyType) {
203 case BooleanType:
204 return value.type() == Value::Variant && value.asVariant().type() == QVariant::Bool;
205 case IntegerType:
206 return value.type() == Value::Variant && value.asVariant().type() == QVariant::Int;
207 case DateType:
208 return value.type() == Value::Variant && value.asVariant().type() == QVariant::DateTime;
210 case TextType:
211 return value.type() == Value::Variant && value.asVariant().type() == QVariant::String;
212 case OrderedArrayType:
213 if (value.type() == Value::OrderedArray) {
214 return checkArray(value, d->embeddedTypeInfo);
215 } else {
216 return false;
217 }
219 if (value.type() == Value::UnorderedArray) {
220 return checkArray(value, d->embeddedTypeInfo);
221 } else {
222 return false;
223 }
225 if (value.type() == Value::AlternativeArray) {
226 return checkArray(value, d->embeddedTypeInfo);
227 } else {
228 return false;
229 }
230 case LangArrayType:
231 if (value.type() == Value::LangArray) {
232 QList< Value > values = value.asArray();
233 Q_FOREACH (const Value& vallang, values) {
234 if (!Private::Text->hasCorrectType(vallang) ||
235 !Private::Text->hasCorrectType(vallang.propertyQualifiers()["xml:lang"])) {
236 return false;
237 }
238 }
239 return true;
240 } else {
241 return false;
242 }
243 case StructureType:
244 if (value.type() == Value::Structure) {
245 QMap<QString, KisMetaData::Value> structure = value.asStructure();
246 for (QMap<QString, KisMetaData::Value>::iterator it = structure.begin();
247 it != structure.end(); ++it) {
248 const TypeInfo* typeInfo = d->structureSchema->propertyType(it.key());
249 if (!typeInfo || !typeInfo->hasCorrectType(it.value())) {
250 return false;
251 }
252 }
253 return true;
254 } else {
255 return false;
256 }
257 case RationalType:
258 return value.type() == Value::Rational;
259 case OpenedChoice:
260 case ClosedChoice:
261 return d->embeddedTypeInfo->hasCorrectType(value);
262 }
263 return false;
264}
float value(const T *src, size_t ch)
bool hasCorrectType(const Value &value) const
bool checkArray(const Value &value, const TypeInfo *typeInfo)
QMap< QString, Value > propertyQualifiers

References KisMetaData::Value::AlternativeArray, AlternativeArrayType, BooleanType, checkArray(), ClosedChoice, d, DateType, GPSCoordinateType, hasCorrectType(), IntegerType, KisMetaData::Value::LangArray, LangArrayType, OpenedChoice, KisMetaData::Value::OrderedArray, OrderedArrayType, KisMetaData::Value::propertyQualifiers(), KisMetaData::Value::Rational, RationalType, KisMetaData::Value::Structure, StructureType, TextType, KisMetaData::Value::UnorderedArray, UnorderedArrayType, value(), and KisMetaData::Value::Variant.

◆ hasCorrectValue()

bool TypeInfo::hasCorrectValue ( const Value & value) const
Returns
true if value has a value acceptable for this TypeInfo

Definition at line 266 of file kis_meta_data_type_info.cc.

267{
268 if (d->propertyType == ClosedChoice) {
269 Q_FOREACH (const Choice& choice, d->choices) {
270 if (choice.value() == value) {
271 return true;
272 }
273 }
274 return false;
275 } else {
276 return true;
277 }
278}

References ClosedChoice, d, KisMetaData::TypeInfo::Choice::value(), and value().

◆ parser()

const Parser * TypeInfo::parser ( ) const

Definition at line 184 of file kis_meta_data_type_info.cc.

185{
186 return d->parser;
187}

References d.

◆ propertyType()

TypeInfo::PropertyType TypeInfo::propertyType ( ) const

Definition at line 159 of file kis_meta_data_type_info.cc.

160{
161 return d->propertyType;
162}

References d.

◆ structureName()

const QString & TypeInfo::structureName ( ) const

Definition at line 179 of file kis_meta_data_type_info.cc.

180{
181 return d->structureName;
182}

References d.

◆ structureSchema()

Schema * TypeInfo::structureSchema ( ) const

Definition at line 174 of file kis_meta_data_type_info.cc.

175{
176 return d->structureSchema;
177}

References d.

Member Data Documentation

◆ d

Private* const KisMetaData::TypeInfo::d
private

Definition at line 85 of file kis_meta_data_type_info.h.


The documentation for this class was generated from the following files: