Texture loading done.
This commit is contained in:
10
src/dawn/environment/CMakeLists.txt
Normal file
10
src/dawn/environment/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# Copyright (c) 2023 Dominic Msters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
# Sources
|
||||
target_sources(${DAWN_TARGET_NAME}
|
||||
PRIVATE
|
||||
Environment.cpp
|
||||
)
|
31
src/dawn/environment/Environment.cpp
Normal file
31
src/dawn/environment/Environment.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2023 Dominic Masters
|
||||
//
|
||||
// This software is released under the MIT License.
|
||||
// https://opensource.org/licenses/MIT
|
||||
|
||||
#include "Environment.hpp"
|
||||
#include "assert/assert.hpp"
|
||||
|
||||
using namespace Dawn;
|
||||
|
||||
Environment environment;
|
||||
|
||||
bool_t Environment::hasVariable(const std::string &key) {
|
||||
assertTrue(key.length() > 0, "Key must be at least 1 character long.");
|
||||
return this->variables.find(key) != this->variables.end();
|
||||
}
|
||||
|
||||
void Environment::setVariable(
|
||||
const std::string &key,
|
||||
const std::string &value
|
||||
) {
|
||||
assertTrue(key.length() > 0, "Key must be at least 1 character long.");
|
||||
|
||||
this->variables[key] = value;
|
||||
}
|
||||
|
||||
std::string Environment::getVariable(const std::string &key) {
|
||||
assertTrue(key.length() > 0, "Key must be at least 1 character long.");
|
||||
assertTrue(this->hasVariable(key), "Variable does not exist.");
|
||||
return this->variables[key];
|
||||
}
|
@ -8,8 +8,34 @@
|
||||
|
||||
namespace Dawn {
|
||||
class Environment {
|
||||
public:
|
||||
private:
|
||||
std::map<std::string, std::string> variables;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Checks if the environment has a variable.
|
||||
*
|
||||
* @param key Variable key to check.
|
||||
* @return True if the variable exists, false otherwise.
|
||||
*/
|
||||
bool_t hasVariable(const std::string &key);
|
||||
|
||||
/**
|
||||
* Sets a variable in the environment.
|
||||
*
|
||||
* @param key Variable key to set.
|
||||
* @param value Variable value to set.
|
||||
*/
|
||||
void setVariable(const std::string &key, const std::string &value);
|
||||
|
||||
/**
|
||||
* Gets a variable from the environment.
|
||||
*
|
||||
* @param key Variable key to get.
|
||||
* @return Variable value, or empty string if not found.
|
||||
*/
|
||||
std::string getVariable(const std::string &key);
|
||||
};
|
||||
extern Dawn::Environment environment;
|
||||
}
|
||||
|
||||
extern Dawn::Environment environment;
|
Reference in New Issue
Block a user