MagicSmoke  $VERSION$
keyvalue.h
Go to the documentation of this file.
1 //
2 // C++ Interface: unabstract
3 //
4 // Description: removes abstract flag from classes that only need to be abstract in PHP
5 //
6 //
7 // Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2016
8 //
9 // Copyright: See README/COPYING.GPL files that come with this distribution
10 //
11 //
12 
13 #ifndef MAGICSMOKE_KEYVALUE_H
14 #define MAGICSMOKE_KEYVALUE_H
15 
16 #include "MOKeyValuePairAbstract"
17 #include "misc.h"
18 
19 #include <TimeStamp>
20 
21 #ifndef MSIFACE_EXPORT
22 #define MSIFACE_EXPORT Q_DECL_IMPORT
23 #endif
24 
25 
28 {
29  Q_GADGET
30  WOBJECT(MOKeyValuePair)
31 public:
32  MOKeyValuePair(QString k,QString v){setkey(k);setvalue(v);setisnull(false);}
33  MOKeyValuePair(QString k,std::nullptr_t){setkey(k);setisnull(true);}
34 
35  inline operator QPair<QString,QString> ()
36  {
37  return QPair<QString,QString>(key(),value());
38  }
39 
40 };
41 
42 
43 
47 
48 #include <QPair>
49 #include <QMap>
50 
51 inline
52 QMap<QString,QString>& mergeToMap(QMap<QString,QString>&map, const QList<MOKeyValuePair>pl)
53 {
54  for(auto p:pl)
55  if(p.isnull())
56  map.remove(p.key());
57  else
58  map.insert(p.key(),p.value());
59  return map;
60 }
61 
62 inline
63 QMap<QString,QString> toMap(const QList<MOKeyValuePair>pl)
64 {
65  QMap<QString,QString>map;
66  return mergeToMap(map,pl);
67 }
68 
69 #endif
QMap< QString, QString > toMap(const QList< MOKeyValuePair >pl)
Definition: keyvalue.h:63
virtual Nullable< QString > value() const
Definition: srcMOKeyValuePairAbstract.h:31
virtual void setkey(Nullable< QString > s)
Definition: srcMOKeyValuePairAbstract.h:35
virtual void setvalue(Nullable< QString > s)
Definition: srcMOKeyValuePairAbstract.h:37
this class represents a key value pair or part of a map/dictionary.
Definition: keyvalue.h:27
MOKeyValuePair(QString k, std::nullptr_t)
Definition: keyvalue.h:33
Definition: srcMOKeyValuePairAbstract.h:14
virtual void setisnull(Nullable< bool > s)
Definition: srcMOKeyValuePairAbstract.h:39
virtual Nullable< QString > key() const
Definition: srcMOKeyValuePairAbstract.h:29
Q_DECLARE_METATYPE(QDomNode)
QMap< QString, QString > & mergeToMap(QMap< QString, QString > &map, const QList< MOKeyValuePair >pl)
Definition: keyvalue.h:52
MOKeyValuePair(QString k, QString v)
Definition: keyvalue.h:32
#define MSIFACE_EXPORT
Definition: keyvalue.h:22