v1.4.4
This commit is contained in:
commit
9c94d113d3
10260 changed files with 1237388 additions and 0 deletions
54
source/base/StarConfiguration.cpp
Normal file
54
source/base/StarConfiguration.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
#include "StarConfiguration.hpp"
|
||||
#include "StarFile.hpp"
|
||||
#include "StarLogging.hpp"
|
||||
|
||||
namespace Star {
|
||||
|
||||
Configuration::Configuration(Json defaultConfiguration, Json currentConfiguration)
|
||||
: m_defaultConfig(defaultConfiguration), m_currentConfig(currentConfiguration) {}
|
||||
|
||||
Json Configuration::defaultConfiguration() const {
|
||||
return m_defaultConfig;
|
||||
}
|
||||
|
||||
Json Configuration::currentConfiguration() const {
|
||||
return m_currentConfig;
|
||||
}
|
||||
|
||||
Json Configuration::get(String const& key) const {
|
||||
MutexLocker locker(m_mutex);
|
||||
return m_currentConfig.get(key, {});
|
||||
}
|
||||
|
||||
Json Configuration::getPath(String const& path) const {
|
||||
MutexLocker locker(m_mutex);
|
||||
return m_currentConfig.query(path, {});
|
||||
}
|
||||
|
||||
Json Configuration::getDefault(String const& key) const {
|
||||
MutexLocker locker(m_mutex);
|
||||
return m_defaultConfig.get(key, {});
|
||||
}
|
||||
|
||||
Json Configuration::getDefaultPath(String const& path) const {
|
||||
MutexLocker locker(m_mutex);
|
||||
return m_defaultConfig.query(path, {});
|
||||
}
|
||||
|
||||
void Configuration::set(String const& key, Json const& value) {
|
||||
MutexLocker locker(m_mutex);
|
||||
if (key == "configurationVersion")
|
||||
throw ConfigurationException("cannot set configurationVersion");
|
||||
|
||||
m_currentConfig = m_currentConfig.set(key, value);
|
||||
}
|
||||
|
||||
void Configuration::setPath(String const& path, Json const& value) {
|
||||
MutexLocker locker(m_mutex);
|
||||
if (path.splitAny("[].").get(0) == "configurationVersion")
|
||||
throw ConfigurationException("cannot set configurationVersion");
|
||||
|
||||
m_currentConfig = m_currentConfig.setPath(path, value);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue