AUI Framework  master
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
platform.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 Alex2772 and Contributors
    4 *
    5 * SPDX-License-Identifier: MPL-2.0
    6 *
    7 * This Source Code Form is subject to the terms of the Mozilla Public
    8 * License, v. 2.0. If a copy of the MPL was not distributed with this
    9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
   10 */
   11
   12#pragma once
   13
   14#include <type_traits>
   15
   16namespace aui::platform {
   17    namespace mobile {
   18        using is_vertical_layout_preferred = std::true_type;
   19
   20        constexpr bool is_mobile() {
   21            return true;
   22        }
   23    }
   24
   25    namespace desktop {
   26        using is_vertical_layout_preferred = std::false_type;
   27
   28        constexpr bool is_mobile() {
   29            return false;
   30        }
   31    }
   32
   33    namespace os_windows {
   34        constexpr char path_variable_separator = ';';
   35        using namespace desktop;
   36
   37#if AUI_PLATFORM_WIN
   38#endif
   39
   40        constexpr bool is_windows() {
   41            return true;
   42        }
   43
   44        constexpr bool is_unix() {
   45            return false;
   46        }
   47        constexpr bool is_apple() {
   48            return false;
   49        }
   50
   51        static const char* name() {
   52            return "windows";
   53        }
   54
   55    }
   56    namespace os_unix {
   57        using namespace desktop;
   58
   59        constexpr char path_variable_separator = ':';
   60
   61        static const char* name() {
   62            return "unix";
   63        }
   64
   65        constexpr bool is_windows() {
   66            return false;
   67        }
   68
   69        constexpr bool is_unix() {
   70            return true;
   71        }
   72        constexpr bool is_apple() {
   73            return false;
   74        }
   75    }
   76    namespace macos {
   77        using namespace desktop;
   78
   79        constexpr char path_variable_separator = ':';
   80
   81        static const char* name() {
   82            return "osx";
   83        }
   84
   85        constexpr bool is_windows() {
   86            return false;
   87        }
   88
   89        constexpr bool is_unix() {
   90            return true;
   91        }
   92        constexpr bool is_apple() {
   93            return true;
   94        }
   95    }
   96    namespace os_android {
   97        using namespace mobile;
   98
   99        constexpr char path_variable_separator = ':';
  100
  101        static const char* name() {
  102            return "android";
  103        }
  104
  105
  106        constexpr bool is_windows() {
  107            return false;
  108        }
  109
  110        constexpr bool is_unix() {
  111            return true;
  112        }
  113
  114        constexpr bool is_apple() {
  115            return false;
  116        }
  117    }
  118    namespace os_ios {
  119        using namespace mobile;
  120
  121        constexpr char path_variable_separator = ':';
  122
  123        static const char* name() {
  124            return "ios";
  125        }
  126
  127
  128        constexpr bool is_windows() {
  129            return false;
  130        }
  131
  132        constexpr bool is_unix() {
  133            return true;
  134        }
  135
  136        constexpr bool is_apple() {
  137            return true;
  138        }
  139    }
  140
  141    constexpr bool is_64_bit = sizeof(void*) == 8;
  142    constexpr bool is_32_bit = sizeof(void*) == 4;
  143
  144    constexpr bool is_x86 = AUI_ARCH_X86;
  145    constexpr bool is_x86_64 = AUI_ARCH_X86_64;
  146
  150    constexpr bool is_armv7 = AUI_ARCH_ARM_V7;
  151
  155    constexpr bool is_arm64 = AUI_ARCH_ARM_64;
  156
  157#if AUI_PLATFORM_WIN
  158    namespace current = os_windows;
  159#elif AUI_PLATFORM_ANDROID
  160    namespace current = os_android;
  161#elif AUI_PLATFORM_MACOS
  162    namespace current = macos;
  163#elif AUI_PLATFORM_IOS
  164    namespace current = os_ios;
  165#else
  166    namespace current = os_unix;
  167#endif
  168}