aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPřemysl Eric Janouch <p@janouch.name>2024-12-15 06:41:07 +0100
committerPřemysl Eric Janouch <p@janouch.name>2024-12-15 06:44:06 +0100
commit149938cc445f99b1aa40c490014aad72cf698dec (patch)
treef1fc5ada59f85f58107c1c5dad2d5566db050067 /tools
parent62f8a7d05f9a72f632fbf2b70490b9bbd1c49895 (diff)
downloadliberty-149938cc445f99b1aa40c490014aad72cf698dec.tar.gz
liberty-149938cc445f99b1aa40c490014aad72cf698dec.tar.xz
liberty-149938cc445f99b1aa40c490014aad72cf698dec.zip
lxdrgen-cpp: add a Qt backend
Motivation: some Android NDKs do not have iconv.
Diffstat (limited to 'tools')
-rw-r--r--tools/lxdrgen-cpp-qt.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/lxdrgen-cpp-qt.cpp b/tools/lxdrgen-cpp-qt.cpp
new file mode 100644
index 0000000..60e7293
--- /dev/null
+++ b/tools/lxdrgen-cpp-qt.cpp
@@ -0,0 +1,23 @@
+// lxdrgen-cpp-qt.cpp: Qt support code for lxdrgen-cpp.awk.
+//
+// Copyright (c) 2024, Přemysl Eric Janouch <p@janouch.name>
+// SPDX-License-Identifier: 0BSD
+#include <QString>
+#include <string>
+
+namespace LibertyXDR {
+
+bool utf8_to_wstring(const uint8_t *utf8, size_t length, std::wstring &wide) {
+ QByteArrayView view(reinterpret_cast<const char *>(utf8), length);
+ if (!view.isValidUtf8())
+ return false;
+ wide = QString::fromUtf8(view).toStdWString();
+ return true;
+}
+
+bool wstring_to_utf8(const std::wstring &wide, std::string &utf8) {
+ utf8 = QString::fromStdWString(wide).toUtf8().toStdString();
+ return true;
+}
+
+} // namespace LibertyXDR