mirror of https://github.com/mgba-emu/mgba.git
Core: Add mCoreConfigGetBoolValue
This commit is contained in:
parent
603de394d8
commit
58ddecb830
|
@ -78,6 +78,7 @@ bool mCoreConfigIsPortable(void);
|
|||
#endif
|
||||
|
||||
const char* mCoreConfigGetValue(const struct mCoreConfig*, const char* key);
|
||||
bool mCoreConfigGetBoolValue(const struct mCoreConfig*, const char* key, bool* value);
|
||||
bool mCoreConfigGetIntValue(const struct mCoreConfig*, const char* key, int* value);
|
||||
bool mCoreConfigGetUIntValue(const struct mCoreConfig*, const char* key, unsigned* value);
|
||||
bool mCoreConfigGetFloatValue(const struct mCoreConfig*, const char* key, float* value);
|
||||
|
|
|
@ -89,6 +89,20 @@ static bool _lookupCharValue(const struct mCoreConfig* config, const char* key,
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool _lookupBoolValue(const struct mCoreConfig* config, const char* key, bool* out) {
|
||||
const char* charValue = _lookupValue(config, key);
|
||||
if (!charValue) {
|
||||
return false;
|
||||
}
|
||||
char* end;
|
||||
long value = strtol(charValue, &end, 10);
|
||||
if (*end) {
|
||||
return false;
|
||||
}
|
||||
*out = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _lookupIntValue(const struct mCoreConfig* config, const char* key, int* out) {
|
||||
const char* charValue = _lookupValue(config, key);
|
||||
if (!charValue) {
|
||||
|
@ -314,6 +328,10 @@ const char* mCoreConfigGetValue(const struct mCoreConfig* config, const char* ke
|
|||
return _lookupValue(config, key);
|
||||
}
|
||||
|
||||
bool mCoreConfigGetBoolValue(const struct mCoreConfig* config, const char* key, bool* value) {
|
||||
return _lookupBoolValue(config, key, value);
|
||||
}
|
||||
|
||||
bool mCoreConfigGetIntValue(const struct mCoreConfig* config, const char* key, int* value) {
|
||||
return _lookupIntValue(config, key, value);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue