IniFile: Handle s64/u64 values
This commit is contained in:
parent
51136681df
commit
beec40f178
|
@ -2,7 +2,10 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
// see IniFile.h
|
||||
#include "Common/IniFile.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cinttypes>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
|
@ -15,7 +16,6 @@
|
|||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
void IniFile::ParseLine(const std::string& line, std::string* keyOut, std::string* valueOut)
|
||||
|
@ -73,6 +73,41 @@ void IniFile::Section::Set(const std::string& key, const std::vector<std::string
|
|||
Set(key, temp);
|
||||
}
|
||||
|
||||
void IniFile::Section::Set(const std::string& key, u32 newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("0x%08x", newValue));
|
||||
}
|
||||
|
||||
void IniFile::Section::Set(const std::string& key, u64 new_value)
|
||||
{
|
||||
Set(key, StringFromFormat("0x%016" PRIx64, new_value));
|
||||
}
|
||||
|
||||
void IniFile::Section::Set(const std::string& key, float newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("%#.9g", newValue));
|
||||
}
|
||||
|
||||
void IniFile::Section::Set(const std::string& key, double newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("%#.17g", newValue));
|
||||
}
|
||||
|
||||
void IniFile::Section::Set(const std::string& key, int newValue)
|
||||
{
|
||||
Set(key, StringFromInt(newValue));
|
||||
}
|
||||
|
||||
void IniFile::Section::Set(const std::string& key, s64 newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("%" PRId64, newValue));
|
||||
}
|
||||
|
||||
void IniFile::Section::Set(const std::string& key, bool newValue)
|
||||
{
|
||||
Set(key, StringFromBool(newValue));
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, std::string* value,
|
||||
const std::string& defaultValue) const
|
||||
{
|
||||
|
@ -133,6 +168,18 @@ bool IniFile::Section::Get(const std::string& key, int* value, int defaultValue)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, s64* value, s64 default_value) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = default_value;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, u32* value, u32 defaultValue) const
|
||||
{
|
||||
std::string temp;
|
||||
|
@ -145,6 +192,18 @@ bool IniFile::Section::Get(const std::string& key, u32* value, u32 defaultValue)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, u64* value, u64 default_value) const
|
||||
{
|
||||
std::string temp;
|
||||
bool retval = Get(key, &temp);
|
||||
|
||||
if (retval && TryParse(temp, value))
|
||||
return true;
|
||||
|
||||
*value = default_value;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IniFile::Section::Get(const std::string& key, bool* value, bool defaultValue) const
|
||||
{
|
||||
std::string temp;
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
struct CaseInsensitiveStringCompare
|
||||
{
|
||||
|
@ -37,24 +36,14 @@ public:
|
|||
|
||||
void Set(const std::string& key, const std::string& newValue);
|
||||
void Set(const std::string& key, const std::string& newValue, const std::string& defaultValue);
|
||||
void Set(const std::string& key, u32 newValue);
|
||||
void Set(const std::string& key, u64 new_value);
|
||||
void Set(const std::string& key, float newValue);
|
||||
void Set(const std::string& key, double newValue);
|
||||
void Set(const std::string& key, int newValue);
|
||||
void Set(const std::string& key, s64 new_value);
|
||||
void Set(const std::string& key, bool newValue);
|
||||
|
||||
void Set(const std::string& key, u32 newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("0x%08x", newValue));
|
||||
}
|
||||
|
||||
void Set(const std::string& key, float newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("%#.9g", newValue));
|
||||
}
|
||||
|
||||
void Set(const std::string& key, double newValue)
|
||||
{
|
||||
Set(key, StringFromFormat("%#.17g", newValue));
|
||||
}
|
||||
|
||||
void Set(const std::string& key, int newValue) { Set(key, StringFromInt(newValue)); }
|
||||
void Set(const std::string& key, bool newValue) { Set(key, StringFromBool(newValue)); }
|
||||
template <typename T>
|
||||
void Set(const std::string& key, T newValue, const T defaultValue)
|
||||
{
|
||||
|
@ -69,7 +58,9 @@ public:
|
|||
bool Get(const std::string& key, std::string* value,
|
||||
const std::string& defaultValue = NULL_STRING) const;
|
||||
bool Get(const std::string& key, int* value, int defaultValue = 0) const;
|
||||
bool Get(const std::string& key, s64* value, s64 default_value = 0) const;
|
||||
bool Get(const std::string& key, u32* value, u32 defaultValue = 0) const;
|
||||
bool Get(const std::string& key, u64* value, u64 default_value = 0) const;
|
||||
bool Get(const std::string& key, bool* value, bool defaultValue = false) const;
|
||||
bool Get(const std::string& key, float* value, float defaultValue = 0.0f) const;
|
||||
bool Get(const std::string& key, double* value, double defaultValue = 0.0) const;
|
||||
|
|
|
@ -247,6 +247,25 @@ bool TryParse(const std::string& str, u32* const output)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool TryParse(const std::string& str, u64* const output)
|
||||
{
|
||||
char* end_ptr = nullptr;
|
||||
|
||||
// Set errno to a clean slate
|
||||
errno = 0;
|
||||
|
||||
u64 value = strtoull(str.c_str(), &end_ptr, 0);
|
||||
|
||||
if (end_ptr == nullptr || *end_ptr != '\0')
|
||||
return false;
|
||||
|
||||
if (errno == ERANGE)
|
||||
return false;
|
||||
|
||||
*output = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TryParse(const std::string& str, bool* const output)
|
||||
{
|
||||
float value;
|
||||
|
|
|
@ -61,6 +61,7 @@ std::string StringFromBool(bool value);
|
|||
|
||||
bool TryParse(const std::string& str, bool* output);
|
||||
bool TryParse(const std::string& str, u32* output);
|
||||
bool TryParse(const std::string& str, u64* output);
|
||||
|
||||
template <typename N>
|
||||
static bool TryParse(const std::string& str, N* const output)
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
// Boot.cpp CBoot::BootUp()
|
||||
// CBoot::EmulatedBS2_Wii() / GC() or Load_BS2()
|
||||
|
||||
// Includes
|
||||
// ----------------
|
||||
#include "Core/BootManager.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <string>
|
||||
|
@ -28,8 +28,8 @@
|
|||
#include "Common/IniFile.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/BootManager.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
|
||||
CEXIAgp::CEXIAgp(int index)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Thread.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "Common/Common.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "InputCommon/ControllerEmu/Control/Input.h"
|
||||
#include "InputCommon/ControllerEmu/ControlGroup/Buttons.h"
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "Common/ENetUtil.h"
|
||||
#include "Common/MD5.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Timer.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/EXI/EXI_DeviceIPL.h"
|
||||
|
|
|
@ -2,17 +2,19 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/WiiRoot.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/NandPaths.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/SysConf.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/NetPlayClient.h"
|
||||
#include "Core/WiiRoot.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include "Common/Common.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/EXI/EXI.h"
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinWX/Config/InterfaceConfigPane.h"
|
||||
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <string>
|
||||
|
@ -20,9 +22,9 @@
|
|||
#include "Common/FileSearch.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HotkeyManager.h"
|
||||
#include "DolphinWX/Config/InterfaceConfigPane.h"
|
||||
#include "DolphinWX/Frame.h"
|
||||
#include "DolphinWX/Input/InputConfigDiag.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
|
|
@ -25,17 +25,6 @@
|
|||
#include <wx/thread.h>
|
||||
#include <wx/toolbar.h>
|
||||
|
||||
#include "DolphinWX/Config/ConfigMain.h"
|
||||
#include "DolphinWX/Debugger/BreakpointDlg.h"
|
||||
#include "DolphinWX/Debugger/CodeWindow.h"
|
||||
#include "DolphinWX/Debugger/MemoryCheckDlg.h"
|
||||
#include "DolphinWX/GameListCtrl.h"
|
||||
#include "DolphinWX/Globals.h"
|
||||
#include "DolphinWX/LogWindow.h"
|
||||
#include "DolphinWX/Main.h"
|
||||
#include "DolphinWX/TASInputDlg.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
#if defined(__unix__) || defined(__unix) || defined(__APPLE__)
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
@ -49,6 +38,7 @@
|
|||
#include "Common/FileUtil.h"
|
||||
#include "Common/Flag.h"
|
||||
#include "Common/Logging/ConsoleListener.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Thread.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
|
@ -63,6 +53,17 @@
|
|||
#include "Core/Movie.h"
|
||||
#include "Core/State.h"
|
||||
|
||||
#include "DolphinWX/Config/ConfigMain.h"
|
||||
#include "DolphinWX/Debugger/BreakpointDlg.h"
|
||||
#include "DolphinWX/Debugger/CodeWindow.h"
|
||||
#include "DolphinWX/Debugger/MemoryCheckDlg.h"
|
||||
#include "DolphinWX/GameListCtrl.h"
|
||||
#include "DolphinWX/Globals.h"
|
||||
#include "DolphinWX/LogWindow.h"
|
||||
#include "DolphinWX/Main.h"
|
||||
#include "DolphinWX/TASInputDlg.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
|
||||
#include "InputCommon/GCPadStatus.h"
|
||||
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/EXI/EXI_Device.h"
|
||||
|
|
|
@ -2,20 +2,23 @@
|
|||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "DolphinWX/X11Utils.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <spawn.h>
|
||||
#include <string>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "DolphinWX/X11Utils.h"
|
||||
|
||||
extern char** environ;
|
||||
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
namespace X11Utils
|
||||
{
|
||||
bool ToggleFullscreen(Display* dpy, Window win)
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||
#include <X11/extensions/Xrandr.h>
|
||||
#endif
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define __STDC_CONSTANT_MACROS 1
|
||||
#endif
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
|
@ -18,6 +19,7 @@ extern "C" {
|
|||
#include "Common/FileUtil.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/MsgHandler.h"
|
||||
#include "Common/StringUtil.h"
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/SystemTimers.h"
|
||||
|
|
Loading…
Reference in New Issue