Dawn/src/dawn/environment/Environment.cpp
2023-11-25 19:31:16 -06:00

32 lines
870 B
C++

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