15#ifndef HPP_ALIB_COMPATIBILITY_QT_CHARACTERS
16#define HPP_ALIB_COMPATIBILITY_QT_CHARACTERS 1
24#if !defined(ALIB_QT_LIB_NOT_FOUND)
28 #pragma clang diagnostic push
29 #pragma clang diagnostic ignored "-Wreserved-id-macro"
30 #pragma clang diagnostic ignored "-Wredundant-parens"
31 #pragma clang diagnostic ignored "-Wcovered-switch-default"
32 #pragma clang diagnostic ignored "-Wsign-conversion"
33 #pragma clang diagnostic ignored "-Wdeprecated"
34 #pragma clang diagnostic ignored "-Wunused-variable"
35 #pragma clang diagnostic ignored "-Wcomma"
36 #pragma clang diagnostic ignored "-Wduplicate-enum"
38#include <QtCore/QString>
39#include <QtCore/QVector>
42 #pragma clang diagnostic pop
45#if defined(HPP_ALIB_BOXING_BOXING)
46# error "Wrong inclusion order. Header 'alib/compatibility/qt_characters.hpp' has to be included before headers of module ALib Boxing."
56namespace compatibility {
64#define ALIB_QTCHAR typename alib::characters::TT_CharOfSize<2>::type
65#define ALIB_QTCHAR_4 typename alib::characters::TT_CharOfSize<4>::type
69template<>
struct T_CharArray<QStringView, ALIB_QTCHAR>
73 static const ALIB_QTCHAR*
Buffer (QStringView
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.data()); }
75 static QStringView
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QStringView( array,
static_cast<qsizetype
>(length) ); }
78template<>
struct T_ZTCharArray<QStringView, ALIB_QTCHAR>
82 static const ALIB_QTCHAR*
Buffer (QStringView
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.data()); }
84 static QStringView
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QStringView( array,
static_cast<qsizetype
>(length) ); }
88template<>
struct T_CharArray<QString, ALIB_QTCHAR >
92 static const ALIB_QTCHAR*
Buffer (QString
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.data()); }
94 static QString
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QString(
reinterpret_cast<const QChar*
>(array),
static_cast<int>(length) ); }
97template<>
struct T_ZTCharArray<QString, ALIB_QTCHAR>
101 static const ALIB_QTCHAR*
Buffer (QString
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.utf16()); }
103 static QString
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QString(
reinterpret_cast<const QChar*
>(array),
static_cast<int>(length) ); }
107template<>
struct T_CharArray<QLatin1String,
nchar>
111 static const nchar*
Buffer (QLatin1String
const & src) {
return src.data(); }
113 static QLatin1String
Construct(
const nchar* array,
integer length ) {
return QLatin1String( array,
static_cast<int>(length) ); }
116template<>
struct T_ZTCharArray<QLatin1String,
nchar>
120 static const nchar*
Buffer (QLatin1String
const & src) {
return reinterpret_cast<const nchar*
>(src.data()); }
122 static QLatin1String
Construct(
const nchar* array,
integer length ) {
return QLatin1String( array,
static_cast<int>(length) ); }
126template<>
struct T_CharArray<QByteArray,
nchar>
130 static const nchar*
Buffer (QByteArray
const & src) {
return src.data(); }
132 static QByteArray
Construct(
const nchar* array,
integer length ) {
return QByteArray( array,
static_cast<int>(length) ); }
135template<>
struct T_ZTCharArray<QByteArray,
nchar>
139 static const nchar*
Buffer (QByteArray
const & src) {
return reinterpret_cast<const nchar*
>(src.data()); }
141 static QByteArray
Construct(
const nchar* array,
integer length ) {
return QByteArray( array,
static_cast<int>(length) ); }
145template<>
struct T_CharArray<QVector<uint>, ALIB_QTCHAR_4>
149 static const ALIB_QTCHAR_4*
Buffer (QVector<uint>
const & src) {
return reinterpret_cast<const ALIB_QTCHAR_4*
>(src.data()); }
153 QVector<uint> result;
154 result.reserve(
static_cast<int>(length) );
155 const ALIB_QTCHAR_4* end= array + length;
157 result.append(
static_cast<uint
>( *array++ ) );
162template<>
struct T_ZTCharArray<QVector<uint>, ALIB_QTCHAR_4>
166 static const ALIB_QTCHAR_4*
Buffer (QVector<uint>
const & src) {
return reinterpret_cast<const ALIB_QTCHAR_4*
>(src.data()); }
167 static integer Length (QVector<uint>
const & src) {
return static_cast<integer >(src.size() ); }
170 QVector<uint> result;
171 result.reserve(
static_cast<int>(length) );
172 const ALIB_QTCHAR_4* end= array + length;
174 result.append(
static_cast<uint
>( *array++ ) );
#define ALIB_ASSERT_MODULE(modulename)
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
@ ExplicitOnly
Allows explicit construction of objects from character array data.
@ Implicit
Allows implicit (and explicit) construction of objects from character array data.
@ ExplicitOnly
Allows explicit access of the character array data from mutable or constant objects.
lang::integer integer
Type alias in namespace alib.
static const TChar * Buffer(const TString &src)
static constexpr ConstructionType Construction
static TString Construct(const TChar *array, integer length)
static constexpr AccessType Access
static integer Length(const TString &src)
static const TChar * Buffer(const TString &src)
static TString Construct(const TChar *array, integer length)
static integer Length(const TString &src)