mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-02-23 17:56:19 -05:00
Initial prototype of settings manager loads JSON settings file and E1.31 detector uses JSON data to detect devices
This commit is contained in:
49
SettingsManager.cpp
Normal file
49
SettingsManager.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*-----------------------------------------*\
|
||||
| SettingsManager.cpp |
|
||||
| |
|
||||
| OpenRGB Settings Manager maintains a list|
|
||||
| of application settings in JSON format. |
|
||||
| Other components may register settings |
|
||||
| with this class and store/load values. |
|
||||
| |
|
||||
| Adam Honse (CalcProgrammer1) 11/4/2020 |
|
||||
\*-----------------------------------------*/
|
||||
|
||||
#include "SettingsManager.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
SettingsManager::SettingsManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SettingsManager::~SettingsManager()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
json SettingsManager::GetSettings(std::string settings_key)
|
||||
{
|
||||
if(settings_data.contains(settings_key))
|
||||
{
|
||||
return(settings_data[settings_key]);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsManager::LoadSettings(std::string filename)
|
||||
{
|
||||
/*---------------------------------------------------------*\
|
||||
| Open input file in binary mode |
|
||||
\*---------------------------------------------------------*/
|
||||
std::ifstream settings_file(filename, std::ios::in | std::ios::binary);
|
||||
|
||||
/*---------------------------------------------------------*\
|
||||
| Read settings into JSON store |
|
||||
\*---------------------------------------------------------*/
|
||||
if(settings_file)
|
||||
{
|
||||
settings_file >> settings_data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user