StdInc.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "../Global.h"
  3. #define VCMI_EDITOR_VERSION "0.2"
  4. #define VCMI_EDITOR_NAME "VCMI Map Editor"
  5. #include <QtWidgets>
  6. #include <QStringList>
  7. #include <QSet>
  8. #include <QVector>
  9. #include <QList>
  10. #include <QString>
  11. #include <QFile>
  12. VCMI_LIB_USING_NAMESPACE
  13. using NumericPointer = typename std::conditional<sizeof(void *) == sizeof(unsigned long long),
  14. unsigned long long, unsigned int>::type;
  15. template<class Type>
  16. NumericPointer data_cast(Type * _pointer)
  17. {
  18. static_assert(sizeof(Type *) == sizeof(NumericPointer),
  19. "Cannot compile for that architecture, see NumericPointer definition");
  20. return reinterpret_cast<NumericPointer>(_pointer);
  21. }
  22. template<class Type>
  23. Type * data_cast(NumericPointer _numeric)
  24. {
  25. static_assert(sizeof(Type *) == sizeof(NumericPointer),
  26. "Cannot compile for that architecture, see NumericPointer definition");
  27. return reinterpret_cast<Type *>(_numeric);
  28. }
  29. inline QString pathToQString(const boost::filesystem::path & path)
  30. {
  31. #ifdef VCMI_WINDOWS
  32. return QString::fromStdWString(path.wstring());
  33. #else
  34. return QString::fromStdString(path.string());
  35. #endif
  36. }
  37. inline boost::filesystem::path qstringToPath(const QString & path)
  38. {
  39. #ifdef VCMI_WINDOWS
  40. return boost::filesystem::path(path.toStdWString());
  41. #else
  42. return boost::filesystem::path(path.toUtf8().data());
  43. #endif
  44. }