aboutsummaryrefslogtreecommitdiff
path: root/include/Platform.hpp
blob: 955df5785f7351cca772014846587ca0c5330b44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once

#include "types.hpp"
#include "StringView.hpp"
#include <vector>

namespace sibs
{
    enum Platform : u64
    {
        PLATFORM_INVALID    = 0x00000000,

        PLATFORM_ANY        = 0xFFFFFFFF,

        PLATFORM_POSIX     = 1 << 1,
        PLATFORM_POSIX32   = 1 << 2 | PLATFORM_POSIX,
        PLATFORM_POSIX64   = 1 << 3 | PLATFORM_POSIX,

        PLATFORM_LINUX      = 1 << 4 | PLATFORM_POSIX,
        PLATFORM_LINUX32    = 1 << 5 | PLATFORM_LINUX | PLATFORM_POSIX32,
        PLATFORM_LINUX64    = 1 << 6 | PLATFORM_LINUX | PLATFORM_POSIX64,

        PLATFORM_WIN        = 1 << 7,
        PLATFORM_WIN32      = 1 << 8 | PLATFORM_WIN,
        PLATFORM_WIN64      = 1 << 9 | PLATFORM_WIN,

        PLATFORM_MACOS      = 1 << 10 | PLATFORM_POSIX,
        PLATFORM_MACOS32    = 1 << 11 | PLATFORM_MACOS | PLATFORM_POSIX32,
        PLATFORM_MACOS64    = 1 << 12 | PLATFORM_MACOS | PLATFORM_POSIX64,

        PLATFORM_BSD        = 1 << 13 | PLATFORM_POSIX,
        PLATFORM_OPENBSD    = 1 << 14 | PLATFORM_BSD,
        PLATFORM_OPENBSD32  = 1 << 15 | PLATFORM_OPENBSD | PLATFORM_POSIX32,
        PLATFORM_OPENBSD64  = 1 << 16 | PLATFORM_OPENBSD | PLATFORM_POSIX64,

        PLATFORM_HAIKU      = 1 << 24 | PLATFORM_POSIX,
        PLATFORM_HAIKU32    = 1 << 25 | PLATFORM_HAIKU | PLATFORM_POSIX32,
        PLATFORM_HAIKU64    = 1 << 26 | PLATFORM_HAIKU | PLATFORM_POSIX64
    };

    const StringViewMap<Platform> PLATFORM_BY_NAME = {
        { "any", PLATFORM_ANY },
        { "posix", PLATFORM_POSIX },
        { "posix32", PLATFORM_POSIX32 },
        { "posix64", PLATFORM_POSIX64 },
        { "linux", PLATFORM_LINUX },
        { "linux32", PLATFORM_LINUX32 },
        { "linux64", PLATFORM_LINUX64 },
        { "win", PLATFORM_WIN },
        { "win32", PLATFORM_WIN32 },
        { "win64", PLATFORM_WIN64 },
        { "macos", PLATFORM_MACOS },
        { "macos32", PLATFORM_MACOS32 },
        { "macos64", PLATFORM_MACOS64 },
        { "bsd", PLATFORM_BSD },
        { "openbsd", PLATFORM_OPENBSD },
        { "openbsd32", PLATFORM_OPENBSD32 },
        { "openbsd64", PLATFORM_OPENBSD64 },
        { "haiku", PLATFORM_HAIKU },
        { "haiku32", PLATFORM_HAIKU32 },
        { "haiku64", PLATFORM_HAIKU64 },
    };

    bool containsPlatform(const std::vector<Platform> &platforms, Platform platform);
    const char* asString(Platform platform);
    Platform getPlatformByName(StringView name);
    // Return true if both platforms are of same type, for example if platform @a is either win, win32, win64 and @b is either win, win32, win64
    bool isSamePlatformFamily(Platform a, Platform b);
    // Returns true if platform @base is a base platform for platform @platform, for example if @platform is win64 and @base is either win64 or win, then this function return true.
    // If for example @platform is win64 and @base is win32, then this function returns false.
    bool isBaseForPlatform(Platform base, Platform platform);
    Platform getPlatformGenericType(Platform platform);
}