OpenTTD Source: src/os/macosx/macos.h Source File

OpenTTD Source 15.0-RC2

macos.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef MACOS_H
11#define MACOS_H
12
14 void ShowMacDialog(std::string_view title, std::string_view message, std::string_view button_label);
15
16void GetMacOSVersion(int *return_major, int *return_minor, int *return_bugfix);
17
25 inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
26{
27 int version_major, version_minor, version_bugfix;
28 GetMacOSVersion(&version_major, &version_minor, &version_bugfix);
29
30 if (version_major < major) return false;
31 if (version_major == major && version_minor < minor) return false;
32 if (version_major == major && version_minor == minor && version_bugfix < bugfix) return false;
33
34 return true;
35}
36
37bool IsMonospaceFont(CFStringRef name);
38
39void MacOSSetThreadName(const std::string &name);
40
41uint64_t MacOSGetPhysicalMemory();
42
43
45 template <typename T> struct CFDeleter {
46 void operator()(T *p)
47 {
48 if (p) ::CFRelease(p);
49 }
50};
51
53template <typename T>
54 using CFAutoRelease = std::unique_ptr<typename std::remove_pointer<T>::type, CFDeleter<typename std::remove_pointer<T>::type>>;
55
56#endif /* MACOS_H */
ShowMacDialog
void ShowMacDialog(std::string_view title, std::string_view message, std::string_view button_label)
Helper function displaying a message the best possible way.
CFAutoRelease
std::unique_ptr< typename std::remove_pointer< T >::type, CFDeleter< typename std::remove_pointer< T >::type > > CFAutoRelease
Specialisation of std::unique_ptr for CoreFoundation objects.
Definition macos.h:54
MacOSVersionIsAtLeast
bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
Check if we are at least running on the specified version of Mac OS.
Definition macos.h:25
CFDeleter
Deleter that calls CFRelease rather than deleting the pointer.
Definition macos.h:45