StdInc.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * StdInc.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../Global.h"
  12. #include <QtWidgets>
  13. #ifdef ENABLE_TEMPLATE_EDITOR
  14. #include <QtSvg>
  15. #include <QSvgRenderer>
  16. #include <QDomDocument>
  17. #endif
  18. #include <QStringList>
  19. #include <QSet>
  20. #include <QVector>
  21. #include <QList>
  22. #include <QString>
  23. #include <QFile>
  24. #include "../vcmiqt/convpathqstring.h"
  25. VCMI_LIB_USING_NAMESPACE
  26. using NumericPointer = typename std::conditional_t<sizeof(void *) == sizeof(unsigned long long),
  27. unsigned long long, unsigned int>;
  28. template<class Type>
  29. NumericPointer data_cast(Type * _pointer)
  30. {
  31. static_assert(sizeof(Type *) == sizeof(NumericPointer),
  32. "Cannot compile for that architecture, see NumericPointer definition");
  33. return reinterpret_cast<NumericPointer>(_pointer);
  34. }
  35. template<class Type>
  36. Type * data_cast(NumericPointer _numeric)
  37. {
  38. static_assert(sizeof(Type *) == sizeof(NumericPointer),
  39. "Cannot compile for that architecture, see NumericPointer definition");
  40. return reinterpret_cast<Type *>(_numeric);
  41. }