summaryrefslogtreecommitdiffstats
path: root/src/imports/location/locationvaluetypeprovider.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/imports/location/locationvaluetypeprovider.h')
-rw-r--r--src/imports/location/locationvaluetypeprovider.h107
1 files changed, 98 insertions, 9 deletions
diff --git a/src/imports/location/locationvaluetypeprovider.h b/src/imports/location/locationvaluetypeprovider.h
index 3f7b1b02..a0c79887 100644
--- a/src/imports/location/locationvaluetypeprovider.h
+++ b/src/imports/location/locationvaluetypeprovider.h
@@ -46,7 +46,13 @@
QT_BEGIN_NAMESPACE
-QVariant stringToCoordinate(const QString &s);
+class QGeoCoordinate;
+class QGeoRectangle;
+class QGeoCircle;
+
+QGeoCoordinate parseCoordinate(const QJSValue &value, bool *ok);
+QGeoRectangle parseRectangle(const QJSValue &value, bool *ok);
+QGeoCircle parseCircle(const QJSValue &value, bool *ok);
class LocationValueTypeProvider : public QQmlValueTypeProvider
{
@@ -54,22 +60,105 @@ public:
LocationValueTypeProvider();
private:
+ template<typename T>
+ bool typedCreate(QQmlValueType *&v)
+ {
+ v = new T;
+ return true;
+ }
+
bool create(int type, QQmlValueType *&v) Q_DECL_OVERRIDE;
- bool init(int type, void *data, size_t n) Q_DECL_OVERRIDE;
- bool destroy(int type, void *data, size_t n) Q_DECL_OVERRIDE;
- bool copy(int type, const void *src, void *dst, size_t n) Q_DECL_OVERRIDE;
+ template<typename T>
+ bool typedInit(void *data, size_t dataSize)
+ {
+ Q_ASSERT(dataSize >= sizeof(T));
+ T *t = reinterpret_cast<T *>(data);
+ new (t) T();
+ return true;
+ }
+
+ bool init(int type, void *data, size_t dataSize) Q_DECL_OVERRIDE;
+
+ template<typename T>
+ bool typedDestroy(void *data, size_t dataSize)
+ {
+ Q_ASSERT(dataSize >= sizeof(T));
+ T *t = reinterpret_cast<T *>(data);
+ t->~T();
+ return true;
+ }
+
+ bool destroy(int type, void *data, size_t dataSize) Q_DECL_OVERRIDE;
+
+ template<typename T>
+ bool typedCopyConstruct(const void *src, void *dst, size_t dstSize)
+ {
+ Q_ASSERT(dstSize >= sizeof(T));
+ const T *srcT = reinterpret_cast<const T *>(src);
+ T *dstT = reinterpret_cast<T *>(dst);
+ new (dstT) T(*srcT);
+ return true;
+ }
+
+ bool copy(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE;
bool create(int type, int argc, const void *argv[], QVariant *v) Q_DECL_OVERRIDE;
- bool createFromString(int type, const QString &s, void *data, size_t n) Q_DECL_OVERRIDE;
+ bool createFromString(int type, const QString &s, void *data, size_t dataSize) Q_DECL_OVERRIDE;
bool createStringFrom(int type, const void *data, QString *s) Q_DECL_OVERRIDE;
bool variantFromJsObject(int type, QQmlV8Handle h, QV8Engine *e, QVariant *v) Q_DECL_OVERRIDE;
- bool equal(int type, const void *lhs, const void *rhs, size_t n) Q_DECL_OVERRIDE;
- bool store(int type, const void *src, void *dst, size_t n) Q_DECL_OVERRIDE;
- bool read(int srcType, const void *src, size_t n, int dstType, void *dst) Q_DECL_OVERRIDE;
- bool write(int type, const void *src, void *dst, size_t n) Q_DECL_OVERRIDE;
+ template<typename T>
+ bool typedEqual(const void *lhs, const void *rhs)
+ {
+ return *reinterpret_cast<const T *>(lhs) == *reinterpret_cast<const T *>(rhs);
+ }
+
+ bool equal(int type, const void *lhs, const void *rhs, size_t rhsSize) Q_DECL_OVERRIDE;
+
+ template<typename T>
+ bool typedStore(const void *src, void *dst, size_t dstSize)
+ {
+ Q_ASSERT(dstSize >= sizeof(T));
+ const T *srcT = reinterpret_cast<const T *>(src);
+ T *dstT = reinterpret_cast<T *>(dst);
+ new (dstT) T(*srcT);
+ return true;
+ }
+
+ bool store(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE;
+
+ template<typename T>
+ bool typedRead(int srcType, const void *src, size_t srcSize, int dstType, void *dst)
+ {
+ T *dstT = reinterpret_cast<T *>(dst);
+ if (srcType == dstType) {
+ Q_ASSERT(srcSize >= sizeof(T));
+ const T *srcT = reinterpret_cast<const T *>(src);
+ *dstT = *srcT;
+ } else {
+ *dstT = T();
+ }
+ return true;
+ }
+
+ bool read(int srcType, const void *src, size_t srcSize, int dstType, void *dst) Q_DECL_OVERRIDE;
+
+ template<typename T>
+ bool typedWrite(const void *src, void *dst, size_t dstSize)
+ {
+ Q_ASSERT(dstSize >= sizeof(T));
+ const T *srcT = reinterpret_cast<const T *>(src);
+ T *dstT = reinterpret_cast<T *>(dst);
+ if (*dstT != *srcT) {
+ *dstT = *srcT;
+ return true;
+ }
+ return false;
+ }
+
+ bool write(int type, const void *src, void *dst, size_t dstSize) Q_DECL_OVERRIDE;
};
QT_END_NAMESPACE