AppCore
Loading...
Searching...
No Matches
UniversalDictionary.h
Go to the documentation of this file.
1#ifndef UNIVERSALDICTIONARY_H
2#define UNIVERSALDICTIONARY_H
3
4#include "StorageItem.h"
5#include <qvariant.h>
6#include <utility>
7#include <map>
8#include "core/common/eplatform.h"
9
10#include <qglobal.h>
11#if QT_VERSION < 0x040000
12 typedef QValueList<QVariant> QVariantList;
13#endif
14
16{
17public:
21
22 virtual StorageItem *Clone();
23 virtual QString WhoAmI() const;
24 virtual int32_t GetStorageDataType() const;
25
26 void AddItem( const long key, const QVariant &value );
27 void AddItem( const long key, void *value );
28
30
31 DEPRECATED( bool GetBool( const long key, bool &data ) );
32 DEPRECATED( bool GetNumber( const long key, long &data ) );
33 DEPRECATED( bool GetNumber( const long key, unsigned long &data ) );
34 DEPRECATED( bool GetString( const long key, QString &data ) );
35 DEPRECATED( bool GetPointer( const long key, void *&data ) );
36
37#ifdef EMTEST_XSCALE
38 bool GetData( const int32_t key, QString &data )
39 {
42 if ( ok == false )
43 {
44 return false;
45 }
46
47 if ( qvariantValue.canCast( QVariant::String ) == true )
48 {
49 data = qvariantValue.toString();
50 return true;
51 }
52
53 return false;
54 }
55#endif
56
57 template<typename T>
58 bool GetData( const int32_t key, T &data )
59 {
62 if ( ok == false )
63 {
64 return false;
65 }
66
67 QVariant returnValue( data );
68#ifdef EMTEST_XSCALE
69 if ( qvariantValue.canCast( returnValue.type() ) == true )
70 {
71 QVariant::Type type = qvariantValue.type();
72 switch ( type )
73 {
74 case QVariant::Bool:
75 {
76 data = qvariantValue.toBool();
77 }
78 break;
79
80 case QVariant::String:
81 {
82 // RDU - toString() tu nemoze byt kvoli chybe kompilacie (invalidconversion from `const char*' to `int'). Na ziskanie QString sa pouzije samostatna metoda.
83 //data = qvariantValue.toString();
84 return false;
85 }
86 break;
87
88 case QVariant::Int:
89 case QVariant::LongLong:
90 {
91 data = qvariantValue.toInt();
92 }
93 break;
94
95 case QVariant::UInt:
96 case QVariant::ULongLong:
97 {
98 data = qvariantValue.toUInt();
99 }
100 break;
101
102 default:
103 {
104 return false;
105 }
106 }
107 }
108#else
109 if ( qvariantValue.canConvert( returnValue.type() ) == true )
110 {
112 }
113#endif
114 else
115 {
116 return false;
117 }
118
119 return true;
120 }
121
122 template<typename T>
123 bool GetPointer( const int32_t key, T &data )
124 {
125 void *rawPointer = NULL;
127 if ( ok == false )
128 {
129 return false;
130 }
131
132 data = ( T )rawPointer;
133 return true;
134 }
135
136 bool RemoveItem( const int32_t &key );
137
138 unsigned short GetSize();
139
142
143#ifdef DEVELOP
144 virtual void PrintToLog();
145#endif
146
147private:
149
150 class DataClass;
151 DataClass *d;
152
153 bool GetRawPointerByKey( const int32_t key, void *&rawPointer );
155
157};
158
159#ifdef EMTEST_XSCALE
160template<>
161inline bool UniversalDictionary::GetData<QVariantList>( const int32_t key, QVariantList &data )
162{
165 if ( ok == false )
166 {
167 return false;
168 }
169
170 if ( qvariantValue.canCast( QVariant::List ) == true )
171 {
172 data = qvariantValue.toList();
173 return true;
174 }
175
176 return false;
177}
178
179#endif // EMTEST_XSCALE
180
181#endif // UniversalDictionary_H
QValueList< QVariant > QVariantList
Definition UniversalDictionary.h:12
Interface of information element which can be state input.
Definition StorageItem.h:14
Definition UniversalDictionary.h:16
bool RemoveItem(const int32_t &key)
unsigned short GetSize()
virtual QString WhoAmI() const
void AddExistingDictionary(const UniversalDictionary *copiedDictionary)
DEPRECATED(bool GetNumber(const long key, unsigned long &data))
UniversalDictionary(const int32_t &storageDataType)
UniversalDictionary(const UniversalDictionary &otherInstance)
DEPRECATED(bool GetString(const long key, QString &data))
UniversalDictionary & operator=(const UniversalDictionary &otherInstance)
Definition UniversalDictionary.cpp:268
DEPRECATED(bool GetNumber(const long key, long &data))
void AddItem(const long key, void *value)
virtual int32_t GetStorageDataType() const
virtual ~UniversalDictionary()
DEPRECATED(bool GetPointer(const long key, void *&data))
virtual StorageItem * Clone()
bool GetPointer(const int32_t key, T &data)
Definition UniversalDictionary.h:123
void AddItem(const long key, const QVariant &value)
DEPRECATED(bool GetBool(const long key, bool &data))
bool GetData(const int32_t key, T &data)
Definition UniversalDictionary.h:58