added util function
This commit is contained in:
parent
0f737a1328
commit
ade6268eb1
@ -91,6 +91,7 @@ Note that `MessageObject` attributes which can be synchronized back to service a
|
|||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `String hostname()` | `utils.hostname()` | Returns name of your PC. |
|
| `String hostname()` | `utils.hostname()` | Returns name of your PC. |
|
||||||
| `String fromXmlToJson(String)` | `utils.fromXmlToJson('<h1>hello</h1>')` | Converts `XML` string into `JSON`. |
|
| `String fromXmlToJson(String)` | `utils.fromXmlToJson('<h1>hello</h1>')` | Converts `XML` string into `JSON`. |
|
||||||
|
| `Date parseDateTime(String)` | `utils.parseDateTime('2020-02-24T08:00:00')` | Converts textual date/time representation into proper `Date` object. |
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
Accept only messages from "Bob" while also marking them important.
|
Accept only messages from "Bob" while also marking them important.
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "core/filterutils.h"
|
#include "core/filterutils.h"
|
||||||
|
|
||||||
#include "definitions/definitions.h"
|
#include "definitions/definitions.h"
|
||||||
|
#include "miscellaneous/textfactory.h"
|
||||||
|
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
@ -70,3 +71,7 @@ QString FilterUtils::fromXmlToJson(const QString& xml) const {
|
|||||||
return QSL("{\"%1\": %2}").arg(xml_doc.documentElement().tagName(),
|
return QSL("{\"%1\": %2}").arg(xml_doc.documentElement().tagName(),
|
||||||
json);
|
json);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDateTime FilterUtils::parseDateTime(const QString& dat) const {
|
||||||
|
return TextFactory::parseDateTime(dat);
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#ifndef FILTERUTILS_H
|
#ifndef FILTERUTILS_H
|
||||||
#define FILTERUTILS_H
|
#define FILTERUTILS_H
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
#include <QDomElement>
|
#include <QDomElement>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
@ -18,6 +19,9 @@ class FilterUtils : public QObject {
|
|||||||
|
|
||||||
// Converts XML -> JSON or returns empty string if failed.
|
// Converts XML -> JSON or returns empty string if failed.
|
||||||
Q_INVOKABLE QString fromXmlToJson(const QString& xml) const;
|
Q_INVOKABLE QString fromXmlToJson(const QString& xml) const;
|
||||||
|
|
||||||
|
// Parses string into date/time object.
|
||||||
|
Q_INVOKABLE QDateTime parseDateTime(const QString& dat) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FILTERUTILS_H
|
#endif // FILTERUTILS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user