| 
									
										
										
										
											2019-01-02 12:27:16 -05:00
										 |  |  | #ifndef MESSAGE_H
 | 
					
						
							|  |  |  | #define MESSAGE_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * (C) 2018 Jordan Sherer <kn4crd@gmail.com> - All Rights Reserved | 
					
						
							|  |  |  |  **/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <QMap>
 | 
					
						
							|  |  |  | #include <QByteArray>
 | 
					
						
							|  |  |  | #include <QJsonDocument>
 | 
					
						
							|  |  |  | #include <QJsonObject>
 | 
					
						
							|  |  |  | #include <QString>
 | 
					
						
							|  |  |  | #include <QVariant>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Message { | 
					
						
							|  |  |  | public: | 
					
						
							|  |  |  |     Message(); | 
					
						
							|  |  |  |     Message(QString const &type, QString const &value=""); | 
					
						
							|  |  |  |     Message(QString const &type, QString const &value, QMap<QString, QVariant> const ¶ms); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void read(const QJsonObject &json); | 
					
						
							|  |  |  |     void write(QJsonObject &json) const; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QByteArray toJson() const; | 
					
						
							| 
									
										
										
										
											2020-04-05 14:33:10 -04:00
										 |  |  |     QVariantMap toVariantMap() const; | 
					
						
							| 
									
										
										
										
											2019-01-02 12:27:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |     QString type() const { return type_; } | 
					
						
							|  |  |  |     void setType(QString type){ type_ = type; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QString value() const { return value_; } | 
					
						
							|  |  |  |     void setValue(QString value){ value_ = value; } | 
					
						
							| 
									
										
										
										
											2020-04-04 15:15:17 -04:00
										 |  |  |     qint64 id() const { return params_.value("_ID").toLongLong(); } | 
					
						
							|  |  |  |     qint64 ensureId(); | 
					
						
							| 
									
										
										
										
											2019-01-02 12:27:16 -05:00
										 |  |  |     QMap<QString, QVariant> params() const { return params_; } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     QString type_; | 
					
						
							|  |  |  |     QString value_; | 
					
						
							|  |  |  |     QMap<QString, QVariant> params_; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif // MESSAGE_H
 |