Compare commits
2 Commits
492815c8fc
...
149938cc44
| Author | SHA1 | Date | |
|---|---|---|---|
|
149938cc44
|
|||
|
62f8a7d05f
|
@@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.0...3.27)
|
||||
project (liberty C CXX)
|
||||
|
||||
# Moar warnings
|
||||
set (CMAKE_CXX_STANDARD 11)
|
||||
if ("${CMAKE_C_COMPILER_ID}" MATCHES "GNU" OR CMAKE_COMPILER_IS_GNUCC)
|
||||
# -Wunused-function is pretty annoying here, as everything is static
|
||||
set (wdisabled "-Wno-unused-function")
|
||||
@@ -104,6 +105,7 @@ else ()
|
||||
add_executable (test-lxdrgen-cpp tests/lxdrgen.cpp
|
||||
${lxdrgen_base}.cpp tools/lxdrgen-cpp-posix.cpp)
|
||||
endif ()
|
||||
target_link_libraries (test-lxdrgen-cpp ${common_libraries})
|
||||
target_include_directories (test-lxdrgen-cpp PUBLIC ${PROJECT_BINARY_DIR})
|
||||
add_test (NAME test-lxdrgen-cpp COMMAND test-lxdrgen-cpp)
|
||||
|
||||
|
||||
@@ -45,8 +45,9 @@ lxdrgen-c.awk::
|
||||
LibertyXDR backend that builds on top of the C pseudolibrary.
|
||||
|
||||
lxdrgen-cpp.awk::
|
||||
lxdrgen-cpp-win32.cpp::
|
||||
lxdrgen-cpp-posix.cpp::
|
||||
lxdrgen-cpp-qt.cpp::
|
||||
lxdrgen-cpp-win32.cpp::
|
||||
LibertyXDR backend for C++, primarily targeting Win32 and its wide strings.
|
||||
Link the result together with one of the accompanied source files.
|
||||
|
||||
|
||||
23
tools/lxdrgen-cpp-qt.cpp
Normal file
23
tools/lxdrgen-cpp-qt.cpp
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user