1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-16 10:19:47 +02:00
vcmi/mapeditor/StdInc.h

56 lines
1.4 KiB
C
Raw Normal View History

2022-09-18 01:23:17 +02:00
#pragma once
#include "../Global.h"
#define VCMI_EDITOR_VERSION "0.1"
#define VCMI_EDITOR_NAME "VCMI Map Editor"
#include <QtWidgets>
#include <QStringList>
#include <QSet>
#include <QVector>
#include <QList>
#include <QString>
#include <QFile>
2022-10-16 11:49:47 +02:00
VCMI_LIB_USING_NAMESPACE
2022-10-15 22:20:21 +02:00
using NumericPointer = typename std::conditional<sizeof(void *) == sizeof(unsigned long long),
unsigned long long, unsigned int>::type;
2022-09-19 01:17:39 +02:00
template<class Type>
NumericPointer data_cast(Type * _pointer)
{
static_assert(sizeof(Type *) == sizeof(NumericPointer),
2022-10-15 22:20:21 +02:00
"Cannot compile for that architecture, see NumericPointer definition");
2022-09-19 01:17:39 +02:00
return reinterpret_cast<NumericPointer>(_pointer);
}
template<class Type>
Type * data_cast(NumericPointer _numeric)
{
static_assert(sizeof(Type *) == sizeof(NumericPointer),
2022-10-15 22:20:21 +02:00
"Cannot compile for that architecture, see NumericPointer definition");
2022-09-19 01:17:39 +02:00
return reinterpret_cast<Type *>(_numeric);
}
2022-09-18 01:23:17 +02:00
inline QString pathToQString(const boost::filesystem::path & path)
{
#ifdef VCMI_WINDOWS
return QString::fromStdWString(path.wstring());
#else
return QString::fromStdString(path.string());
#endif
}
inline boost::filesystem::path qstringToPath(const QString & path)
{
#ifdef VCMI_WINDOWS
return boost::filesystem::path(path.toStdWString());
#else
return boost::filesystem::path(path.toUtf8().data());
#endif
}