aboutsummaryrefslogtreecommitdiffstats
path: root/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/include/wnnlookuptable.h
diff options
context:
space:
mode:
authorJarkko Koivikko <jarkko.koivikko@code-q.fi>2017-07-05 00:33:18 +0300
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2017-07-25 10:06:27 +0000
commit27eb4f5683d9fe1426d3d3b51cb3c7f2b74082a6 (patch)
treecd29b4ce03946f435ddd1f6529a5216552b88042 /src/virtualkeyboard/3rdparty/openwnn/wnnEngine/include/wnnlookuptable.h
parent2f03202810f6c264509fb704511301d51f282292 (diff)
3rdparty/openwnn: Fix and optimize the engine due to QStringLiteral
QStringLiteral is broken in MSVC2015 onwards when used with \uXXXX encoded character literals. This was the reason Japanese tests were failing - the OpenWNN engine was actually broken and producing garbage. Not only this change eliminates QStringLiteral from openwnn, but also reduces runtime memory usage by replacing QMap<QString, QString>. The new solution is based on simple binary lookup table WnnLookupTable. WnnLookupTable data was converted from existing QMap structures using WnnLookupTable::create() method, which was left there for future reference. This change also removes the unnecessary QObjectPrivate definitions from Romkan* classes. [ChangeLog][OpenWNN] Fixed and optimized OpenWNN engine (as a workaround for QStringLiteral breakage) Task-number: QTBUG-62133 Change-Id: I50c9e2f5c363e1314f47d7023685da543ec9a7eb Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 0bf1c6ad9e0b5572b8ea99f5fc8945dade5675b7)
Diffstat (limited to 'src/virtualkeyboard/3rdparty/openwnn/wnnEngine/include/wnnlookuptable.h')
-rw-r--r--src/virtualkeyboard/3rdparty/openwnn/wnnEngine/include/wnnlookuptable.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/include/wnnlookuptable.h b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/include/wnnlookuptable.h
new file mode 100644
index 00000000..49d88208
--- /dev/null
+++ b/src/virtualkeyboard/3rdparty/openwnn/wnnEngine/include/wnnlookuptable.h
@@ -0,0 +1,47 @@
+/*
+ * Qt implementation of OpenWnn library
+ * This file is part of the Qt Virtual Keyboard module.
+ * Contact: http://www.qt.io/licensing/
+ *
+ * Copyright (C) 2017 The Qt Company
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WNNLOOKUPTABLE_H
+#define WNNLOOKUPTABLE_H
+
+#include <QString>
+#if WNN_LOOKUP_TABLE_CREATE
+#include <QMap>
+#endif
+
+class WnnLookupTable
+{
+public:
+ explicit WnnLookupTable(const char **keys, const char **values, const int length);
+
+ const QString value(const QString &what) const;
+ inline const QString operator[](const QString &what) const { return value(what); }
+
+#if WNN_LOOKUP_TABLE_CREATE
+ static void create(const QMap<QString, QString> &map, const QString &privatePrefix, const QString &fileName);
+#endif
+
+private:
+ const char **keys;
+ const char **values;
+ const int length;
+};
+
+#endif // WNNLOOKUPTABLE_H