• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdesdk API Reference
  • KDE Home
  • Contact Us
 

okteta

  • sources
  • kde-4.12
  • kdesdk
  • okteta
  • kasten
  • controllers
  • view
  • structures
  • datatypes
  • primitive
enumdefinition.h
Go to the documentation of this file.
1 /*
2  * This file is part of the Okteta Kasten Framework, made within the KDE community.
3  *
4  * Copyright 2009, 2012 Alex Richardson <alex.richardson@gmx.de>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) version 3, or any
10  * later version accepted by the membership of KDE e.V. (or its
11  * successor approved by the membership of KDE e.V.), which shall
12  * act as a proxy defined in Section 6 of version 3 of the license.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library. If not, see <http://www.gnu.org/licenses/>.
21  */
22 
23 #ifndef ENUMDEFINITION_H_
24 #define ENUMDEFINITION_H_
25 #include "../../allprimitivetypes.h"
26 #include "../primitivedatatype.h"
27 //Qt core
28 #include <QMap>
29 #include <QSharedData>
30 #include <QSharedDataPointer>
31 #include <QString>
32 #include <QPair>
33 
34 class QScriptValue;
35 struct LoggerWithContext;
36 
37 class EnumDefinition: public QSharedData
38 {
39 public:
40  typedef QSharedDataPointer<EnumDefinition> Ptr;
41  EnumDefinition(const QMap<AllPrimitiveTypes, QString> values, const QString& name,
42  PrimitiveDataType type) :
43  QSharedData(), mName(name), mValues(values), mType(type) {}
44  EnumDefinition(const EnumDefinition& e) :
45  QSharedData(e), mValues(e.mValues), mType(e.mType) {}
46 
47  const QMap<AllPrimitiveTypes, QString>& values() const;
48  const AllPrimitiveTypes key(QString& value) const;
49  const QString value(AllPrimitiveTypes key) const;
50  PrimitiveDataType type() const;
51  const QString& name() const;
52  void setValues(QMap< AllPrimitiveTypes, QString > newValues);
53 
54  static QMap<AllPrimitiveTypes, QString> parseEnumValues(const QScriptValue& val,
55  const LoggerWithContext& logger, PrimitiveDataType type = Type_UInt64);
57  static QPair<AllPrimitiveTypes, QString> convertToEnumEntry(const QString& name, const QVariant& value,
58  const LoggerWithContext& logger, PrimitiveDataType type);
59 protected:
60  const QString mName;
61  QMap<AllPrimitiveTypes, QString> mValues;
62  const PrimitiveDataType mType;
63 };
64 
65 
66 inline const QMap<AllPrimitiveTypes, QString>& EnumDefinition::values() const
67 {
68  return mValues;
69 }
70 
71 inline const AllPrimitiveTypes EnumDefinition::key(QString& value) const
72 {
73  return mValues.key(value);
74 }
75 
76 inline const QString EnumDefinition::value(AllPrimitiveTypes key) const
77 {
78  return mValues.value(key);
79 }
80 
81 inline PrimitiveDataType EnumDefinition::type() const
82 {
83  return mType;
84 }
85 
86 inline const QString& EnumDefinition::name() const
87 {
88  return mName;
89 }
90 
91 inline void EnumDefinition::setValues(QMap<AllPrimitiveTypes, QString> newValues)
92 {
93  mValues = newValues; //causes the QSharedPointer to detach and copy
94 }
95 
96 
97 #endif /* ENUMDEFINITION_H_ */
LoggerWithContext
Definition: scriptlogger.h:94
EnumDefinition::name
const QString & name() const
Definition: enumdefinition.h:86
EnumDefinition::convertToEnumEntry
static QPair< AllPrimitiveTypes, QString > convertToEnumEntry(const QString &name, const QVariant &value, const LoggerWithContext &logger, PrimitiveDataType type)
Definition: enumdefinition.cpp:59
EnumDefinition::Ptr
QSharedDataPointer< EnumDefinition > Ptr
Definition: enumdefinition.h:40
PrimitiveDataType
Definition: primitivedatatype.h:54
Type_UInt64
Definition: primitivedatatype.h:45
EnumDefinition::EnumDefinition
EnumDefinition(const QMap< AllPrimitiveTypes, QString > values, const QString &name, PrimitiveDataType type)
Definition: enumdefinition.h:41
EnumDefinition::mType
const PrimitiveDataType mType
Definition: enumdefinition.h:62
EnumDefinition::parseEnumValues
static QMap< AllPrimitiveTypes, QString > parseEnumValues(const QScriptValue &val, const LoggerWithContext &logger, PrimitiveDataType type=Type_UInt64)
Definition: enumdefinition.cpp:31
EnumDefinition::key
const AllPrimitiveTypes key(QString &value) const
Definition: enumdefinition.h:71
EnumDefinition::EnumDefinition
EnumDefinition(const EnumDefinition &e)
Definition: enumdefinition.h:44
EnumDefinition::values
const QMap< AllPrimitiveTypes, QString > & values() const
Definition: enumdefinition.h:66
EnumDefinition
Definition: enumdefinition.h:37
EnumDefinition::mValues
QMap< AllPrimitiveTypes, QString > mValues
Definition: enumdefinition.h:61
AllPrimitiveTypes
This union holds the value of one primitive datatype.
Definition: allprimitivetypes.h:70
EnumDefinition::mName
const QString mName
Definition: enumdefinition.h:60
EnumDefinition::value
const QString value(AllPrimitiveTypes key) const
Definition: enumdefinition.h:76
EnumDefinition::type
PrimitiveDataType type() const
Definition: enumdefinition.h:81
EnumDefinition::setValues
void setValues(QMap< AllPrimitiveTypes, QString > newValues)
Definition: enumdefinition.h:91
QMap< AllPrimitiveTypes, QString >
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:04:08 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

okteta

Skip menu "okteta"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdesdk API Reference

Skip menu "kdesdk API Reference"
  • kapptemplate
  • kcachegrind
  • kompare
  • lokalize
  • okteta
  • umbrello
  •   umbrello

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal