Version: 3.2.5

#include <wx/platinfo.h>

Detailed Description

This class holds information about the operating system, the toolkit and the basic architecture bitness of the machine where the application is currently running.

This class does not only have getters for the information above, it also has setters. This allows you to e.g. save the current platform information in a data file (maybe in string form) so that when you later load it, you can easily retrieve (see the static getters for string->enum conversion functions) and store inside a wxPlatformInfo instance (using its setters) the signature of the system which generated it.

In general however you only need to use the static Get() function and then access the various information for the current platform:

wxLogMessage("This application is running under %s.",
static const wxPlatformInfo & Get()
Returns the global wxPlatformInfo object, initialized with the values for the currently running platf...
wxString GetOperatingSystemIdName() const
Returns the operating system name of the OS associated with this wxPlatformInfo instance.
void wxLogMessage(const char *formatString,...)
For all normal, informational messages.

Library:  wxBase
Category:  Application and System configuration
See also
wxGetOsVersion(), wxIsPlatformLittleEndian(), wxIsPlatform64Bit(), wxAppTraits, Network, User and OS

Public Member Functions

 wxPlatformInfo ()
 Initializes the instance with the values corresponding to the currently running platform. More...
 
 wxPlatformInfo (wxPortId pid, int tkMajor=-1, int tkMinor=-1, wxOperatingSystemId id=wxOS_UNKNOWN, int osMajor=-1, int osMinor=-1, wxBitness bitness=wxBITNESS_INVALID, wxEndianness endian=wxENDIAN_INVALID)
 Initializes the object using given values. More...
 
bool CheckOSVersion (int major, int minor, int micro=0) const
 Returns true if the OS version is at least major.minor.micro. More...
 
bool CheckToolkitVersion (int major, int minor, int micro=0) const
 Returns true if the toolkit version is at least major.minor.micro. More...
 
bool IsOk () const
 Returns true if this instance is fully initialized with valid values. More...
 
bool IsUsingUniversalWidgets () const
 Returns true if this wxPlatformInfo describes wxUniversal build. More...
 
bool operator!= (const wxPlatformInfo &t) const
 Inequality operator. More...
 
bool operator== (const wxPlatformInfo &t) const
 Equality operator. More...
 
Getters
wxArchitecture GetArchitecture () const
 
wxBitness GetBitness () const
 Returns the architecture bitness ID of this wxPlatformInfo instance. More...
 
wxEndianness GetEndianness () const
 Returns the endianness ID of this wxPlatformInfo instance. More...
 
wxString GetCpuArchitectureName () const
 Returns the CPU architecture name, if available. More...
 
wxString GetNativeCpuArchitectureName () const
 Returns the native CPU architecture name, if available. More...
 
int GetOSMajorVersion () const
 Returns the run-time major version of the OS associated with this wxPlatformInfo instance. More...
 
int GetOSMinorVersion () const
 Returns the run-time minor version of the OS associated with this wxPlatformInfo instance. More...
 
int GetOSMicroVersion () const
 Returns the run-time micro version of the OS associated with this wxPlatformInfo instance. More...
 
wxOperatingSystemId GetOperatingSystemId () const
 Returns the operating system ID of this wxPlatformInfo instance. More...
 
wxString GetOperatingSystemDescription () const
 Returns the description of the operating system of this wxPlatformInfo instance. More...
 
wxPortId GetPortId () const
 Returns the wxWidgets port ID associated with this wxPlatformInfo instance. More...
 
wxLinuxDistributionInfo GetLinuxDistributionInfo () const
 Returns the Linux distribution info associated with this wxPlatformInfo instance. More...
 
wxString GetDesktopEnvironment () const
 Returns the desktop environment associated with this wxPlatformInfo instance. More...
 
int GetToolkitMajorVersion () const
 Returns the run-time major version of the toolkit associated with this wxPlatformInfo instance. More...
 
int GetToolkitMinorVersion () const
 Returns the run-time minor version of the toolkit associated with this wxPlatformInfo instance. More...
 
int GetToolkitMicroVersion () const
 Returns the run-time micro version of the toolkit associated with this wxPlatformInfo instance. More...
 
String-form getters
wxString GetArchName () const
 
wxString GetBitnessName () const
 Returns the name for the architecture bitness of this wxPlatformInfo instance. More...
 
wxString GetEndiannessName () const
 Returns the name for the endianness of this wxPlatformInfo instance. More...
 
wxString GetOperatingSystemFamilyName () const
 Returns the operating system family name of the OS associated with this wxPlatformInfo instance. More...
 
wxString GetOperatingSystemIdName () const
 Returns the operating system name of the OS associated with this wxPlatformInfo instance. More...
 
wxString GetPortIdName () const
 Returns the name of the wxWidgets port ID associated with this wxPlatformInfo instance. More...
 
wxString GetPortIdShortName () const
 Returns the short name of the wxWidgets port ID associated with this wxPlatformInfo instance. More...
 
Setters
void SetArchitecture (wxArchitecture n)
 
void SetBitness (wxBitness n)
 Sets the architecture bitness enum value associated with this wxPlatformInfo instance. More...
 
void SetEndianness (wxEndianness n)
 Sets the endianness enum value associated with this wxPlatformInfo instance. More...
 
void SetOSVersion (int major, int minor, int micro=0)
 Sets the version of the operating system associated with this wxPlatformInfo instance. More...
 
void SetOperatingSystemId (wxOperatingSystemId n)
 Sets the operating system associated with this wxPlatformInfo instance. More...
 
void SetPortId (wxPortId n)
 Sets the wxWidgets port ID associated with this wxPlatformInfo instance. More...
 
void SetToolkitVersion (int major, int minor, int micro=0)
 Sets the version of the toolkit associated with this wxPlatformInfo instance. More...
 
void SetOperatingSystemDescription (const wxString &desc)
 Sets the operating system description associated with this wxPlatformInfo instance. More...
 
void SetDesktopEnvironment (const wxString &de)
 Sets the desktop environment associated with this wxPlatformInfo instance. More...
 
void SetLinuxDistributionInfo (const wxLinuxDistributionInfo &di)
 Sets the linux distribution info associated with this wxPlatformInfo instance. More...
 

Static Public Member Functions

static const wxPlatformInfoGet ()
 Returns the global wxPlatformInfo object, initialized with the values for the currently running platform. More...
 
Static enum getters

These getters allow for easy string-to-enumeration-value conversion.

static wxBitness GetBitness (const wxString &bitness)
 Converts the given string to a wxBitness enum value or to wxBITNESS_INVALID if the given string is not a valid architecture bitness string (i.e. More...
 
static wxArchitecture GetArch (const wxString &arch)
 
static wxEndianness GetEndianness (const wxString &end)
 Converts the given string to a wxEndianness enum value or to wxENDIAN_INVALID if the given string is not a valid endianness string (i.e. More...
 
static wxOperatingSystemId GetOperatingSystemId (const wxString &name)
 Converts the given string to a wxOperatingSystemId enum value or to wxOS_UNKNOWN if the given string is not a valid operating system name. More...
 
static wxPortId GetPortId (const wxString &portname)
 Converts the given string to a wxWidgets port ID value or to wxPORT_UNKNOWN if the given string does not match any of the wxWidgets canonical name ports ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc). More...
 
Static string-form getters

These getters allow for easy enumeration-value-to-string conversion.

static wxString GetArchName (wxArchitecture arch)
 
static wxString GetBitnessName (wxBitness bitness)
 Returns the name for the given wxBitness enumeration value. More...
 
static wxString GetEndiannessName (wxEndianness end)
 Returns name for the given wxEndianness enumeration value. More...
 
static wxString GetOperatingSystemFamilyName (wxOperatingSystemId os)
 Returns the operating system family name for the given wxOperatingSystemId enumeration value: Unix for wxOS_UNIX, OSX for wxOS_MAC_OS, Windows for wxOS_WINDOWS. More...
 
static wxString GetOperatingSystemIdName (wxOperatingSystemId os)
 Returns the name for the given operating system ID value. More...
 
static wxString GetPortIdName (wxPortId port, bool usingUniversal)
 Returns the name of the given wxWidgets port ID value. More...
 
static wxString GetPortIdShortName (wxPortId port, bool usingUniversal)
 Returns the short name of the given wxWidgets port ID value. More...
 
static wxString GetOperatingSystemDirectory ()
 Returns the operating system directory. More...
 

Constructor & Destructor Documentation

◆ wxPlatformInfo() [1/2]

wxPlatformInfo::wxPlatformInfo ( )

Initializes the instance with the values corresponding to the currently running platform.

This is a fast operation because it only requires to copy the values internally cached for the currently running platform.

See also
Get()

◆ wxPlatformInfo() [2/2]

wxPlatformInfo::wxPlatformInfo ( wxPortId  pid,
int  tkMajor = -1,
int  tkMinor = -1,
wxOperatingSystemId  id = wxOS_UNKNOWN,
int  osMajor = -1,
int  osMinor = -1,
wxBitness  bitness = wxBITNESS_INVALID,
wxEndianness  endian = wxENDIAN_INVALID 
)

Initializes the object using given values.

Member Function Documentation

◆ CheckOSVersion()

bool wxPlatformInfo::CheckOSVersion ( int  major,
int  minor,
int  micro = 0 
) const

Returns true if the OS version is at least major.minor.micro.

See also
GetOSMajorVersion(), GetOSMinorVersion(), GetOSMicroVersion(), CheckToolkitVersion()

◆ CheckToolkitVersion()

bool wxPlatformInfo::CheckToolkitVersion ( int  major,
int  minor,
int  micro = 0 
) const

Returns true if the toolkit version is at least major.minor.micro.

See also
GetToolkitMajorVersion(), GetToolkitMinorVersion(), GetToolkitMicroVersion(), CheckOSVersion()

◆ Get()

static const wxPlatformInfo& wxPlatformInfo::Get ( )
static

Returns the global wxPlatformInfo object, initialized with the values for the currently running platform.

◆ GetArch()

static wxArchitecture wxPlatformInfo::GetArch ( const wxString arch)
static

◆ GetArchitecture()

wxArchitecture wxPlatformInfo::GetArchitecture ( ) const

◆ GetArchName() [1/2]

wxString wxPlatformInfo::GetArchName ( ) const

◆ GetArchName() [2/2]

static wxString wxPlatformInfo::GetArchName ( wxArchitecture  arch)
static

◆ GetBitness() [1/2]

wxBitness wxPlatformInfo::GetBitness ( ) const

Returns the architecture bitness ID of this wxPlatformInfo instance.

Since
3.1.5

◆ GetBitness() [2/2]

static wxBitness wxPlatformInfo::GetBitness ( const wxString bitness)
static

Converts the given string to a wxBitness enum value or to wxBITNESS_INVALID if the given string is not a valid architecture bitness string (i.e.

does not contain nor 32 nor 64 strings).

Since
3.1.5

◆ GetBitnessName() [1/2]

wxString wxPlatformInfo::GetBitnessName ( ) const

Returns the name for the architecture bitness of this wxPlatformInfo instance.

Since
3.1.5

◆ GetBitnessName() [2/2]

static wxString wxPlatformInfo::GetBitnessName ( wxBitness  bitness)
static

Returns the name for the given wxBitness enumeration value.

Since
3.1.5

◆ GetCpuArchitectureName()

wxString wxPlatformInfo::GetCpuArchitectureName ( ) const

Returns the CPU architecture name, if available.

See also
wxGetCpuArchitectureName(), GetNativeCpuArchitectureName()
Since
3.1.5

◆ GetDesktopEnvironment()

wxString wxPlatformInfo::GetDesktopEnvironment ( ) const

Returns the desktop environment associated with this wxPlatformInfo instance.

See wxAppTraits::GetDesktopEnvironment() for more info.

◆ GetEndianness() [1/2]

wxEndianness wxPlatformInfo::GetEndianness ( ) const

Returns the endianness ID of this wxPlatformInfo instance.

◆ GetEndianness() [2/2]

static wxEndianness wxPlatformInfo::GetEndianness ( const wxString end)
static

Converts the given string to a wxEndianness enum value or to wxENDIAN_INVALID if the given string is not a valid endianness string (i.e.

does not contain nor little nor big strings).

◆ GetEndiannessName() [1/2]

wxString wxPlatformInfo::GetEndiannessName ( ) const

Returns the name for the endianness of this wxPlatformInfo instance.

◆ GetEndiannessName() [2/2]

static wxString wxPlatformInfo::GetEndiannessName ( wxEndianness  end)
static

Returns name for the given wxEndianness enumeration value.

◆ GetLinuxDistributionInfo()

wxLinuxDistributionInfo wxPlatformInfo::GetLinuxDistributionInfo ( ) const

Returns the Linux distribution info associated with this wxPlatformInfo instance.

See wxGetLinuxDistributionInfo() for more info.

◆ GetNativeCpuArchitectureName()

wxString wxPlatformInfo::GetNativeCpuArchitectureName ( ) const

Returns the native CPU architecture name, if available.

Since
3.1.6
See also
wxGetNativeCpuArchitectureName(), GetCpuArchitectureName()

◆ GetOperatingSystemDescription()

wxString wxPlatformInfo::GetOperatingSystemDescription ( ) const

Returns the description of the operating system of this wxPlatformInfo instance.

See wxGetOsDescription() for more info.

◆ GetOperatingSystemDirectory()

static wxString wxPlatformInfo::GetOperatingSystemDirectory ( )
static

Returns the operating system directory.

See wxGetOSDirectory() for more info.

◆ GetOperatingSystemFamilyName() [1/2]

wxString wxPlatformInfo::GetOperatingSystemFamilyName ( ) const

Returns the operating system family name of the OS associated with this wxPlatformInfo instance.

◆ GetOperatingSystemFamilyName() [2/2]

static wxString wxPlatformInfo::GetOperatingSystemFamilyName ( wxOperatingSystemId  os)
static

Returns the operating system family name for the given wxOperatingSystemId enumeration value: Unix for wxOS_UNIX, OSX for wxOS_MAC_OS, Windows for wxOS_WINDOWS.

◆ GetOperatingSystemId() [1/2]

wxOperatingSystemId wxPlatformInfo::GetOperatingSystemId ( ) const

Returns the operating system ID of this wxPlatformInfo instance.

See wxGetOsVersion() for more info.

◆ GetOperatingSystemId() [2/2]

static wxOperatingSystemId wxPlatformInfo::GetOperatingSystemId ( const wxString name)
static

Converts the given string to a wxOperatingSystemId enum value or to wxOS_UNKNOWN if the given string is not a valid operating system name.

◆ GetOperatingSystemIdName() [1/2]

wxString wxPlatformInfo::GetOperatingSystemIdName ( ) const

Returns the operating system name of the OS associated with this wxPlatformInfo instance.

◆ GetOperatingSystemIdName() [2/2]

static wxString wxPlatformInfo::GetOperatingSystemIdName ( wxOperatingSystemId  os)
static

Returns the name for the given operating system ID value.

This can be a long name (e.g. Microsoft Windows NT); use GetOperatingSystemFamilyName() to retrieve a short, generic name.

◆ GetOSMajorVersion()

int wxPlatformInfo::GetOSMajorVersion ( ) const

Returns the run-time major version of the OS associated with this wxPlatformInfo instance.

See also
wxGetOsVersion(), CheckOSVersion()

◆ GetOSMicroVersion()

int wxPlatformInfo::GetOSMicroVersion ( ) const

Returns the run-time micro version of the OS associated with this wxPlatformInfo instance.

See also
wxGetOsVersion(), CheckOSVersion()
Since
3.1.1

◆ GetOSMinorVersion()

int wxPlatformInfo::GetOSMinorVersion ( ) const

Returns the run-time minor version of the OS associated with this wxPlatformInfo instance.

See also
wxGetOsVersion(), CheckOSVersion()

◆ GetPortId() [1/2]

wxPortId wxPlatformInfo::GetPortId ( ) const

Returns the wxWidgets port ID associated with this wxPlatformInfo instance.

◆ GetPortId() [2/2]

static wxPortId wxPlatformInfo::GetPortId ( const wxString portname)
static

Converts the given string to a wxWidgets port ID value or to wxPORT_UNKNOWN if the given string does not match any of the wxWidgets canonical name ports ("wxGTK", "wxMSW", etc) nor any of the short wxWidgets name ports ("gtk", "msw", etc).

◆ GetPortIdName() [1/2]

wxString wxPlatformInfo::GetPortIdName ( ) const

Returns the name of the wxWidgets port ID associated with this wxPlatformInfo instance.

◆ GetPortIdName() [2/2]

static wxString wxPlatformInfo::GetPortIdName ( wxPortId  port,
bool  usingUniversal 
)
static

Returns the name of the given wxWidgets port ID value.

The usingUniversal argument specifies whether the port is in its native or wxUniversal variant.

The returned string always starts with the "wx" prefix and is a mixed-case string.

◆ GetPortIdShortName() [1/2]

wxString wxPlatformInfo::GetPortIdShortName ( ) const

Returns the short name of the wxWidgets port ID associated with this wxPlatformInfo instance.

◆ GetPortIdShortName() [2/2]

static wxString wxPlatformInfo::GetPortIdShortName ( wxPortId  port,
bool  usingUniversal 
)
static

Returns the short name of the given wxWidgets port ID value.

The usingUniversal argument specifies whether the port is in its native or wxUniversal variant.

The returned string does not start with the "wx" prefix and is always lower case.

◆ GetToolkitMajorVersion()

int wxPlatformInfo::GetToolkitMajorVersion ( ) const

Returns the run-time major version of the toolkit associated with this wxPlatformInfo instance.

Note that if GetPortId() returns wxPORT_BASE, then this value is zero (unless externally modified with SetToolkitVersion()); that is, no native toolkit is in use. See wxAppTraits::GetToolkitVersion() for more info.

See also
CheckToolkitVersion()

◆ GetToolkitMicroVersion()

int wxPlatformInfo::GetToolkitMicroVersion ( ) const

Returns the run-time micro version of the toolkit associated with this wxPlatformInfo instance.

Note that if GetPortId() returns wxPORT_BASE, then this value is zero (unless externally modified with SetToolkitVersion()); that is, no native toolkit is in use. See wxAppTraits::GetToolkitVersion() for more info.

See also
CheckToolkitVersion()
Since
3.1.1

◆ GetToolkitMinorVersion()

int wxPlatformInfo::GetToolkitMinorVersion ( ) const

Returns the run-time minor version of the toolkit associated with this wxPlatformInfo instance.

Note that if GetPortId() returns wxPORT_BASE, then this value is zero (unless externally modified with SetToolkitVersion()); that is, no native toolkit is in use. See wxAppTraits::GetToolkitVersion() for more info.

See also
CheckToolkitVersion()

◆ IsOk()

bool wxPlatformInfo::IsOk ( ) const

Returns true if this instance is fully initialized with valid values.

◆ IsUsingUniversalWidgets()

bool wxPlatformInfo::IsUsingUniversalWidgets ( ) const

Returns true if this wxPlatformInfo describes wxUniversal build.

◆ operator!=()

bool wxPlatformInfo::operator!= ( const wxPlatformInfo t) const

Inequality operator.

Tests all class' internal variables.

◆ operator==()

bool wxPlatformInfo::operator== ( const wxPlatformInfo t) const

Equality operator.

Tests all class' internal variables.

◆ SetArchitecture()

void wxPlatformInfo::SetArchitecture ( wxArchitecture  n)

◆ SetBitness()

void wxPlatformInfo::SetBitness ( wxBitness  n)

Sets the architecture bitness enum value associated with this wxPlatformInfo instance.

Since
3.1.5

◆ SetDesktopEnvironment()

void wxPlatformInfo::SetDesktopEnvironment ( const wxString de)

Sets the desktop environment associated with this wxPlatformInfo instance.

◆ SetEndianness()

void wxPlatformInfo::SetEndianness ( wxEndianness  n)

Sets the endianness enum value associated with this wxPlatformInfo instance.

◆ SetLinuxDistributionInfo()

void wxPlatformInfo::SetLinuxDistributionInfo ( const wxLinuxDistributionInfo di)

Sets the linux distribution info associated with this wxPlatformInfo instance.

◆ SetOperatingSystemDescription()

void wxPlatformInfo::SetOperatingSystemDescription ( const wxString desc)

Sets the operating system description associated with this wxPlatformInfo instance.

◆ SetOperatingSystemId()

void wxPlatformInfo::SetOperatingSystemId ( wxOperatingSystemId  n)

Sets the operating system associated with this wxPlatformInfo instance.

◆ SetOSVersion()

void wxPlatformInfo::SetOSVersion ( int  major,
int  minor,
int  micro = 0 
)

Sets the version of the operating system associated with this wxPlatformInfo instance.

◆ SetPortId()

void wxPlatformInfo::SetPortId ( wxPortId  n)

Sets the wxWidgets port ID associated with this wxPlatformInfo instance.

◆ SetToolkitVersion()

void wxPlatformInfo::SetToolkitVersion ( int  major,
int  minor,
int  micro = 0 
)

Sets the version of the toolkit associated with this wxPlatformInfo instance.