OpenTTD Source 20260129-master-g2bb01bd0e4
macos.h File Reference

Functions related to MacOS support. More...

Go to the source code of this file.

Data Structures

struct  CFDeleter< T >
 Deleter that calls CFRelease rather than deleting the pointer. More...
 

Typedefs

template<typename T >
using CFAutoRelease = std::unique_ptr< typename std::remove_pointer< T >::type, CFDeleter< typename std::remove_pointer< T >::type > >
 Specialisation of std::unique_ptr for CoreFoundation objects.
 

Functions

void ShowMacDialog (std::string_view title, std::string_view message, std::string_view button_label)
 Helper function displaying a message the best possible way.
 
std::tuple< int, int, int > GetMacOSVersion ()
 Get the version of the MacOS we are running under.
 
bool IsMonospaceFont (CFStringRef name)
 Check if a font is a monospace font.
 
void MacOSSetThreadName (const std::string &name)
 Set the name of the current thread for the debugger.
 
uint64_t MacOSGetPhysicalMemory ()
 Ask OS how much RAM it has physically attached.
 

Detailed Description

Functions related to MacOS support.

Definition in file macos.h.

Typedef Documentation

◆ CFAutoRelease

template<typename T >
using CFAutoRelease = std::unique_ptr<typename std::remove_pointer<T>::type, CFDeleter<typename std::remove_pointer<T>::type> >

Specialisation of std::unique_ptr for CoreFoundation objects.

Definition at line 35 of file macos.h.

Function Documentation

◆ GetMacOSVersion()

std::tuple< int, int, int > GetMacOSVersion ( )

Get the version of the MacOS we are running under.

Returns
Tuple with major, minor and patch of the MacOS version.

Definition at line 32 of file macos.mm.

◆ IsMonospaceFont()

bool IsMonospaceFont ( CFStringRef  name)

Check if a font is a monospace font.

Parameters
nameName of the font.
Returns
True if the font is a monospace font.

Definition at line 167 of file macos.mm.

◆ MacOSGetPhysicalMemory()

uint64_t MacOSGetPhysicalMemory ( )

Ask OS how much RAM it has physically attached.

Returns
Number of available bytes.

Definition at line 192 of file macos.mm.

◆ MacOSSetThreadName()

void MacOSSetThreadName ( const std::string &  name)

Set the name of the current thread for the debugger.

Parameters
nameThe new name of the current thread.

Definition at line 178 of file macos.mm.

Referenced by SetCurrentThreadName().

◆ ShowMacDialog()

void ShowMacDialog ( std::string_view  title,
std::string_view  message,
std::string_view  buttonLabel 
)

Helper function displaying a message the best possible way.

Helper function displaying a message the best possible way.

Parameters
titleWindow title.
messageMessage text.
buttonLabelButton text.

Definition at line 48 of file macos.mm.

References CocoaDialog().

Referenced by CrashLogOSX::DisplayCrashDialog(), HandleCrash(), and ShowOSErrorBox().