4 changed files with 90 additions and 22 deletions
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Riyyi |
||||
* |
||||
* SPDX-License-Identifier: MIT |
||||
*/ |
||||
|
||||
#include "settings.h" |
||||
|
||||
namespace blaze { |
||||
|
||||
std::string_view Settings::get(std::string_view key) const |
||||
{ |
||||
VERIFY(m_settings.find(key) != m_settings.end(), "setting does not exist"); |
||||
return m_settings.at(key); |
||||
}; |
||||
|
||||
} // namespace blaze
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Riyyi |
||||
* |
||||
* SPDX-License-Identifier: MIT |
||||
*/ |
||||
|
||||
#pragma once |
||||
|
||||
#include "ruc/meta/assert.h" |
||||
#include "ruc/singleton.h" |
||||
#include <string> |
||||
#include <string_view> |
||||
#include <unordered_map> |
||||
#include <vector> |
||||
|
||||
namespace blaze { |
||||
|
||||
class Settings final : public ruc::Singleton<Settings> { |
||||
public: |
||||
Settings(s) {} |
||||
virtual ~Settings() = default; |
||||
|
||||
std::string_view get(std::string_view key) const; |
||||
void set(std::string_view key, std::string_view value) { m_settings[key] = value; }; |
||||
|
||||
private: |
||||
std::unordered_map<std::string_view, std::string_view> m_settings; |
||||
}; |
||||
|
||||
} // namespace blaze
|
Loading…
Reference in new issue