Cogs.Core
FoundationBase.h
1#pragma once
2
3#include <cassert>
4#include <cstddef>
5#include <cstdint>
6
7#ifdef _WIN32
8// See: http://msdn.microsoft.com/en-us/library/esew7y1w.aspx
9//
10// This warning is triggered by using classes from STL when exporting our classes from a DLL. The STL classes are
11// not DLL-exported and can therefore not be shared safely between modules. However, we do not expose publicly
12// any of the STL-class members, so the warning can be ignored.
13#pragma warning(disable:4251)
14
15// When building the library:
16#ifdef COGSFOUNDATION_BUILD
17#ifdef COGSFOUNDATION_DLL
18#define COGSFOUNDATION_API __declspec(dllexport)
19#else
20#define COGSFOUNDATION_API
21#endif
22// When using the library:
23#else
24#ifdef COGSFOUNDATION_DLL
25#define COGSFOUNDATION_API __declspec(dllimport)
26#else
27#define COGSFOUNDATION_API
28#endif
29#endif
30#else
31#define COGSFOUNDATION_API
32#endif
33
34#ifndef COGS_FOUNDATION_SIZE_T_LITERAL_SUFFIX
35#define COGS_FOUNDATION_SIZE_T_LITERAL_SUFFIX 1
41constexpr size_t operator ""_uz(unsigned long long x)
42{
43 return x;
44}
45#endif
46
47#ifdef _DEBUG
48#define debug_assert(x) assert(x)
49#else
50#ifndef debug_assert
51#define debug_assert(x) ((void)0)
52#endif
53#endif
54
57namespace Cogs
58{
66 template <typename ClassType, typename FieldType>
67 inline size_t memberOffset(FieldType ClassType::*ptr)
68 {
69 return reinterpret_cast<size_t>(&((static_cast<ClassType *>(nullptr))->*ptr));
70 }
71
72 constexpr uint32_t make2CCLE(uint8_t a, uint8_t b) {
73 return (static_cast<uint32_t>(b) << 8) | a;
74 }
75
76 constexpr uint32_t make2CCBE(uint8_t a, uint8_t b) {
77 return (static_cast<uint32_t>(a) << 8) | b;
78 }
79
80 constexpr uint32_t make4CCLE( uint8_t a, uint8_t b, uint8_t c, uint8_t d ) {
81 return (static_cast<uint32_t>(d) << 24) | (static_cast<uint32_t>(c) << 16) | (static_cast<uint32_t>(b) << 8) | a;
82 }
83
84 constexpr uint32_t make4CCBE( uint8_t a, uint8_t b, uint8_t c, uint8_t d ) {
85 return (static_cast<uint32_t>(a) << 24) | (static_cast<uint32_t>(b) << 16) | (static_cast<uint32_t>(c) << 8) | d;
86 }
87
88 const char* getFoundationVersionString();
89}
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
size_t memberOffset(FieldType ClassType::*ptr)
Find the offset of a pointer to member in a class or struct.