Texture loading done.

This commit is contained in:
2023-11-25 19:31:16 -06:00
parent 89fe77c07e
commit 94941b1c14
12 changed files with 233 additions and 32 deletions

View 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
)

View 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];
}

View File

@ -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;