OpenTTD Source 20260711-master-g3fb3006dff
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
9
10#ifndef MACOS_H
11#define MACOS_H
12
13void ShowMacDialog(std::string_view title, std::string_view message, std::string_view button_label);
14
15std::tuple<int, int, int> GetMacOSVersion();
16
17bool IsMonospaceFont(CFStringRef name);
18
19void MacOSSetThreadName(const std::string &name);
20
21uint64_t MacOSGetPhysicalMemory();
22
23
25template <typename T> struct CFDeleter {
26 void operator()(T *p)
27 {
28 if (p) ::CFRelease(p);
29 }
30};
31
33template <typename T>
34using CFAutoRelease = std::unique_ptr<typename std::remove_pointer<T>::type, CFDeleter<typename std::remove_pointer<T>::type>>;
35
36#endif /* MACOS_H */
#define T
Climate temperate.
Definition engines.h:91
bool IsMonospaceFont(CFStringRef name)
Check if a font is a monospace font.
Definition macos.mm:178
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:203
void MacOSSetThreadName(const std::string &name)
Set the name of the current thread for the debugger.
Definition macos.mm:189
void ShowMacDialog(std::string_view title, std::string_view message, std::string_view button_label)
Show the system dialogue message, uses Cocoa if available and console otherwise.
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:34
Deleter that calls CFRelease rather than deleting the pointer.
Definition macos.h:25