Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/base/StarConfiguration.hpp
blob: 4f5d97cf0382e5df26063e0d55ee2044a041acb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#pragma once

#include "StarJson.hpp"
#include "StarThread.hpp"
#include "StarVersion.hpp"

namespace Star {

STAR_CLASS(Configuration);

STAR_EXCEPTION(ConfigurationException, StarException);

class Configuration {
public:
  Configuration(Json defaultConfiguration, Json currentConfiguration);

  Json defaultConfiguration() const;
  Json currentConfiguration() const;
  String printConfiguration() const;

  Json get(String const& key, Json def = {}) const;
  Json getPath(String const& path, Json def = {}) const;

  Json getDefault(String const& key) const;
  Json getDefaultPath(String const& path) const;

  void set(String const& key, Json const& value);
  void setPath(String const& path, Json const& value);

private:
  mutable Mutex m_mutex;

  Json m_defaultConfig;
  Json m_currentConfig;
};

}