15#ifndef HPP_ALIB_COMPATIBILITY_QT_CHARACTERS
16#define HPP_ALIB_COMPATIBILITY_QT_CHARACTERS 1
18#if !defined(HPP_ALIB) && !defined(ALIB_DOX)
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."
49#if !defined(HPP_ALIB_CHARACTERS_CHARACTERS)
53namespace alib {
namespace characters {
58namespace compatibility {
68#define ALIB_QTCHAR typename alib::characters::TT_CharOfSize<2>::type
69#define ALIB_QTCHAR_4 typename alib::characters::TT_CharOfSize<4>::type
73template<>
struct T_CharArray<QStringView, ALIB_QTCHAR>
77 static const ALIB_QTCHAR*
Buffer (QStringView
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.data()); }
79 static QStringView
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QStringView( array,
static_cast<qsizetype
>(length) ); }
82template<>
struct T_ZTCharArray<QStringView, ALIB_QTCHAR>
86 static const ALIB_QTCHAR*
Buffer (QStringView
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.data()); }
88 static QStringView
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QStringView( array,
static_cast<qsizetype
>(length) ); }
92template<>
struct T_CharArray<QString, ALIB_QTCHAR >
96 static const ALIB_QTCHAR*
Buffer (QString
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.data()); }
98 static QString
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QString(
reinterpret_cast<const QChar*
>(array),
static_cast<int>(length) ); }
101template<>
struct T_ZTCharArray<QString, ALIB_QTCHAR>
105 static const ALIB_QTCHAR*
Buffer (QString
const & src) {
return reinterpret_cast<const ALIB_QTCHAR*
>(src.utf16()); }
107 static QString
Construct(
const ALIB_QTCHAR* array,
integer length ) {
return QString(
reinterpret_cast<const QChar*
>(array),
static_cast<int>(length) ); }
111template<>
struct T_CharArray<QLatin1String,
nchar>
115 static const nchar*
Buffer (QLatin1String
const & src) {
return src.data(); }
117 static QLatin1String
Construct(
const nchar* array,
integer length ) {
return QLatin1String( array,
static_cast<int>(length) ); }
120template<>
struct T_ZTCharArray<QLatin1String,
nchar>
124 static const nchar*
Buffer (QLatin1String
const & src) {
return reinterpret_cast<const nchar*
>(src.data()); }
126 static QLatin1String
Construct(
const nchar* array,
integer length ) {
return QLatin1String( array,
static_cast<int>(length) ); }
130template<>
struct T_CharArray<QByteArray,
nchar>
134 static const nchar*
Buffer (QByteArray
const & src) {
return src.data(); }
136 static QByteArray
Construct(
const nchar* array,
integer length ) {
return QByteArray( array,
static_cast<int>(length) ); }
139template<>
struct T_ZTCharArray<QByteArray,
nchar>
143 static const nchar*
Buffer (QByteArray
const & src) {
return reinterpret_cast<const nchar*
>(src.data()); }
145 static QByteArray
Construct(
const nchar* array,
integer length ) {
return QByteArray( array,
static_cast<int>(length) ); }
149template<>
struct T_CharArray<QVector<uint>, ALIB_QTCHAR_4>
153 static const ALIB_QTCHAR_4*
Buffer (QVector<uint>
const & src) {
return reinterpret_cast<const ALIB_QTCHAR_4*
>(src.data()); }
157 QVector<uint> result;
158 result.reserve(
static_cast<int>(length) );
159 const ALIB_QTCHAR_4* end= array + length;
161 result.append(
static_cast<uint
>( *array++ ) );
166template<>
struct T_ZTCharArray<QVector<uint>, ALIB_QTCHAR_4>
170 static const ALIB_QTCHAR_4*
Buffer (QVector<uint>
const & src) {
return reinterpret_cast<const ALIB_QTCHAR_4*
>(src.data()); }
171 static integer Length (QVector<uint>
const & src) {
return static_cast<integer >(src.size() ); }
174 QVector<uint> result;
175 result.reserve(
static_cast<int>(length) );
176 const ALIB_QTCHAR_4* end= array + length;
178 result.append(
static_cast<uint
>( *array++ ) );
#define ALIB_ASSERT_MODULE(modulename)
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
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)