mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 09:54:54 -05:00
The "core" macro conditions and actions have been extracted out to the "base" plugin. The library now mostly contains functionality which is required across all plugins and (e.g. definitions for macro segments). The goal is to reduce the complexity and cross-dependencies and group the source files in a better way. This should relsove the "library limit of 65535 objects exceeded" build issue occuring in some Windows build environments.
82 lines
1.5 KiB
C++
82 lines
1.5 KiB
C++
#include "variable-string.hpp"
|
|
#include "utility.hpp"
|
|
|
|
namespace advss {
|
|
|
|
void StringVariable::Resolve() const
|
|
{
|
|
if (GetVariables().empty()) {
|
|
_resolvedValue = _value;
|
|
return;
|
|
}
|
|
if (_lastResolve == GetLastVariableChangeTime()) {
|
|
return;
|
|
}
|
|
_resolvedValue = SubstitueVariables(_value);
|
|
_lastResolve = GetLastVariableChangeTime();
|
|
}
|
|
|
|
StringVariable::operator std::string() const
|
|
{
|
|
Resolve();
|
|
return _resolvedValue;
|
|
}
|
|
|
|
StringVariable::operator QVariant() const
|
|
{
|
|
return QVariant::fromValue<StringVariable>(*this);
|
|
}
|
|
|
|
void StringVariable::operator=(std::string value)
|
|
{
|
|
_value = value;
|
|
_lastResolve = {};
|
|
}
|
|
|
|
void StringVariable::operator=(const char *value)
|
|
{
|
|
_value = value;
|
|
_lastResolve = {};
|
|
}
|
|
|
|
void StringVariable::Load(obs_data_t *obj, const char *name)
|
|
{
|
|
_value = obs_data_get_string(obj, name);
|
|
Resolve();
|
|
}
|
|
|
|
void StringVariable::Save(obs_data_t *obj, const char *name) const
|
|
{
|
|
obs_data_set_string(obj, name, _value.c_str());
|
|
}
|
|
|
|
const char *StringVariable::c_str()
|
|
{
|
|
Resolve();
|
|
return _resolvedValue.c_str();
|
|
}
|
|
|
|
const char *StringVariable::c_str() const
|
|
{
|
|
Resolve();
|
|
return _resolvedValue.c_str();
|
|
}
|
|
|
|
bool StringVariable::empty() const
|
|
{
|
|
Resolve();
|
|
return _resolvedValue.empty();
|
|
}
|
|
|
|
std::string SubstitueVariables(std::string str)
|
|
{
|
|
for (const auto &v : GetVariables()) {
|
|
const auto &variable = std::dynamic_pointer_cast<Variable>(v);
|
|
const std::string pattern = "${" + variable->Name() + "}";
|
|
ReplaceAll(str, pattern, variable->Value());
|
|
}
|
|
return str;
|
|
}
|
|
|
|
} // namespace advss
|