-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/irov/Mengine
- Loading branch information
Showing
11 changed files
with
154 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#pragma once | ||
|
||
#include "Config/Char.h" | ||
#include "Config/StdDef.h" | ||
|
||
namespace Mengine | ||
{ | ||
namespace Helper | ||
{ | ||
bool AppleGetUserDefaultsString( const Char * _key, Char * const _value, size_t _capacity ); | ||
bool AppleSetUserDefaultsString( const Char * _key, const Char * _value ); | ||
bool AppleGetUserDefaultsBoolean( const Char * _key, bool _default ); | ||
bool AppleSetUserDefaultsBoolean( const Char * _key, bool _value ); | ||
|
||
bool AppleRemoveUserDefaults( const Char * _key ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
#include "AppleUserDefaults.h" | ||
|
||
#include "Kernel/StringCopy.h" | ||
|
||
#if defined(MENGINE_PLATFORM_MACOS) | ||
# import <AppKit/AppKit.h> | ||
#else | ||
# import <UIKit/UIKit.h> | ||
#endif | ||
|
||
namespace Mengine | ||
{ | ||
namespace Helper | ||
{ | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleGetUserDefaultsString( const Char * _key, Char * const _value, size_t _capacity ) | ||
{ | ||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; | ||
|
||
if( defaults == nil ) | ||
{ | ||
return false; | ||
} | ||
|
||
NSString * _Nullable value = [defaults objectForKey:@(_key)]; | ||
|
||
if( value == nil ) | ||
{ | ||
return false; | ||
} | ||
|
||
const Char * value_str = [value UTF8String]; | ||
|
||
Helper::stringCopy( _value, value_str, _capacity ); | ||
|
||
return true; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleSetUserDefaultsString( const Char * _key, const Char * _value ) | ||
{ | ||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; | ||
|
||
if( defaults == nil ) | ||
{ | ||
return false; | ||
} | ||
|
||
[defaults setObject:@(_value) forKey:@(_key)]; | ||
|
||
[defaults synchronize]; | ||
|
||
return true; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleGetUserDefaultsBoolean( const Char * _key, bool _default ) | ||
{ | ||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; | ||
|
||
if( defaults == nil ) | ||
{ | ||
return _default; | ||
} | ||
|
||
NSNumber * _Nullable value = [defaults objectForKey:@(_key)]; | ||
|
||
if( value == nil ) | ||
{ | ||
return _default; | ||
} | ||
|
||
BOOL value_bool = [value boolValue]; | ||
|
||
return (bool)value_bool; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleSetUserDefaultsBoolean( const Char * _key, bool _value ) | ||
{ | ||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; | ||
|
||
if( defaults == nil ) | ||
{ | ||
return false; | ||
} | ||
|
||
[defaults setObject:@(_value) forKey:@(_key)]; | ||
|
||
[defaults synchronize]; | ||
|
||
return true; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleRemoveUserDefaults( const Char * _key ) | ||
{ | ||
NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; | ||
|
||
if( defaults == nil ) | ||
{ | ||
return false; | ||
} | ||
|
||
[defaults removeObjectForKey:@(_key)]; | ||
|
||
[defaults synchronize]; | ||
|
||
return true; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
|
||
#include "Config/StdString.h" | ||
|
||
#import <Sentry/Sentry.h> | ||
#import "Sentry/Sentry.h" | ||
|
||
namespace Mengine | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters