OpenTTD Source 20260129-master-g2bb01bd0e4
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
14void ShowMacDialog(std::string_view title, std::string_view message, std::string_view button_label);
15
16std::tuple<int, int, int> GetMacOSVersion();
17
18bool IsMonospaceFont(CFStringRef name);
19
20void MacOSSetThreadName(const std::string &name);
21
22uint64_t MacOSGetPhysicalMemory();
23
24
26template <typename T> struct CFDeleter {
27 void operator()(T *p)
28 {
29 if (p) ::CFRelease(p);
30 }
31};
32
34template <typename T>
35using CFAutoRelease = std::unique_ptr<typename std::remove_pointer<T>::type, CFDeleter<typename std::remove_pointer<T>::type>>;
36
37#endif /* MACOS_H */
bool IsMonospaceFont(CFStringRef name)
Check if a font is a monospace font.
Definition macos.mm:167
std::tuple< int, int, int > GetMacOSVersion()
Get the version of the MacOS we are running under.
Definition macos.mm:32
uint64_t MacOSGetPhysicalMemory()
Ask OS how much RAM it has physically attached.
Definition macos.mm:192
void MacOSSetThreadName(const std::string &name)
Set the name of the current thread for the debugger.
Definition macos.mm:178
void ShowMacDialog(std::string_view title, std::string_view message, std::string_view button_label)
Helper function displaying a message the best possible way.
Definition macos.mm:48
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:35
Deleter that calls CFRelease rather than deleting the pointer.
Definition macos.h:26