Initial prototype of settings manager loads JSON settings file and E1.31 detector uses JSON data to detect devices
This commit is contained in:
parent
5b15251d46
commit
5b68efd09f
6 changed files with 275 additions and 204 deletions
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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue