Ocean
Ocean::Platform::Apple::Utilities Class Reference

This class implements utilitiy functions for Apple platforms. More...

Static Public Member Functions

static ScopedCFStringRef toCFString (const std::string &value)
 Converts a given string to a CFString reference object. More...
 
static ScopedCFStringRef toCFString (const std::wstring &value)
 Converts a given string to a CFString reference object. More...
 
static ScopedCGImageRef toCGImage (const Frame &frame, bool copyData=true)
 Creates an CGImage object for a given frame object. More...
 
static bool asNSImageOrUIImage (const Frame &frame)
 This function is a simple helper function to debug a frame on iOS or macOS. More...
 
static void showMessageBox (const std::string &title, const std::string &message)
 Shows a modal message box with a title, a message and an OK button. More...
 
static std::string documentDirectory ()
 Returns the path to the document directory of the application. More...
 
static bool hasFixedSupportedInterfaceOrientation (int &zAxisDegree)
 Returns whether the application's main window has exactly one supported interface orientation. More...
 
static bool bundleVersion (std::string &bundleShortVersion, std::string *bundleVersionKey=nullptr)
 Returns the application's version number. More...
 

Detailed Description

This class implements utilitiy functions for Apple platforms.

Member Function Documentation

◆ asNSImageOrUIImage()

static bool Ocean::Platform::Apple::Utilities::asNSImageOrUIImage ( const Frame frame)
static

This function is a simple helper function to debug a frame on iOS or macOS.

Within the function, Xcode's Quick look debugging functionality can be used to visualize the image's content.

Parameters
frameThe frame to be debugged, must be valid
Returns
True, if the frame could be handled
See also
toCGImage().

◆ bundleVersion()

static bool Ocean::Platform::Apple::Utilities::bundleVersion ( std::string &  bundleShortVersion,
std::string *  bundleVersionKey = nullptr 
)
static

Returns the application's version number.

Parameters
bundleShortVersionThe resulting release version number of the bundle
bundleVersionKeyOptional resulting version key of the bundle, nullptr if not of interest
Returns
True, if succeeded

◆ documentDirectory()

static std::string Ocean::Platform::Apple::Utilities::documentDirectory ( )
static

Returns the path to the document directory of the application.

In a non-sandboxed application (e.g., a Mac console application), path will refer to the Documents folder in home.
In a sandboxed application (e.g., an iOS app), the path will refer to the Document folder of the app.
On iOS, you can use this path to the folder to e.g., to store files in the folder,
and you can access the data later using Apple's file sharing/accessing capabilities. Beware: You may need/want to add a 'UIFileSharingEnabled' key and a 'LSSupportsOpeningDocumentsInPlace' to the 'Info.plist' file of the application and set both to 'True'.

Returns
The document directory's path

◆ hasFixedSupportedInterfaceOrientation()

static bool Ocean::Platform::Apple::Utilities::hasFixedSupportedInterfaceOrientation ( int &  zAxisDegree)
static

Returns whether the application's main window has exactly one supported interface orientation.

         device top
...........................
.                         .
.         ^               .
.       Y |               .
.         |               .
.         |               .
.         O --------->    .
.        /        X       .
.       / Z               .
.      v                  .
.                         .
...........................
.      home button        .
...........................
      device bottom
Parameters
zAxisDegreeThe resulting angle of the supported orientation around the z-axis, possible values {-90, 0, 90, 180}
Returns
True, if so

◆ showMessageBox()

static void Ocean::Platform::Apple::Utilities::showMessageBox ( const std::string &  title,
const std::string &  message 
)
static

Shows a modal message box with a title, a message and an OK button.

Beware: This function is not supported on iOS.

Parameters
titleThe title to be shown in the box
messageThe message to be shown in the box

◆ toCFString() [1/2]

static ScopedCFStringRef Ocean::Platform::Apple::Utilities::toCFString ( const std::string &  value)
static

Converts a given string to a CFString reference object.

Beware: The resulting string must be released via CFRelease once the string is not needed anymore.

Parameters
valueThe string to convert, may be empty
Returns
The resulting converted string object

◆ toCFString() [2/2]

static ScopedCFStringRef Ocean::Platform::Apple::Utilities::toCFString ( const std::wstring &  value)
static

Converts a given string to a CFString reference object.

Beware: The resulting string must be released via CFRelease once the string is not needed anymore.

Parameters
valueThe string to convert, may be empty
Returns
The resulting converted string object

◆ toCGImage()

static ScopedCGImageRef Ocean::Platform::Apple::Utilities::toCGImage ( const Frame frame,
bool  copyData = true 
)
static

Creates an CGImage object for a given frame object.

The frame data can either be copied or used only.
If the frame data is not copied, the frame data must exist as long as any related object exists relying on the resulting CGImage.
Beware: The caller has to release the image object by calling CGImageRelease.

This function can be used to e.g., debug a Frame object within Xcode by using the Quick look functionality. Here is a code example how to debug the an image:

#import <UIKit/UIKit.h>
// the following image object can be visualized in Xcode (via `Quick look`)
UIImage* image = [[UIImage alloc] initWithCGImage:cgImage];
static ScopedCGImageRef toCGImage(const Frame &frame, bool copyData=true)
Creates an CGImage object for a given frame object.
ScopedObjectCompileTimeVoidT< CGImageRef, CGImageRelease > ScopedCGImageRef
Definition of a scoped object holding a CGImageRef object.
Definition: platform/apple/Apple.h:79
Parameters
frameThe frame from which the CGImage object will be created
copyDataTrue, to create an CGImage object owning the frame data; False, to create an CGImageo object using the frame data only
Returns
The resulting CGImage object, nullptr if the conversion failed
See also
asNSImageOrUIImage().

The documentation for this class was generated from the following file: