Add option to set config values.
This commit is contained in:
parent
28238ba041
commit
9a83cf6c08
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.22)
|
||||
project(scsl LANGUAGES CXX
|
||||
VERSION 1.0.2
|
||||
VERSION 1.0.3
|
||||
DESCRIPTION "Shimmering Clarity Standard Library")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
|
|
@ -121,6 +121,10 @@ public:
|
|||
/// \return The value stored under the key, or the default
|
||||
/// value.
|
||||
static std::string GetGlobal(std::string &key, const std::string &defaultValue);
|
||||
|
||||
/// \brief Set a configuration value. This will override any
|
||||
/// value set.
|
||||
static void PutGlobal(std::string &key, const std::string &value);
|
||||
#endif
|
||||
|
||||
/// \brief The constructor doesn't need any initialisation.
|
||||
|
@ -173,6 +177,15 @@ public:
|
|||
/// value.
|
||||
std::string Get(std::string &key, std::string defaultValue);
|
||||
|
||||
/// \brief Set a configuration value. This will override any
|
||||
/// value set.
|
||||
///
|
||||
/// \param key The key to look up. See the class documentation
|
||||
/// for information on how this is used.
|
||||
/// \param value The value to set.
|
||||
/// \return
|
||||
void Put(std::string &key, const std::string value);
|
||||
|
||||
private:
|
||||
std::string envPrefix;
|
||||
std::map<std::string, std::string> vars;
|
||||
|
|
|
@ -90,6 +90,13 @@ SimpleConfig::GetGlobal(std::string &key, const std::string &defaultValue)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
SimpleConfig::PutGlobal(std::string &key, const std::string &value)
|
||||
{
|
||||
return globalConfig.Put(key, value);
|
||||
}
|
||||
|
||||
|
||||
SimpleConfig::SimpleConfig()
|
||||
{
|
||||
}
|
||||
|
@ -173,6 +180,13 @@ SimpleConfig::Get(std::string &key, std::string defaultValue)
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
SimpleConfig::Put(std::string &key, const std::string value)
|
||||
{
|
||||
this->vars[key] = std::move(key);
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string>
|
||||
SimpleConfig::KeyList()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue