mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-27 06:48:33 +00:00
Android: Replace Java INI parser with C++ INI parser
Fixes https://bugs.dolphin-emu.org/issues/12096.
This commit is contained in:
parent
74f197caed
commit
c6a308380c
35 changed files with 1238 additions and 2253 deletions
|
@ -28,6 +28,20 @@ static jobject SectionToJava(JNIEnv* env, jobject ini_file, IniFile::Section* se
|
|||
ini_file, reinterpret_cast<jlong>(section));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T GetInSection(JNIEnv* env, jobject obj, jstring key, T default_value)
|
||||
{
|
||||
T result;
|
||||
GetSectionPointer(env, obj)->Get(GetJString(env, key), &result, default_value);
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void SetInSection(JNIEnv* env, jobject obj, jstring key, T new_value)
|
||||
{
|
||||
GetSectionPointer(env, obj)->Set(GetJString(env, key), new_value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static T Get(JNIEnv* env, jobject obj, jstring section_name, jstring key, T default_value)
|
||||
{
|
||||
|
@ -50,6 +64,66 @@ static void Set(JNIEnv* env, jobject obj, jstring section_name, jstring key, T n
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_exists(
|
||||
JNIEnv* env, jobject obj, jstring key)
|
||||
{
|
||||
return static_cast<jboolean>(GetSectionPointer(env, obj)->Exists(GetJString(env, key)));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_delete(
|
||||
JNIEnv* env, jobject obj, jstring key)
|
||||
{
|
||||
return static_cast<jboolean>(GetSectionPointer(env, obj)->Delete(GetJString(env, key)));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getString(
|
||||
JNIEnv* env, jobject obj, jstring key, jstring default_value)
|
||||
{
|
||||
return ToJString(env, GetInSection(env, obj, key, GetJString(env, default_value)));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getBoolean(
|
||||
JNIEnv* env, jobject obj, jstring key, jboolean default_value)
|
||||
{
|
||||
return static_cast<jboolean>(GetInSection(env, obj, key, static_cast<bool>(default_value)));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getInt(
|
||||
JNIEnv* env, jobject obj, jstring key, jint default_value)
|
||||
{
|
||||
return GetInSection(env, obj, key, default_value);
|
||||
}
|
||||
|
||||
JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_getFloat(
|
||||
JNIEnv* env, jobject obj, jstring key, jfloat default_value)
|
||||
{
|
||||
return GetInSection(env, obj, key, default_value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setString(
|
||||
JNIEnv* env, jobject obj, jstring key, jstring new_value)
|
||||
{
|
||||
SetInSection(env, obj, key, GetJString(env, new_value));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setBoolean(
|
||||
JNIEnv* env, jobject obj, jstring key, jboolean new_value)
|
||||
{
|
||||
SetInSection(env, obj, key, static_cast<bool>(new_value));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setInt(
|
||||
JNIEnv* env, jobject obj, jstring key, jint new_value)
|
||||
{
|
||||
SetInSection(env, obj, key, new_value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_00024Section_setFloat(
|
||||
JNIEnv* env, jobject obj, jstring key, jfloat new_value)
|
||||
{
|
||||
SetInSection(env, obj, key, new_value);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_load(
|
||||
JNIEnv* env, jobject obj, jstring path, jboolean keep_current_data)
|
||||
{
|
||||
|
@ -64,6 +138,41 @@ JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_save(JNI
|
|||
return static_cast<jboolean>(GetIniFilePointer(env, obj)->Save(GetJString(env, path)));
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getOrCreateSection(
|
||||
JNIEnv* env, jobject obj, jstring section_name)
|
||||
{
|
||||
return SectionToJava(
|
||||
env, obj, GetIniFilePointer(env, obj)->GetOrCreateSection(GetJString(env, section_name)));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_exists__Ljava_lang_String_2(
|
||||
JNIEnv* env, jobject obj, jstring section_name)
|
||||
{
|
||||
return static_cast<jboolean>(GetIniFilePointer(env, obj)->Exists(GetJString(env, section_name)));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_org_dolphinemu_dolphinemu_utils_IniFile_exists__Ljava_lang_String_2Ljava_lang_String_2(
|
||||
JNIEnv* env, jobject obj, jstring section_name, jstring key)
|
||||
{
|
||||
return static_cast<jboolean>(
|
||||
GetIniFilePointer(env, obj)->Exists(GetJString(env, section_name), GetJString(env, key)));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_deleteSection(
|
||||
JNIEnv* env, jobject obj, jstring section_name)
|
||||
{
|
||||
return static_cast<jboolean>(
|
||||
GetIniFilePointer(env, obj)->DeleteSection(GetJString(env, section_name)));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_deleteKey(
|
||||
JNIEnv* env, jobject obj, jstring section_name, jstring key)
|
||||
{
|
||||
return static_cast<jboolean>(
|
||||
GetIniFilePointer(env, obj)->DeleteKey(GetJString(env, section_name), GetJString(env, key)));
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getString(
|
||||
JNIEnv* env, jobject obj, jstring section_name, jstring key, jstring default_value)
|
||||
{
|
||||
|
@ -84,6 +193,12 @@ JNIEXPORT jint JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getInt(JNIEn
|
|||
return Get(env, obj, section_name, key, default_value);
|
||||
}
|
||||
|
||||
JNIEXPORT jfloat JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_getFloat(
|
||||
JNIEnv* env, jobject obj, jstring section_name, jstring key, jfloat default_value)
|
||||
{
|
||||
return Get(env, obj, section_name, key, default_value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_setString(
|
||||
JNIEnv* env, jobject obj, jstring section_name, jstring key, jstring new_value)
|
||||
{
|
||||
|
@ -104,6 +219,12 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_setInt(JNIEn
|
|||
Set(env, obj, section_name, key, new_value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_setFloat(
|
||||
JNIEnv* env, jobject obj, jstring section_name, jstring key, jfloat new_value)
|
||||
{
|
||||
Set(env, obj, section_name, key, new_value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_finalize(JNIEnv* env,
|
||||
jobject obj)
|
||||
{
|
||||
|
@ -116,6 +237,13 @@ JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_newIniFile(
|
|||
return reinterpret_cast<jlong>(new IniFile);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_org_dolphinemu_dolphinemu_utils_IniFile_copyIniFile(JNIEnv* env,
|
||||
jobject obj,
|
||||
jobject other)
|
||||
{
|
||||
return reinterpret_cast<jlong>(new IniFile(*GetIniFilePointer(env, other)));
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue