• 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
primitivefactory.cpp
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 2010 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 #include "primitivefactory.h"
24 #include "primitive/primitivetemplateinfo.h"
25 #include "../script/scriptlogger.h"
26 
27 namespace PrimitiveFactory
28 {
29 
30 PrimitiveDataType typeStringToType(const QString& string, const LoggerWithContext& logger)
31 {
32  const QString typeStr = string.trimmed().toLower();
33  if (typeStr == QLatin1String("bool8"))
34  return Type_Bool8;
35  if (typeStr == QLatin1String("bool16"))
36  return Type_Bool16;
37  if (typeStr == QLatin1String("bool32"))
38  return Type_Bool32;
39  if (typeStr == QLatin1String("bool64"))
40  return Type_Bool64;
41  if (typeStr == QLatin1String("int8"))
42  return Type_Int8;
43  if (typeStr == QLatin1String("uint8"))
44  return Type_UInt8;
45  if (typeStr == QLatin1String("int16"))
46  return Type_Int16;
47  if (typeStr == QLatin1String("uint16"))
48  return Type_UInt16;
49  if (typeStr == QLatin1String("int32"))
50  return Type_Int32;
51  if (typeStr == QLatin1String("uint32"))
52  return Type_UInt32;
53  if (typeStr == QLatin1String("int64"))
54  return Type_Int64;
55  if (typeStr == QLatin1String("uint64"))
56  return Type_UInt64;
57  if (typeStr == QLatin1String("char"))
58  return Type_Char;
59  if (typeStr == QLatin1String("float"))
60  return Type_Float;
61  if (typeStr == QLatin1String("double"))
62  return Type_Double;
63  logger.warn() << typeStr << "does not name a valid primitive type";
64  return Type_Invalid; //just return a default value
65 }
66 PrimitiveDataInformation* newInstance(const QString& name, PrimitiveDataType type,
67  const LoggerWithContext& logger, DataInformation* parent)
68 {
69  switch (type.value)
70  {
71  case Type_Char:
72  return new PrimitiveInfo<Type_Char>::Class(name, parent);
73  case Type_Int8:
74  return new PrimitiveInfo<Type_Int8>::Class(name, parent);
75  case Type_Int16:
76  return new PrimitiveInfo<Type_Int16>::Class(name, parent);
77  case Type_Int32:
78  return new PrimitiveInfo<Type_Int32>::Class(name, parent);
79  case Type_Int64:
80  return new PrimitiveInfo<Type_Int64>::Class(name, parent);
81  case Type_UInt8:
82  return new PrimitiveInfo<Type_UInt8>::Class(name, parent);
83  case Type_UInt16:
84  return new PrimitiveInfo<Type_UInt16>::Class(name, parent);
85  case Type_UInt32:
86  return new PrimitiveInfo<Type_UInt32>::Class(name, parent);
87  case Type_UInt64:
88  return new PrimitiveInfo<Type_UInt64>::Class(name, parent);
89  case Type_Bool8:
90  return new PrimitiveInfo<Type_Bool8>::Class(name, parent);
91  case Type_Bool16:
92  return new PrimitiveInfo<Type_Bool16>::Class(name, parent);
93  case Type_Bool32:
94  return new PrimitiveInfo<Type_Bool32>::Class(name, parent);
95  case Type_Bool64:
96  return new PrimitiveInfo<Type_Bool64>::Class(name, parent);
97  case Type_Float:
98  return new PrimitiveInfo<Type_Float>::Class(name, parent);
99  case Type_Double:
100  return new PrimitiveInfo<Type_Double>::Class(name, parent);
101  default:
102  logger.error().nospace() << "could not convert '" << type << "' to a primitive type";
103  return 0; //invalid type
104  }
105 }
106 
107 }
DataInformation
Interface that must be implemented by all datatypes.
Definition: datainformation.h:67
LoggerWithContext
Definition: scriptlogger.h:94
Type_Bool32
Definition: primitivedatatype.h:40
LoggerWithContext::warn
QDebug warn() const
Definition: scriptlogger.h:98
Type_Int64
Definition: primitivedatatype.h:44
Type_Bool16
Definition: primitivedatatype.h:37
Type_UInt32
Definition: primitivedatatype.h:42
PrimitiveDataType
Definition: primitivedatatype.h:54
Type_UInt16
Definition: primitivedatatype.h:39
Type_UInt64
Definition: primitivedatatype.h:45
Type_Bool64
Definition: primitivedatatype.h:43
Type_Char
Definition: primitivedatatype.h:36
Type_Float
Definition: primitivedatatype.h:46
PrimitiveFactory::typeStringToType
PrimitiveDataType typeStringToType(const QString &string, const LoggerWithContext &logger)
Converts typeStr to a PrimitiveDataType case-insensitively.
Definition: primitivefactory.cpp:30
primitivetemplateinfo.h
Type_Int16
Definition: primitivedatatype.h:38
primitivefactory.h
PrimitiveFactory::newInstance
PrimitiveDataInformation * newInstance(const QString &name, PrimitiveDataType type, const LoggerWithContext &logger, DataInformation *parent)
Definition: primitivefactory.cpp:66
Type_Int32
Definition: primitivedatatype.h:41
PrimitiveInfo::Class
void Class
Definition: primitivetemplateinfo.h:57
LoggerWithContext::error
QDebug error() const
Definition: scriptlogger.h:99
Type_Invalid
!! DO NOT CHANGE ORDER OF ITEMS !!!
Definition: primitivedatatype.h:31
Type_Int8
Definition: primitivedatatype.h:34
Type_UInt8
Definition: primitivedatatype.h:35
Type_Bool8
Definition: primitivedatatype.h:33
Type_Double
Definition: primitivedatatype.h:47
PrimitiveDataInformation
A base class for all primitive data elements (e.g.
Definition: primitivedatainformation.h:34
PrimitiveDataType::value
PrimitiveDataTypeEnum value
Definition: primitivedatatype.h:56
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